diff options
author | kennykb <kennykb@noemail.net> | 2004-12-29 20:57:24 (GMT) |
---|---|---|
committer | kennykb <kennykb@noemail.net> | 2004-12-29 20:57:24 (GMT) |
commit | bfb5407182ecb6762c0f4b1bd305c0f283e68a53 (patch) | |
tree | 443fafc914ab6f557d09f08d00406daa7772ee6e /generic/tclDate.c | |
parent | cd8637a0f2474450c426af344561a41e13617293 (diff) | |
download | tcl-bfb5407182ecb6762c0f4b1bd305c0f283e68a53.zip tcl-bfb5407182ecb6762c0f4b1bd305c0f283e68a53.tar.gz tcl-bfb5407182ecb6762c0f4b1bd305c0f283e68a53.tar.bz2 |
bugs 1090413, 1092789 fixed
FossilOrigin-Name: c237cdd9eca448e03244267b222acb6131c1eacc
Diffstat (limited to 'generic/tclDate.c')
-rw-r--r-- | generic/tclDate.c | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/generic/tclDate.c b/generic/tclDate.c index a3b2109..ee07443 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" + /* * tclDate.c -- @@ -169,6 +169,8 @@ typedef struct DateInfo { char *dateInput; time_t *dateRelPointer; + int dateDigitCount; + } DateInfo; #define YYPARSE_PARAM info @@ -197,6 +199,7 @@ typedef struct DateInfo { #define yyRelSeconds (((DateInfo*)info)->dateRelSeconds) #define yyRelPointer (((DateInfo*)info)->dateRelPointer) #define yyInput (((DateInfo*)info)->dateInput) +#define yyDigitCount (((DateInfo*)info)->dateDigitCount) #define EPOCH 1970 #define START_OF_TIME 1902 @@ -263,13 +266,13 @@ static int TclDatelex _ANSI_ARGS_((void* info)); #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 160 "../unix/../generic/tclGetDate.y" + typedef union YYSTYPE { time_t Number; enum _MERIDIAN Meridian; } YYSTYPE; /* Line 191 of yacc.c. */ -#line 272 "../unix/../generic/tclDate.c" + # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -281,7 +284,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c. */ -#line 284 "../unix/../generic/tclDate.c" + #if ! defined (yyoverflow) || YYERROR_VERBOSE @@ -470,12 +473,12 @@ static const yysigned_char yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { - 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 + 0, 179, 179, 180, 183, 186, 189, 192, 195, 198, + 201, 205, 210, 213, 219, 225, 233, 239, 250, 254, + 258, 264, 268, 272, 276, 280, 286, 290, 295, 300, + 305, 310, 314, 319, 323, 328, 335, 339, 345, 354, + 363, 373, 386, 391, 393, 394, 395, 396, 397, 399, + 400, 402, 403, 404, 407, 426, 429 }; #endif @@ -642,6 +645,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. */ @@ -762,9 +766,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]]); @@ -1224,49 +1228,49 @@ yyreduce: switch (yyn) { case 4: -#line 180 "../unix/../generic/tclGetDate.y" + { yyHaveTime++; ;} break; case 5: -#line 183 "../unix/../generic/tclGetDate.y" + { yyHaveZone++; ;} break; case 6: -#line 186 "../unix/../generic/tclGetDate.y" + { yyHaveDate++; ;} break; case 7: -#line 189 "../unix/../generic/tclGetDate.y" + { yyHaveOrdinalMonth++; ;} break; case 8: -#line 192 "../unix/../generic/tclGetDate.y" + { yyHaveDay++; ;} break; case 9: -#line 195 "../unix/../generic/tclGetDate.y" + { yyHaveRel++; ;} break; case 10: -#line 198 "../unix/../generic/tclGetDate.y" + { yyHaveTime++; yyHaveDate++; @@ -1274,7 +1278,7 @@ yyreduce: break; case 11: -#line 202 "../unix/../generic/tclGetDate.y" + { yyHaveTime++; yyHaveDate++; @@ -1283,7 +1287,7 @@ yyreduce: break; case 13: -#line 210 "../unix/../generic/tclGetDate.y" + { yyHour = yyvsp[-1].Number; yyMinutes = 0; @@ -1293,7 +1297,7 @@ yyreduce: break; case 14: -#line 216 "../unix/../generic/tclGetDate.y" + { yyHour = yyvsp[-3].Number; yyMinutes = yyvsp[-1].Number; @@ -1303,7 +1307,7 @@ yyreduce: break; case 15: -#line 222 "../unix/../generic/tclGetDate.y" + { yyHour = yyvsp[-4].Number; yyMinutes = yyvsp[-2].Number; @@ -1315,7 +1319,7 @@ yyreduce: break; case 16: -#line 230 "../unix/../generic/tclGetDate.y" + { yyHour = yyvsp[-5].Number; yyMinutes = yyvsp[-3].Number; @@ -1325,7 +1329,7 @@ yyreduce: break; case 17: -#line 236 "../unix/../generic/tclGetDate.y" + { yyHour = yyvsp[-6].Number; yyMinutes = yyvsp[-4].Number; @@ -1338,7 +1342,7 @@ yyreduce: break; case 18: -#line 247 "../unix/../generic/tclGetDate.y" + { yyTimezone = yyvsp[-1].Number; yyDSTmode = DSTon; @@ -1346,7 +1350,7 @@ yyreduce: break; case 19: -#line 251 "../unix/../generic/tclGetDate.y" + { yyTimezone = yyvsp[0].Number; yyDSTmode = DSToff; @@ -1354,7 +1358,7 @@ yyreduce: break; case 20: -#line 255 "../unix/../generic/tclGetDate.y" + { yyTimezone = yyvsp[0].Number; yyDSTmode = DSTon; @@ -1362,7 +1366,7 @@ yyreduce: break; case 21: -#line 261 "../unix/../generic/tclGetDate.y" + { yyDayOrdinal = 1; yyDayNumber = yyvsp[0].Number; @@ -1370,7 +1374,7 @@ yyreduce: break; case 22: -#line 265 "../unix/../generic/tclGetDate.y" + { yyDayOrdinal = 1; yyDayNumber = yyvsp[-1].Number; @@ -1378,7 +1382,7 @@ yyreduce: break; case 23: -#line 269 "../unix/../generic/tclGetDate.y" + { yyDayOrdinal = yyvsp[-1].Number; yyDayNumber = yyvsp[0].Number; @@ -1386,7 +1390,7 @@ yyreduce: break; case 24: -#line 273 "../unix/../generic/tclGetDate.y" + { yyDayOrdinal = yyvsp[-2].Number * yyvsp[-1].Number; yyDayNumber = yyvsp[0].Number; @@ -1394,7 +1398,7 @@ yyreduce: break; case 25: -#line 277 "../unix/../generic/tclGetDate.y" + { yyDayOrdinal = 2; yyDayNumber = yyvsp[0].Number; @@ -1402,7 +1406,7 @@ yyreduce: break; case 26: -#line 283 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[-2].Number; yyDay = yyvsp[0].Number; @@ -1410,7 +1414,7 @@ yyreduce: break; case 27: -#line 287 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[-4].Number; yyDay = yyvsp[-2].Number; @@ -1419,7 +1423,7 @@ yyreduce: break; case 28: -#line 292 "../unix/../generic/tclGetDate.y" + { yyYear = yyvsp[0].Number / 10000; yyMonth = (yyvsp[0].Number % 10000)/100; @@ -1428,7 +1432,7 @@ yyreduce: break; case 29: -#line 297 "../unix/../generic/tclGetDate.y" + { yyDay = yyvsp[-4].Number; yyMonth = yyvsp[-2].Number; @@ -1437,7 +1441,7 @@ yyreduce: break; case 30: -#line 302 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[-2].Number; yyDay = yyvsp[0].Number; @@ -1446,7 +1450,7 @@ yyreduce: break; case 31: -#line 307 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[-1].Number; yyDay = yyvsp[0].Number; @@ -1454,7 +1458,7 @@ yyreduce: break; case 32: -#line 311 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[-3].Number; yyDay = yyvsp[-2].Number; @@ -1463,7 +1467,7 @@ yyreduce: break; case 33: -#line 316 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[0].Number; yyDay = yyvsp[-1].Number; @@ -1471,7 +1475,7 @@ yyreduce: break; case 34: -#line 320 "../unix/../generic/tclGetDate.y" + { yyMonth = 1; yyDay = 1; @@ -1480,7 +1484,7 @@ yyreduce: break; case 35: -#line 325 "../unix/../generic/tclGetDate.y" + { yyMonth = yyvsp[-1].Number; yyDay = yyvsp[-2].Number; @@ -1489,7 +1493,7 @@ yyreduce: break; case 36: -#line 332 "../unix/../generic/tclGetDate.y" + { yyMonthOrdinal = 1; yyMonth = yyvsp[0].Number; @@ -1497,7 +1501,7 @@ yyreduce: break; case 37: -#line 336 "../unix/../generic/tclGetDate.y" + { yyMonthOrdinal = yyvsp[-1].Number; yyMonth = yyvsp[0].Number; @@ -1505,7 +1509,7 @@ yyreduce: break; case 38: -#line 342 "../unix/../generic/tclGetDate.y" + { if (yyvsp[-1].Number != HOUR(- 7)) YYABORT; yyYear = yyvsp[-2].Number / 10000; @@ -1518,7 +1522,7 @@ yyreduce: break; case 39: -#line 351 "../unix/../generic/tclGetDate.y" + { if (yyvsp[-5].Number != HOUR(- 7)) YYABORT; yyYear = yyvsp[-6].Number / 10000; @@ -1531,7 +1535,7 @@ yyreduce: break; case 40: -#line 360 "../unix/../generic/tclGetDate.y" + { yyYear = yyvsp[-1].Number / 10000; yyMonth = (yyvsp[-1].Number % 10000)/100; @@ -1543,7 +1547,7 @@ yyreduce: break; case 41: -#line 370 "../unix/../generic/tclGetDate.y" + { /* * Offset computed year by -377 so that the returned years will @@ -1558,7 +1562,7 @@ yyreduce: break; case 42: -#line 383 "../unix/../generic/tclGetDate.y" + { yyRelSeconds *= -1; yyRelMonth *= -1; @@ -1567,63 +1571,63 @@ yyreduce: break; case 44: -#line 390 "../unix/../generic/tclGetDate.y" + { *yyRelPointer += yyvsp[-2].Number * yyvsp[-1].Number * yyvsp[0].Number; ;} break; case 45: -#line 391 "../unix/../generic/tclGetDate.y" + { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;} break; case 46: -#line 392 "../unix/../generic/tclGetDate.y" + { *yyRelPointer += yyvsp[0].Number; ;} break; case 47: -#line 393 "../unix/../generic/tclGetDate.y" + { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;} break; case 48: -#line 394 "../unix/../generic/tclGetDate.y" + { *yyRelPointer += yyvsp[0].Number; ;} break; case 49: -#line 396 "../unix/../generic/tclGetDate.y" + { yyval.Number = -1; ;} break; case 50: -#line 397 "../unix/../generic/tclGetDate.y" + { yyval.Number = 1; ;} break; case 51: -#line 399 "../unix/../generic/tclGetDate.y" + { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelSeconds; ;} break; case 52: -#line 400 "../unix/../generic/tclGetDate.y" + { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelDay; ;} break; case 53: -#line 401 "../unix/../generic/tclGetDate.y" + { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelMonth; ;} break; case 54: -#line 405 "../unix/../generic/tclGetDate.y" + { if (yyHaveTime && yyHaveDate && !yyHaveRel) { yyYear = yyvsp[0].Number; } else { yyHaveTime++; - if (yyvsp[0].Number < 100) { + if (yyDigitCount <= 2) { yyHour = yyvsp[0].Number; yyMinutes = 0; } else { @@ -1637,14 +1641,14 @@ yyreduce: break; case 55: -#line 423 "../unix/../generic/tclGetDate.y" + { yyval.Meridian = MER24; ;} break; case 56: -#line 426 "../unix/../generic/tclGetDate.y" + { yyval.Meridian = yyvsp[0].Meridian; ;} @@ -1653,8 +1657,8 @@ yyreduce: } -/* Line 991 of yacc.c. */ -#line 1657 "../unix/../generic/tclDate.c" +/* Line 999 of yacc.c. */ + yyvsp -= yylen; yyssp -= yylen; @@ -1695,18 +1699,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) { @@ -1715,16 +1734,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); @@ -1768,30 +1784,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 (;;) @@ -1865,7 +1864,7 @@ yyreturn: } -#line 431 "../unix/../generic/tclGetDate.y" + /* @@ -2239,6 +2238,7 @@ TclDatelex( void* info ) Count++; } yyInput--; + yyDigitCount = Count; /* A number with 6 or more digits is considered an ISO 8601 base */ if (Count >= 6) { return tISOBASE; |