summaryrefslogtreecommitdiffstats
path: root/generic/tclDate.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclDate.c')
-rw-r--r--generic/tclDate.c767
1 files changed, 286 insertions, 481 deletions
diff --git a/generic/tclDate.c b/generic/tclDate.c
index 8369a85..566c848 100644
--- a/generic/tclDate.c
+++ b/generic/tclDate.c
@@ -1,7 +1,7 @@
-/* A Bison parser, made by GNU Bison 1.875. */
+/* A Bison parser, made by GNU Bison 1.875b. */
/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -105,7 +105,7 @@
/* Copy the first part of user declarations. */
-#line 17 "../unix/../generic/tclGetDate.y"
+#line 17 "..\\generic/tclGetDate.y"
/*
* tclDate.c --
@@ -119,9 +119,10 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * SCCSID
*/
+#include "tclInt.h"
+
/*
* Bison generates several labels that happen to be unused. MS Visual
* C++ doesn't like that, and complains. Tell it to shut up.
@@ -132,35 +133,70 @@
#endif /* _MSC_VER */
/*
- * yyparse will accept a 'struct TclGetDateInfo' as its parameter;
+ * yyparse will accept a 'struct DateInfo' as its parameter;
* that's where the parsed fields will be returned.
*/
-#define YYPARSE_PARAM info
+typedef struct DateInfo {
-#define yyDSTmode (((TclGetDateInfo*)info)->dateDSTmode)
-#define yyDayOrdinal (((TclGetDateInfo*)info)->dateDayOrdinal)
-#define yyDayNumber (((TclGetDateInfo*)info)->dateDayNumber)
-#define yyMonthOrdinal (((TclGetDateInfo*)info)->dateMonthOrdinal)
-#define yyHaveDate (((TclGetDateInfo*)info)->dateHaveDate)
-#define yyHaveDay (((TclGetDateInfo*)info)->dateHaveDay)
-#define yyHaveOrdinalMonth (((TclGetDateInfo*)info)->dateHaveOrdinalMonth)
-#define yyHaveRel (((TclGetDateInfo*)info)->dateHaveRel)
-#define yyHaveTime (((TclGetDateInfo*)info)->dateHaveTime)
-#define yyHaveZone (((TclGetDateInfo*)info)->dateHaveZone)
-#define yyTimezone (((TclGetDateInfo*)info)->dateTimezone)
-#define yyDay (((TclGetDateInfo*)info)->dateDay)
-#define yyMonth (((TclGetDateInfo*)info)->dateMonth)
-#define yyYear (((TclGetDateInfo*)info)->dateYear)
-#define yyHour (((TclGetDateInfo*)info)->dateHour)
-#define yyMinutes (((TclGetDateInfo*)info)->dateMinutes)
-#define yySeconds (((TclGetDateInfo*)info)->dateSeconds)
-#define yyMeridian (((TclGetDateInfo*)info)->dateMeridian)
-#define yyRelMonth (((TclGetDateInfo*)info)->dateRelMonth)
-#define yyRelDay (((TclGetDateInfo*)info)->dateRelDay)
-#define yyRelSeconds (((TclGetDateInfo*)info)->dateRelSeconds)
+ time_t dateYear;
+ time_t dateMonth;
+ time_t dateDay;
+ int dateHaveDate;
-#include "tclInt.h"
+ time_t dateHour;
+ time_t dateMinutes;
+ time_t dateSeconds;
+ int dateMeridian;
+ int dateHaveTime;
+
+ time_t dateTimezone;
+ int dateDSTmode;
+ int dateHaveZone;
+
+ time_t dateRelMonth;
+ time_t dateRelDay;
+ time_t dateRelSeconds;
+ int dateHaveRel;
+
+ time_t dateMonthOrdinal;
+ int dateHaveOrdinalMonth;
+
+ time_t dateDayOrdinal;
+ time_t dateDayNumber;
+ int dateHaveDay;
+
+ char *dateInput;
+ time_t *dateRelPointer;
+
+} DateInfo;
+
+#define YYPARSE_PARAM info
+#define YYLEX_PARAM info
+
+#define yyDSTmode (((DateInfo*)info)->dateDSTmode)
+#define yyDayOrdinal (((DateInfo*)info)->dateDayOrdinal)
+#define yyDayNumber (((DateInfo*)info)->dateDayNumber)
+#define yyMonthOrdinal (((DateInfo*)info)->dateMonthOrdinal)
+#define yyHaveDate (((DateInfo*)info)->dateHaveDate)
+#define yyHaveDay (((DateInfo*)info)->dateHaveDay)
+#define yyHaveOrdinalMonth (((DateInfo*)info)->dateHaveOrdinalMonth)
+#define yyHaveRel (((DateInfo*)info)->dateHaveRel)
+#define yyHaveTime (((DateInfo*)info)->dateHaveTime)
+#define yyHaveZone (((DateInfo*)info)->dateHaveZone)
+#define yyTimezone (((DateInfo*)info)->dateTimezone)
+#define yyDay (((DateInfo*)info)->dateDay)
+#define yyMonth (((DateInfo*)info)->dateMonth)
+#define yyYear (((DateInfo*)info)->dateYear)
+#define yyHour (((DateInfo*)info)->dateHour)
+#define yyMinutes (((DateInfo*)info)->dateMinutes)
+#define yySeconds (((DateInfo*)info)->dateSeconds)
+#define yyMeridian (((DateInfo*)info)->dateMeridian)
+#define yyRelMonth (((DateInfo*)info)->dateRelMonth)
+#define yyRelDay (((DateInfo*)info)->dateRelDay)
+#define yyRelSeconds (((DateInfo*)info)->dateRelSeconds)
+#define yyRelPointer (((DateInfo*)info)->dateRelPointer)
+#define yyInput (((DateInfo*)info)->dateInput)
#define EPOCH 1970
#define START_OF_TIME 1902
@@ -168,10 +204,7 @@
/*
* The offset of tm_year of struct tm returned by localtime, gmtime, etc.
- * I don't know how universal this is; K&R II, the NetBSD manpages, and
- * ../compat/strftime.c all agree that tm_year is the year-1900. However,
- * some systems may have a different value. This #define should be the
- * same as in ../compat/strftime.c.
+ * Posix requires 1900.
*/
#define TM_YEAR_BASE 1900
@@ -205,36 +238,13 @@ typedef enum _MERIDIAN {
/*
- * Global variables. We could get rid of most of these by using a good
- * union as the yacc stack. (This routine was originally written before
- * yacc had the %union construct.) Maybe someday; right now we only use
- * the %union very rarely.
- */
-
-static char *yyInput;
-static time_t *yyRelPointer;
-
-/*
* Prototypes of internal functions.
*/
static void TclDateerror _ANSI_ARGS_((char *s));
static time_t ToSeconds _ANSI_ARGS_((time_t Hours, time_t Minutes,
time_t Seconds, MERIDIAN Meridian));
-static int Convert _ANSI_ARGS_((time_t Month, time_t Day, time_t Year,
- time_t Hours, time_t Minutes, time_t Seconds,
- MERIDIAN Meridia, DSTMODE DSTmode, time_t *TimePtr,
- VOID* info));
-static time_t DSTcorrect _ANSI_ARGS_((time_t Start, time_t Future));
-static time_t NamedDay _ANSI_ARGS_((time_t Start, time_t DayOrdinal,
- time_t DayNumber));
-static time_t NamedMonth _ANSI_ARGS_((time_t Start, time_t MonthOrdinal,
- time_t MonthNumber, VOID* info));
-static int RelativeMonth _ANSI_ARGS_((time_t Start, time_t RelMonth,
- time_t *TimePtr, VOID* info));
-static int RelativeDay _ANSI_ARGS_((time_t Start, time_t RelDay,
- time_t *TimePtr));
static int LookupWord _ANSI_ARGS_((char *buff));
-static int TclDatelex _ANSI_ARGS_((void));
+static int TclDatelex _ANSI_ARGS_((void* info));
@@ -253,13 +263,13 @@ static int TclDatelex _ANSI_ARGS_((void));
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 150 "../unix/../generic/tclGetDate.y"
+#line 160 "..\\generic/tclGetDate.y"
typedef union YYSTYPE {
time_t Number;
enum _MERIDIAN Meridian;
} YYSTYPE;
/* Line 191 of yacc.c. */
-#line 262 "../unix/../generic/tclDate.c"
+#line 273 "..\\generic/tclDate.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@@ -271,7 +281,7 @@ typedef union YYSTYPE {
/* Line 214 of yacc.c. */
-#line 274 "../unix/../generic/tclDate.c"
+#line 285 "..\\generic/tclDate.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
@@ -460,12 +470,12 @@ static const yysigned_char yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned short yyrline[] =
{
- 0, 166, 166, 167, 170, 173, 176, 179, 182, 185,
- 188, 192, 197, 200, 206, 212, 219, 225, 235, 239,
- 243, 249, 253, 257, 261, 265, 271, 275, 280, 285,
- 290, 295, 299, 304, 308, 313, 320, 324, 330, 339,
- 348, 358, 371, 376, 378, 379, 380, 381, 382, 384,
- 385, 387, 388, 389, 392, 411, 414
+ 0, 176, 176, 177, 180, 183, 186, 189, 192, 195,
+ 198, 202, 207, 210, 216, 222, 230, 236, 247, 251,
+ 255, 261, 265, 269, 273, 277, 283, 287, 292, 297,
+ 302, 307, 311, 316, 320, 325, 332, 336, 342, 351,
+ 360, 370, 383, 388, 390, 391, 392, 393, 394, 396,
+ 397, 399, 400, 401, 404, 423, 426
};
#endif
@@ -632,6 +642,7 @@ static const unsigned char yystos[] =
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrlab1
+
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
@@ -752,9 +763,9 @@ yy_reduce_print (yyrule)
#endif
{
int yyi;
- unsigned int yylineno = yyrline[yyrule];
+ unsigned int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
- yyrule - 1, yylineno);
+ yyrule - 1, yylno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
@@ -1214,49 +1225,49 @@ yyreduce:
switch (yyn)
{
case 4:
-#line 170 "../unix/../generic/tclGetDate.y"
+#line 180 "..\\generic/tclGetDate.y"
{
yyHaveTime++;
;}
break;
case 5:
-#line 173 "../unix/../generic/tclGetDate.y"
+#line 183 "..\\generic/tclGetDate.y"
{
yyHaveZone++;
;}
break;
case 6:
-#line 176 "../unix/../generic/tclGetDate.y"
+#line 186 "..\\generic/tclGetDate.y"
{
yyHaveDate++;
;}
break;
case 7:
-#line 179 "../unix/../generic/tclGetDate.y"
+#line 189 "..\\generic/tclGetDate.y"
{
yyHaveOrdinalMonth++;
;}
break;
case 8:
-#line 182 "../unix/../generic/tclGetDate.y"
+#line 192 "..\\generic/tclGetDate.y"
{
yyHaveDay++;
;}
break;
case 9:
-#line 185 "../unix/../generic/tclGetDate.y"
+#line 195 "..\\generic/tclGetDate.y"
{
yyHaveRel++;
;}
break;
case 10:
-#line 188 "../unix/../generic/tclGetDate.y"
+#line 198 "..\\generic/tclGetDate.y"
{
yyHaveTime++;
yyHaveDate++;
@@ -1264,7 +1275,7 @@ yyreduce:
break;
case 11:
-#line 192 "../unix/../generic/tclGetDate.y"
+#line 202 "..\\generic/tclGetDate.y"
{
yyHaveTime++;
yyHaveDate++;
@@ -1273,7 +1284,7 @@ yyreduce:
break;
case 13:
-#line 200 "../unix/../generic/tclGetDate.y"
+#line 210 "..\\generic/tclGetDate.y"
{
yyHour = yyvsp[-1].Number;
yyMinutes = 0;
@@ -1283,7 +1294,7 @@ yyreduce:
break;
case 14:
-#line 206 "../unix/../generic/tclGetDate.y"
+#line 216 "..\\generic/tclGetDate.y"
{
yyHour = yyvsp[-3].Number;
yyMinutes = yyvsp[-1].Number;
@@ -1293,18 +1304,19 @@ yyreduce:
break;
case 15:
-#line 212 "../unix/../generic/tclGetDate.y"
+#line 222 "..\\generic/tclGetDate.y"
{
yyHour = yyvsp[-4].Number;
yyMinutes = yyvsp[-2].Number;
yyMeridian = MER24;
yyDSTmode = DSToff;
yyTimezone = (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
+ ++yyHaveZone;
;}
break;
case 16:
-#line 219 "../unix/../generic/tclGetDate.y"
+#line 230 "..\\generic/tclGetDate.y"
{
yyHour = yyvsp[-5].Number;
yyMinutes = yyvsp[-3].Number;
@@ -1314,7 +1326,7 @@ yyreduce:
break;
case 17:
-#line 225 "../unix/../generic/tclGetDate.y"
+#line 236 "..\\generic/tclGetDate.y"
{
yyHour = yyvsp[-6].Number;
yyMinutes = yyvsp[-4].Number;
@@ -1322,11 +1334,12 @@ yyreduce:
yyMeridian = MER24;
yyDSTmode = DSToff;
yyTimezone = (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
+ ++yyHaveZone;
;}
break;
case 18:
-#line 235 "../unix/../generic/tclGetDate.y"
+#line 247 "..\\generic/tclGetDate.y"
{
yyTimezone = yyvsp[-1].Number;
yyDSTmode = DSTon;
@@ -1334,7 +1347,7 @@ yyreduce:
break;
case 19:
-#line 239 "../unix/../generic/tclGetDate.y"
+#line 251 "..\\generic/tclGetDate.y"
{
yyTimezone = yyvsp[0].Number;
yyDSTmode = DSToff;
@@ -1342,7 +1355,7 @@ yyreduce:
break;
case 20:
-#line 243 "../unix/../generic/tclGetDate.y"
+#line 255 "..\\generic/tclGetDate.y"
{
yyTimezone = yyvsp[0].Number;
yyDSTmode = DSTon;
@@ -1350,7 +1363,7 @@ yyreduce:
break;
case 21:
-#line 249 "../unix/../generic/tclGetDate.y"
+#line 261 "..\\generic/tclGetDate.y"
{
yyDayOrdinal = 1;
yyDayNumber = yyvsp[0].Number;
@@ -1358,7 +1371,7 @@ yyreduce:
break;
case 22:
-#line 253 "../unix/../generic/tclGetDate.y"
+#line 265 "..\\generic/tclGetDate.y"
{
yyDayOrdinal = 1;
yyDayNumber = yyvsp[-1].Number;
@@ -1366,7 +1379,7 @@ yyreduce:
break;
case 23:
-#line 257 "../unix/../generic/tclGetDate.y"
+#line 269 "..\\generic/tclGetDate.y"
{
yyDayOrdinal = yyvsp[-1].Number;
yyDayNumber = yyvsp[0].Number;
@@ -1374,7 +1387,7 @@ yyreduce:
break;
case 24:
-#line 261 "../unix/../generic/tclGetDate.y"
+#line 273 "..\\generic/tclGetDate.y"
{
yyDayOrdinal = yyvsp[-2].Number * yyvsp[-1].Number;
yyDayNumber = yyvsp[0].Number;
@@ -1382,7 +1395,7 @@ yyreduce:
break;
case 25:
-#line 265 "../unix/../generic/tclGetDate.y"
+#line 277 "..\\generic/tclGetDate.y"
{
yyDayOrdinal = 2;
yyDayNumber = yyvsp[0].Number;
@@ -1390,7 +1403,7 @@ yyreduce:
break;
case 26:
-#line 271 "../unix/../generic/tclGetDate.y"
+#line 283 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[-2].Number;
yyDay = yyvsp[0].Number;
@@ -1398,7 +1411,7 @@ yyreduce:
break;
case 27:
-#line 275 "../unix/../generic/tclGetDate.y"
+#line 287 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[-4].Number;
yyDay = yyvsp[-2].Number;
@@ -1407,7 +1420,7 @@ yyreduce:
break;
case 28:
-#line 280 "../unix/../generic/tclGetDate.y"
+#line 292 "..\\generic/tclGetDate.y"
{
yyYear = yyvsp[0].Number / 10000;
yyMonth = (yyvsp[0].Number % 10000)/100;
@@ -1416,7 +1429,7 @@ yyreduce:
break;
case 29:
-#line 285 "../unix/../generic/tclGetDate.y"
+#line 297 "..\\generic/tclGetDate.y"
{
yyDay = yyvsp[-4].Number;
yyMonth = yyvsp[-2].Number;
@@ -1425,7 +1438,7 @@ yyreduce:
break;
case 30:
-#line 290 "../unix/../generic/tclGetDate.y"
+#line 302 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[-2].Number;
yyDay = yyvsp[0].Number;
@@ -1434,7 +1447,7 @@ yyreduce:
break;
case 31:
-#line 295 "../unix/../generic/tclGetDate.y"
+#line 307 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[-1].Number;
yyDay = yyvsp[0].Number;
@@ -1442,7 +1455,7 @@ yyreduce:
break;
case 32:
-#line 299 "../unix/../generic/tclGetDate.y"
+#line 311 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[-3].Number;
yyDay = yyvsp[-2].Number;
@@ -1451,7 +1464,7 @@ yyreduce:
break;
case 33:
-#line 304 "../unix/../generic/tclGetDate.y"
+#line 316 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[0].Number;
yyDay = yyvsp[-1].Number;
@@ -1459,7 +1472,7 @@ yyreduce:
break;
case 34:
-#line 308 "../unix/../generic/tclGetDate.y"
+#line 320 "..\\generic/tclGetDate.y"
{
yyMonth = 1;
yyDay = 1;
@@ -1468,7 +1481,7 @@ yyreduce:
break;
case 35:
-#line 313 "../unix/../generic/tclGetDate.y"
+#line 325 "..\\generic/tclGetDate.y"
{
yyMonth = yyvsp[-1].Number;
yyDay = yyvsp[-2].Number;
@@ -1477,7 +1490,7 @@ yyreduce:
break;
case 36:
-#line 320 "../unix/../generic/tclGetDate.y"
+#line 332 "..\\generic/tclGetDate.y"
{
yyMonthOrdinal = 1;
yyMonth = yyvsp[0].Number;
@@ -1485,7 +1498,7 @@ yyreduce:
break;
case 37:
-#line 324 "../unix/../generic/tclGetDate.y"
+#line 336 "..\\generic/tclGetDate.y"
{
yyMonthOrdinal = yyvsp[-1].Number;
yyMonth = yyvsp[0].Number;
@@ -1493,7 +1506,7 @@ yyreduce:
break;
case 38:
-#line 330 "../unix/../generic/tclGetDate.y"
+#line 342 "..\\generic/tclGetDate.y"
{
if (yyvsp[-1].Number != HOUR(- 7)) YYABORT;
yyYear = yyvsp[-2].Number / 10000;
@@ -1506,7 +1519,7 @@ yyreduce:
break;
case 39:
-#line 339 "../unix/../generic/tclGetDate.y"
+#line 351 "..\\generic/tclGetDate.y"
{
if (yyvsp[-5].Number != HOUR(- 7)) YYABORT;
yyYear = yyvsp[-6].Number / 10000;
@@ -1519,7 +1532,7 @@ yyreduce:
break;
case 40:
-#line 348 "../unix/../generic/tclGetDate.y"
+#line 360 "..\\generic/tclGetDate.y"
{
yyYear = yyvsp[-1].Number / 10000;
yyMonth = (yyvsp[-1].Number % 10000)/100;
@@ -1531,7 +1544,7 @@ yyreduce:
break;
case 41:
-#line 358 "../unix/../generic/tclGetDate.y"
+#line 370 "..\\generic/tclGetDate.y"
{
/*
* Offset computed year by -377 so that the returned years will
@@ -1546,7 +1559,7 @@ yyreduce:
break;
case 42:
-#line 371 "../unix/../generic/tclGetDate.y"
+#line 383 "..\\generic/tclGetDate.y"
{
yyRelSeconds *= -1;
yyRelMonth *= -1;
@@ -1555,57 +1568,57 @@ yyreduce:
break;
case 44:
-#line 378 "../unix/../generic/tclGetDate.y"
+#line 390 "..\\generic/tclGetDate.y"
{ *yyRelPointer += yyvsp[-2].Number * yyvsp[-1].Number * yyvsp[0].Number; ;}
break;
case 45:
-#line 379 "../unix/../generic/tclGetDate.y"
+#line 391 "..\\generic/tclGetDate.y"
{ *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
break;
case 46:
-#line 380 "../unix/../generic/tclGetDate.y"
+#line 392 "..\\generic/tclGetDate.y"
{ *yyRelPointer += yyvsp[0].Number; ;}
break;
case 47:
-#line 381 "../unix/../generic/tclGetDate.y"
+#line 393 "..\\generic/tclGetDate.y"
{ *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
break;
case 48:
-#line 382 "../unix/../generic/tclGetDate.y"
+#line 394 "..\\generic/tclGetDate.y"
{ *yyRelPointer += yyvsp[0].Number; ;}
break;
case 49:
-#line 384 "../unix/../generic/tclGetDate.y"
+#line 396 "..\\generic/tclGetDate.y"
{ yyval.Number = -1; ;}
break;
case 50:
-#line 385 "../unix/../generic/tclGetDate.y"
+#line 397 "..\\generic/tclGetDate.y"
{ yyval.Number = 1; ;}
break;
case 51:
-#line 387 "../unix/../generic/tclGetDate.y"
+#line 399 "..\\generic/tclGetDate.y"
{ yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelSeconds; ;}
break;
case 52:
-#line 388 "../unix/../generic/tclGetDate.y"
+#line 400 "..\\generic/tclGetDate.y"
{ yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelDay; ;}
break;
case 53:
-#line 389 "../unix/../generic/tclGetDate.y"
+#line 401 "..\\generic/tclGetDate.y"
{ yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelMonth; ;}
break;
case 54:
-#line 393 "../unix/../generic/tclGetDate.y"
+#line 405 "..\\generic/tclGetDate.y"
{
if (yyHaveTime && yyHaveDate && !yyHaveRel) {
yyYear = yyvsp[0].Number;
@@ -1625,14 +1638,14 @@ yyreduce:
break;
case 55:
-#line 411 "../unix/../generic/tclGetDate.y"
+#line 423 "..\\generic/tclGetDate.y"
{
yyval.Meridian = MER24;
;}
break;
case 56:
-#line 414 "../unix/../generic/tclGetDate.y"
+#line 426 "..\\generic/tclGetDate.y"
{
yyval.Meridian = yyvsp[0].Meridian;
;}
@@ -1641,8 +1654,8 @@ yyreduce:
}
-/* Line 991 of yacc.c. */
-#line 1645 "../unix/../generic/tclDate.c"
+/* Line 999 of yacc.c. */
+#line 1659 "..\\generic/tclDate.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1683,18 +1696,33 @@ yyerrlab:
{
YYSIZE_T yysize = 0;
int yytype = YYTRANSLATE (yychar);
+ const char* yyprefix;
char *yymsg;
- int yyx, yycount;
+ int yyx;
- yycount = 0;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 0;
+
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- yysize += yystrlen (yytname[yyx]) + 15, yycount++;
- yysize += yystrlen ("syntax error, unexpected ") + 1;
- yysize += yystrlen (yytname[yytype]);
+ {
+ yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
+ yycount += 1;
+ if (yycount == 5)
+ {
+ yysize = 0;
+ break;
+ }
+ }
+ yysize += (sizeof ("syntax error, unexpected ")
+ + yystrlen (yytname[yytype]));
yymsg = (char *) YYSTACK_ALLOC (yysize);
if (yymsg != 0)
{
@@ -1703,16 +1731,13 @@ yyerrlab:
if (yycount < 5)
{
- yycount = 0;
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *));
- yyx++)
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
- const char *yyq = ! yycount ? ", expecting " : " or ";
- yyp = yystpcpy (yyp, yyq);
+ yyp = yystpcpy (yyp, yyprefix);
yyp = yystpcpy (yyp, yytname[yyx]);
- yycount++;
+ yyprefix = " or ";
}
}
yyerror (yymsg);
@@ -1756,30 +1781,13 @@ yyerrlab:
/* Else will try to reuse lookahead token after shifting the error
token. */
- goto yyerrlab2;
+ goto yyerrlab1;
/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action. |
`----------------------------------------------------*/
yyerrlab1:
-
- /* Suppress GCC warning that yyerrlab1 is unused when no action
- invokes YYERROR. Doesn't work in C++ */
-#ifndef __cplusplus
-#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
- __attribute__ ((__unused__))
-#endif
-#endif
-
-
- goto yyerrlab2;
-
-
-/*---------------------------------------------------------------.
-| yyerrlab2 -- pop states until the error token can be shifted. |
-`---------------------------------------------------------------*/
-yyerrlab2:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
@@ -1853,7 +1861,7 @@ yyreturn:
}
-#line 419 "../unix/../generic/tclGetDate.y"
+#line 431 "..\\generic/tclGetDate.y"
/*
@@ -2059,7 +2067,6 @@ TclDateerror(s)
{
}
-
static time_t
ToSeconds(Hours, Minutes, Seconds, Meridian)
time_t Hours;
@@ -2086,238 +2093,6 @@ ToSeconds(Hours, Minutes, Seconds, Meridian)
return -1; /* Should never be reached */
}
-/*
- *-----------------------------------------------------------------------------
- *
- * Convert --
- *
- * Convert a {month, day, year, hours, minutes, seconds, meridian, dst}
- * tuple into a clock seconds value.
- *
- * Results:
- * 0 or -1 indicating success or failure.
- *
- * Side effects:
- * Fills TimePtr with the computed value.
- *
- *-----------------------------------------------------------------------------
- */
-static int
-Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode, TimePtr, info)
- time_t Month;
- time_t Day;
- time_t Year;
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
- DSTMODE DSTmode;
- time_t *TimePtr;
- VOID* info;
-{
- static int DaysInMonth[12] = {
- 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- time_t tod;
- time_t Julian;
- int i;
-
- /* Figure out how many days are in February for the given year.
- * Every year divisible by 4 is a leap year.
- * But, every year divisible by 100 is not a leap year.
- * But, every year divisible by 400 is a leap year after all.
- */
- DaysInMonth[1] = IsLeapYear(Year) ? 29 : 28;
-
- /* Check the inputs for validity */
- if (Month < 1 || Month > 12
- || Year < START_OF_TIME || Year > END_OF_TIME
- || Day < 1 || Day > DaysInMonth[(int)--Month])
- return -1;
-
- /* Start computing the value. First determine the number of days
- * represented by the date, then multiply by the number of seconds/day.
- */
- for (Julian = Day - 1, i = 0; i < Month; i++)
- Julian += DaysInMonth[i];
- if (Year >= EPOCH) {
- for (i = EPOCH; i < Year; i++)
- Julian += 365 + IsLeapYear(i);
- } else {
- for (i = Year; i < EPOCH; i++)
- Julian -= 365 + IsLeapYear(i);
- }
- Julian *= SECSPERDAY;
-
- /* Add the timezone offset ?? */
- Julian += yyTimezone * 60L;
-
- /* Add the number of seconds represented by the time component */
- if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
- return -1;
- Julian += tod;
-
- /* Perform a preliminary DST compensation ?? */
- if (DSTmode == DSTon
- || (DSTmode == DSTmaybe && TclpGetDate(&Julian, 0)->tm_isdst))
- Julian -= 60 * 60;
- *TimePtr = Julian;
- return 0;
-}
-
-
-static time_t
-DSTcorrect(Start, Future)
- time_t Start;
- time_t Future;
-{
- time_t StartDay;
- time_t FutureDay;
- StartDay = (TclpGetDate(&Start, 0)->tm_hour + 1) % 24;
- FutureDay = (TclpGetDate(&Future, 0)->tm_hour + 1) % 24;
- return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
-}
-
-
-static time_t
-NamedDay(Start, DayOrdinal, DayNumber)
- time_t Start;
- time_t DayOrdinal;
- time_t DayNumber;
-{
- struct tm *tm;
- time_t now;
-
- now = Start;
- tm = TclpGetDate(&now, 0);
- now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
- now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
- return DSTcorrect(Start, now);
-}
-
-static time_t
-NamedMonth(Start, MonthOrdinal, MonthNumber, info)
- time_t Start;
- time_t MonthOrdinal;
- time_t MonthNumber;
- VOID* info;
-{
- struct tm *tm;
- time_t now;
- int result;
-
- now = Start;
- tm = TclpGetDate(&now, 0);
- /* To compute the next n'th month, we use this alg:
- * add n to year value
- * if currentMonth < requestedMonth decrement year value by 1 (so that
- * doing next february from january gives us february of the current year)
- * set day to 1, time to 0
- */
- tm->tm_year += MonthOrdinal;
- if (tm->tm_mon < MonthNumber - 1) {
- tm->tm_year--;
- }
- result = Convert(MonthNumber, (time_t) 1, tm->tm_year + TM_YEAR_BASE,
- (time_t) 0, (time_t) 0, (time_t) 0, MER24, DSTmaybe, &now, info);
- if (result < 0) {
- return 0;
- }
- return DSTcorrect(Start, now);
-}
-
-static int
-RelativeMonth(Start, RelMonth, TimePtr, info)
- time_t Start;
- time_t RelMonth;
- time_t *TimePtr;
- VOID* info;
-{
- struct tm *tm;
- time_t Month;
- time_t Year;
- time_t Julian;
- int result;
-
- if (RelMonth == 0) {
- *TimePtr = 0;
- return 0;
- }
- tm = TclpGetDate(&Start, 0);
- Month = 12 * (tm->tm_year + TM_YEAR_BASE) + tm->tm_mon + RelMonth;
- Year = Month / 12;
- Month = Month % 12 + 1;
- result = Convert(Month, (time_t) tm->tm_mday, Year,
- (time_t) tm->tm_hour, (time_t) tm->tm_min, (time_t) tm->tm_sec,
- MER24, DSTmaybe, &Julian, info);
-
- /*
- * The Julian time returned above is behind by one day, if "month"
- * or "year" is used to specify relative time and the GMT flag is true.
- * This problem occurs only when the current time is closer to
- * midnight, the difference being not more than its time difference
- * with GMT. For example, in US/Pacific time zone, the problem occurs
- * whenever the current time is between midnight to 8:00am or 7:00amDST.
- * See Bug# 413397 for more details and sample script.
- * To resolve this bug, we simply add the number of seconds corresponding
- * to timezone difference with GMT to Julian time, if GMT flag is true.
- */
-
- if (yyTimezone == 0) {
- Julian += TclpGetTimeZone((unsigned long) Start) * 60L;
- }
-
- /*
- * The following iteration takes into account the case were we jump
- * into a "short month". Far example, "one month from Jan 31" will
- * fail because there is no Feb 31. The code below will reduce the
- * day and try converting the date until we succed or the date equals
- * 28 (which always works unless the date is bad in another way).
- */
-
- while ((result != 0) && (tm->tm_mday > 28)) {
- tm->tm_mday--;
- result = Convert(Month, (time_t) tm->tm_mday, Year,
- (time_t) tm->tm_hour, (time_t) tm->tm_min, (time_t) tm->tm_sec,
- MER24, DSTmaybe, &Julian, info);
- }
- if (result != 0) {
- return -1;
- }
- *TimePtr = DSTcorrect(Start, Julian);
- return 0;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * RelativeDay --
- *
- * Given a starting time and a number of days before or after, compute the
- * DST corrected difference between those dates.
- *
- * Results:
- * 1 or -1 indicating success or failure.
- *
- * Side effects:
- * Fills TimePtr with the computed value.
- *
- *-----------------------------------------------------------------------------
- */
-
-static int
-RelativeDay(Start, RelDay, TimePtr)
- time_t Start;
- time_t RelDay;
- time_t *TimePtr;
-{
- time_t new;
-
- new = Start + (RelDay * 60 * 60 * 24);
- *TimePtr = DSTcorrect(Start, new);
- return 1;
-}
static int
LookupWord(buff)
@@ -2438,9 +2213,8 @@ LookupWord(buff)
return tID;
}
-
static int
-TclDatelex()
+TclDatelex( void* info )
{
register char c;
register char *p;
@@ -2496,118 +2270,149 @@ TclDatelex()
}
}
-/*
- * Specify zone is of -50000 to force GMT. (This allows BST to work).
- */
-
int
-TclGetDate(p, now, zone, timePtr)
- char *p;
- unsigned long now;
- long zone;
- unsigned long *timePtr;
+TclClockOldscanObjCmd( clientData, interp, objc, objv )
+ ClientData clientData; /* Unused */
+ Tcl_Interp* interp; /* Tcl interpreter */
+ int objc; /* Count of paraneters */
+ Tcl_Obj *CONST *objv; /* Parameters */
{
- struct tm *tm;
- time_t Start;
- time_t Time;
- time_t tod;
- int thisyear;
- TclGetDateInfo dateInfo;
+ Tcl_Obj* result;
+ Tcl_Obj* resultElement;
+ int yr, mo, da;
+ DateInfo dateInfo;
void* info = (void*) &dateInfo;
- yyInput = p;
- /* now has to be cast to a time_t for 64bit compliance */
- Start = now;
- tm = TclpGetDate(&Start, (zone == -50000));
- thisyear = tm->tm_year + TM_YEAR_BASE;
- yyYear = thisyear;
- yyMonth = tm->tm_mon + 1;
- yyDay = tm->tm_mday;
- yyTimezone = zone;
- if (zone == -50000) {
- yyDSTmode = DSToff; /* assume GMT */
- yyTimezone = 0;
- } else {
- yyDSTmode = DSTmaybe;
+ if ( objc != 5 ) {
+ Tcl_WrongNumArgs( interp, 1, objv,
+ "stringToParse baseYear baseMonth baseDay" );
+ return TCL_ERROR;
}
- yyHour = 0;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = MER24;
- yyRelSeconds = 0;
- yyRelMonth = 0;
- yyRelDay = 0;
- yyRelPointer = NULL;
+
+ yyInput = Tcl_GetString( objv[1] );
yyHaveDate = 0;
- yyHaveDay = 0;
- yyHaveOrdinalMonth = 0;
- yyHaveRel = 0;
+ if ( Tcl_GetIntFromObj( interp, objv[2], &yr ) != TCL_OK
+ || Tcl_GetIntFromObj( interp, objv[3], &mo ) != TCL_OK
+ || Tcl_GetIntFromObj( interp, objv[4], &da ) != TCL_OK ) {
+ return TCL_ERROR;
+ }
+ yyYear = yr; yyMonth = mo; yyDay = da;
+
yyHaveTime = 0;
+ yyHour = 0; yyMinutes = 0; yySeconds = 0; yyMeridian = MER24;
+
yyHaveZone = 0;
+ yyTimezone = 0; yyDSTmode = DSTmaybe;
- if (yyparse(info) || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 ||
- yyHaveDay > 1 || yyHaveOrdinalMonth > 1) {
- return -1;
+ yyHaveOrdinalMonth = 0;
+ yyMonthOrdinal = 0;
+
+ yyHaveDay = 0;
+ yyDayOrdinal = 0; yyDayNumber = 0;
+
+ yyHaveRel = 0;
+ yyRelMonth = 0; yyRelDay = 0; yyRelSeconds = 0; yyRelPointer = NULL;
+
+ if ( yyparse( info ) ) {
+ Tcl_SetObjResult( interp, Tcl_NewStringObj( "syntax error", -1 ) );
+ return TCL_ERROR;
}
-
- if (yyHaveDate || yyHaveTime || yyHaveDay) {
- if (yyYear < 0) {
- yyYear = -yyYear;
- }
- /*
- * The following line handles years that are specified using
- * only two digits. The line of code below implements a policy
- * defined by the X/Open workgroup on the millinium rollover.
- * Note: some of those dates may not actually be valid on some
- * platforms. The POSIX standard startes that the dates 70-99
- * shall refer to 1970-1999 and 00-38 shall refer to 2000-2038.
- * This later definition should work on all platforms.
- */
-
- if (yyYear < 100) {
- if (yyYear >= 69) {
- yyYear += 1900;
- } else {
- yyYear += 2000;
- }
- }
- if (Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
- yyMeridian, yyDSTmode, &Start, info) < 0) {
- return -1;
- }
+
+ if ( yyHaveDate > 1 ) {
+ Tcl_SetObjResult
+ ( interp,
+ Tcl_NewStringObj( "more than one date in string", -1 ) );
+ return TCL_ERROR;
+ }
+ if ( yyHaveTime > 1 ) {
+ Tcl_SetObjResult
+ ( interp,
+ Tcl_NewStringObj( "more than one time of day in string", -1 ) );
+ return TCL_ERROR;
+ }
+ if ( yyHaveZone > 1 ) {
+ Tcl_SetObjResult
+ ( interp,
+ Tcl_NewStringObj( "more than one time zone in string", -1 ) );
+ return TCL_ERROR;
+ }
+ if ( yyHaveDay > 1 ) {
+ Tcl_SetObjResult
+ ( interp,
+ Tcl_NewStringObj( "more than one weekday in string", -1 ) );
+ return TCL_ERROR;
+ }
+ if ( yyHaveOrdinalMonth > 1 ) {
+ Tcl_SetObjResult
+ ( interp,
+ Tcl_NewStringObj( "more than one ordinal month in string", -1 ) );
+ return TCL_ERROR;
+ }
+
+ result = Tcl_NewObj();
+ resultElement = Tcl_NewObj();
+ if ( yyHaveDate ) {
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyYear ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyMonth ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyDay ) );
+ }
+ Tcl_ListObjAppendElement( interp, result, resultElement );
+
+ if ( yyHaveTime ) {
+ Tcl_ListObjAppendElement( interp, result,
+ Tcl_NewIntObj( ToSeconds( yyHour,
+ yyMinutes,
+ yySeconds,
+ yyMeridian ) ) );
} else {
- Start = now;
- if (!yyHaveRel) {
- Start -= ((tm->tm_hour * 60L * 60L) +
- tm->tm_min * 60L) + tm->tm_sec;
- }
+ Tcl_ListObjAppendElement( interp, result, Tcl_NewObj() );
}
- Start += yyRelSeconds;
- if (RelativeMonth(Start, yyRelMonth, &Time, info) < 0) {
- return -1;
+ resultElement = Tcl_NewObj();
+ if ( yyHaveZone ) {
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( -yyTimezone ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( 1-yyDSTmode ) );
}
- Start += Time;
-
- if (RelativeDay(Start, yyRelDay, &Time) < 0) {
- return -1;
+ Tcl_ListObjAppendElement( interp, result, resultElement );
+
+ resultElement = Tcl_NewObj();
+ if ( yyHaveRel ) {
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyRelMonth ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyRelDay ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyRelSeconds ) );
}
- Start += Time;
-
- if (yyHaveDay && !yyHaveDate) {
- tod = NamedDay(Start, yyDayOrdinal, yyDayNumber);
- Start += tod;
+ Tcl_ListObjAppendElement( interp, result, resultElement );
+
+ resultElement = Tcl_NewObj();
+ if ( yyHaveDay && !yyHaveDate ) {
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyDayOrdinal ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyDayNumber ) );
}
-
- if (yyHaveOrdinalMonth) {
- tod = NamedMonth(Start, yyMonthOrdinal, yyMonth, info);
- Start += tod;
+ Tcl_ListObjAppendElement( interp, result, resultElement );
+
+ resultElement = Tcl_NewObj();
+ if ( yyHaveOrdinalMonth ) {
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyMonthOrdinal ) );
+ Tcl_ListObjAppendElement( interp, resultElement,
+ Tcl_NewIntObj( yyMonth ) );
}
-
- *timePtr = Start;
- return 0;
+ Tcl_ListObjAppendElement( interp, result, resultElement );
+
+ Tcl_SetObjResult( interp, result );
+ return TCL_OK;
}