From dc1e5ec547a5635acaa9d6c052c696db6bc87849 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 27 May 2020 13:58:09 +0000 Subject: Proposed soution for [a1bd37b719]: clock (free)scan of ISO 8601 timestamp with literal T behaves strange (I like it!) --- doc/clock.n | 5 +- generic/tclDate.c | 132 +++++++++++++++++++++++++++++---------------------- generic/tclGetDate.y | 12 ++++- tests/clock.test | 12 ++++- 4 files changed, 99 insertions(+), 62 deletions(-) diff --git a/doc/clock.n b/doc/clock.n index f0f6c37..8b9982c 100644 --- a/doc/clock.n +++ b/doc/clock.n @@ -913,9 +913,10 @@ An ISO 8601 point-in-time specification, such as where \fBT\fR is the literal .QW T , .QW "\fICCyymmdd hhmmss\fR" , +.QW \fICCyymmdd\fBT\fIhh:mm:ss\fR , or -.QW \fICCyymmdd\fBT\fIhh:mm:ss\fR . -Note that only these three formats are accepted. +.QW \fICCyy-mm-dd\fBT\fIhh:mm:ss\fR. +Note that only these four formats are accepted. The command does \fInot\fR accept the full range of point-in-time specifications specified in ISO8601. Other formats can be recognized by giving an explicit \fB\-format\fR option to the \fBclock scan\fR command. diff --git a/generic/tclDate.c b/generic/tclDate.c index ea1f0f3..7b32604 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -129,6 +129,7 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. + * */ #include "tclInt.h" @@ -281,7 +282,7 @@ typedef union YYSTYPE time_t Number; enum _MERIDIAN Meridian; } -/* Line 187 of yacc.c. */ +/* Line 193 of yacc.c. */ YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -534,16 +535,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 79 +#define YYLAST 86 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 26 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 16 /* YYNRULES -- Number of rules. */ -#define YYNRULES 56 +#define YYNRULES 57 /* YYNRULES -- Number of states. */ -#define YYNSTATES 83 +#define YYNSTATES 89 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -593,9 +594,9 @@ static const yytype_uint8 yyprhs[] = 0, 0, 3, 4, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 28, 33, 39, 46, 54, 57, 59, 61, 63, 66, 69, 73, 76, 80, 86, 88, - 94, 100, 103, 108, 111, 113, 117, 120, 124, 128, - 136, 139, 144, 147, 149, 153, 156, 159, 163, 165, - 167, 169, 171, 173, 175, 177, 178 + 94, 100, 103, 108, 111, 113, 117, 120, 124, 136, + 140, 148, 151, 156, 159, 161, 165, 168, 171, 175, + 177, 179, 181, 183, 185, 187, 189, 190 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -613,23 +614,25 @@ static const yytype_int8 yyrhs[] = 8, 21, 13, -1, 13, 21, 13, 21, 13, -1, 8, 13, -1, 8, 13, 22, 13, -1, 13, 8, -1, 15, -1, 13, 8, 13, -1, 19, 8, -1, - 19, 13, 8, -1, 17, 14, 17, -1, 17, 14, - 13, 20, 13, 20, 13, -1, 17, 17, -1, 10, - 13, 24, 13, -1, 37, 3, -1, 37, -1, 38, - 13, 39, -1, 13, 39, -1, 19, 39, -1, 19, - 13, 39, -1, 39, -1, 21, -1, 25, -1, 11, - -1, 18, -1, 9, -1, 13, -1, -1, 7, -1 + 19, 13, 8, -1, 13, 21, 13, 21, 13, 14, + 13, 20, 13, 20, 13, -1, 17, 14, 17, -1, + 17, 14, 13, 20, 13, 20, 13, -1, 17, 17, + -1, 10, 13, 24, 13, -1, 37, 3, -1, 37, + -1, 38, 13, 39, -1, 13, 39, -1, 19, 39, + -1, 19, 13, 39, -1, 39, -1, 21, -1, 25, + -1, 11, -1, 18, -1, 9, -1, 13, -1, -1, + 7, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 225, 225, 226, 229, 232, 235, 238, 241, 244, - 247, 251, 256, 259, 265, 271, 279, 285, 296, 300, - 304, 310, 314, 318, 322, 326, 332, 336, 341, 346, - 351, 356, 360, 365, 369, 374, 381, 385, 391, 400, - 409, 419, 433, 438, 441, 444, 447, 450, 453, 458, - 461, 466, 470, 474, 480, 498, 501 + 0, 223, 223, 224, 227, 230, 233, 236, 239, 242, + 245, 249, 254, 257, 263, 269, 277, 283, 294, 298, + 302, 308, 312, 316, 320, 324, 330, 334, 339, 344, + 349, 354, 358, 363, 367, 372, 379, 383, 389, 399, + 408, 417, 427, 441, 446, 449, 452, 455, 458, 461, + 466, 469, 474, 478, 482, 488, 506, 509 }; #endif @@ -666,8 +669,8 @@ static const yytype_uint8 yyr1[] = 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 34, 34, - 34, 35, 36, 36, 37, 37, 37, 37, 37, 38, - 38, 39, 39, 39, 40, 41, 41 + 34, 34, 35, 36, 36, 37, 37, 37, 37, 37, + 38, 38, 39, 39, 39, 40, 41, 41 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -676,9 +679,9 @@ static const yytype_uint8 yyr2[] = 0, 2, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 5, 6, 7, 2, 1, 1, 1, 2, 2, 3, 2, 3, 5, 1, 5, - 5, 2, 4, 2, 1, 3, 2, 3, 3, 7, - 2, 4, 2, 1, 3, 2, 2, 3, 1, 1, - 1, 1, 1, 1, 1, 0, 1 + 5, 2, 4, 2, 1, 3, 2, 3, 11, 3, + 7, 2, 4, 2, 1, 3, 2, 2, 3, 1, + 1, 1, 1, 1, 1, 1, 0, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -686,15 +689,15 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 0, 1, 21, 20, 0, 53, 0, 51, 54, - 19, 34, 28, 52, 0, 49, 50, 3, 4, 5, - 8, 6, 7, 10, 11, 9, 43, 0, 48, 12, - 22, 31, 0, 23, 13, 33, 0, 0, 0, 45, - 18, 0, 40, 25, 36, 0, 46, 42, 0, 0, - 0, 35, 55, 0, 0, 26, 0, 38, 37, 47, - 24, 44, 32, 41, 56, 0, 0, 14, 0, 0, - 0, 0, 55, 15, 29, 30, 27, 0, 0, 16, - 0, 17, 39 + 2, 0, 1, 21, 20, 0, 54, 0, 52, 55, + 19, 34, 28, 53, 0, 50, 51, 3, 4, 5, + 8, 6, 7, 10, 11, 9, 44, 0, 49, 12, + 22, 31, 0, 23, 13, 33, 0, 0, 0, 46, + 18, 0, 41, 25, 36, 0, 47, 43, 0, 0, + 0, 35, 56, 0, 0, 26, 0, 39, 37, 48, + 24, 45, 32, 42, 57, 0, 0, 14, 0, 0, + 0, 0, 56, 15, 29, 30, 27, 0, 0, 16, + 0, 0, 17, 0, 40, 0, 0, 0, 38 }; /* YYDEFGOTO[NTERM-NUM]. */ @@ -716,15 +719,15 @@ static const yytype_int8 yypact[] = -22, 15, -22, -22, -22, 48, -22, -22, 43, 50, 51, -22, 17, 44, 46, 45, 52, -22, -22, -22, -22, -22, -22, -22, -22, 56, 57, -22, 58, 60, - 61, 62, -3, -22, -22, -22, -22, 59, 63, -22, - 64, -22, -22 + 61, 62, -3, -22, -22, 63, -22, 59, 65, -22, + 67, 68, -22, 64, -22, 69, 66, 70, -22 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -9, -22, 6 + -22, -22, -22, -9, -22, 4 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -741,10 +744,11 @@ static const yytype_uint8 yytable[] = 13, 48, 36, 37, 43, 38, 49, 60, 44, 6, 50, 8, 6, 45, 8, 51, 58, 6, 13, 8, 52, 13, 55, 62, 63, 68, 13, 69, 70, 72, - 73, 74, 71, 75, 76, 77, 81, 82, 79, 80 + 73, 74, 71, 75, 76, 77, 79, 80, 82, 81, + 83, 84, 86, 88, 85, 0, 87 }; -static const yytype_uint8 yycheck[] = +static const yytype_int8 yycheck[] = { 9, 22, 0, 8, 7, 14, 4, 5, 13, 13, 8, 9, 10, 11, 13, 13, 14, 15, 21, 17, @@ -753,7 +757,8 @@ static const yytype_uint8 yycheck[] = 18, 13, 20, 21, 4, 23, 22, 4, 8, 9, 24, 11, 9, 13, 11, 13, 8, 9, 18, 11, 13, 18, 13, 13, 13, 21, 18, 21, 23, 13, - 13, 13, 20, 13, 13, 13, 13, 13, 72, 20 + 13, 13, 20, 13, 13, 13, 72, 14, 13, 20, + 13, 13, 13, 13, 20, -1, 20 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -768,7 +773,7 @@ static const yytype_uint8 yystos[] = 24, 13, 13, 8, 13, 13, 13, 17, 8, 39, 4, 39, 13, 13, 7, 20, 21, 41, 21, 21, 23, 20, 13, 13, 13, 13, 13, 13, 21, 41, - 20, 13, 13 + 14, 20, 13, 13, 13, 20, 13, 20, 13 }; #define yyerrok (yyerrstatus = 0) @@ -1894,6 +1899,19 @@ yyreduce: case 38: { + if ((yyvsp[(6) - (11)].Number) != HOUR( 7)) YYABORT; + yyYear = (yyvsp[(1) - (11)].Number); + yyMonth = (yyvsp[(3) - (11)].Number); + yyDay = (yyvsp[(5) - (11)].Number); + yyHour = (yyvsp[(7) - (11)].Number); + yyMinutes = (yyvsp[(9) - (11)].Number); + yySeconds = (yyvsp[(11) - (11)].Number); + ;} + break; + + case 39: + + { if ((yyvsp[(2) - (3)].Number) != HOUR( 7)) YYABORT; yyYear = (yyvsp[(1) - (3)].Number) / 10000; yyMonth = ((yyvsp[(1) - (3)].Number) % 10000)/100; @@ -1904,7 +1922,7 @@ yyreduce: ;} break; - case 39: + case 40: { if ((yyvsp[(2) - (7)].Number) != HOUR( 7)) YYABORT; @@ -1917,7 +1935,7 @@ yyreduce: ;} break; - case 40: + case 41: { yyYear = (yyvsp[(1) - (2)].Number) / 10000; @@ -1929,7 +1947,7 @@ yyreduce: ;} break; - case 41: + case 42: { /* @@ -1945,7 +1963,7 @@ yyreduce: ;} break; - case 42: + case 43: { yyRelSeconds *= -1; @@ -1954,56 +1972,56 @@ yyreduce: ;} break; - case 44: + case 45: { *yyRelPointer += (yyvsp[(1) - (3)].Number) * (yyvsp[(2) - (3)].Number) * (yyvsp[(3) - (3)].Number); ;} break; - case 45: + case 46: { *yyRelPointer += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number); ;} break; - case 46: + case 47: { *yyRelPointer += (yyvsp[(2) - (2)].Number); ;} break; - case 47: + case 48: { *yyRelPointer += (yyvsp[(2) - (3)].Number) * (yyvsp[(3) - (3)].Number); ;} break; - case 48: + case 49: { *yyRelPointer += (yyvsp[(1) - (1)].Number); ;} break; - case 49: + case 50: { (yyval.Number) = -1; ;} break; - case 50: + case 51: { (yyval.Number) = 1; ;} break; - case 51: + case 52: { (yyval.Number) = (yyvsp[(1) - (1)].Number); @@ -2011,7 +2029,7 @@ yyreduce: ;} break; - case 52: + case 53: { (yyval.Number) = (yyvsp[(1) - (1)].Number); @@ -2019,7 +2037,7 @@ yyreduce: ;} break; - case 53: + case 54: { (yyval.Number) = (yyvsp[(1) - (1)].Number); @@ -2027,7 +2045,7 @@ yyreduce: ;} break; - case 54: + case 55: { if (yyHaveTime && yyHaveDate && !yyHaveRel) { @@ -2047,14 +2065,14 @@ yyreduce: ;} break; - case 55: + case 56: { (yyval.Meridian) = MER24; ;} break; - case 56: + case 57: { (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian); diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index ce7c2ce..4ef10d8 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -386,7 +386,17 @@ ordMonth: tNEXT tMONTH { } ; -iso : tISOBASE tZONE tISOBASE { +iso : tUNUMBER '-' tUNUMBER '-' tUNUMBER tZONE + tUNUMBER ':' tUNUMBER ':' tUNUMBER { + if ($6 != HOUR( 7)) YYABORT; + yyYear = $1; + yyMonth = $3; + yyDay = $5; + yyHour = $7; + yyMinutes = $9; + yySeconds = $11; + } + | tISOBASE tZONE tISOBASE { if ($2 != HOUR( 7)) YYABORT; yyYear = $1 / 10000; yyMonth = ($1 % 10000)/100; diff --git a/tests/clock.test b/tests/clock.test index 9c59b03..df0315b 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -35474,7 +35474,7 @@ test clock-33.5 {clock clicks tests, millisecond timing test} { # 60 msecs seems to be the max time slice under Windows 95/98 expr { ($end > $start) && (($end - $start) <= 60) ? - "ok" : + "ok" : "test should have taken 0-60 ms, actually took [expr $end - $start]"} } {ok} test clock-33.5a {clock tests, millisecond timing test} { @@ -35490,7 +35490,7 @@ test clock-33.5a {clock tests, millisecond timing test} { # 60 msecs seems to be the max time slice under Windows 95/98 expr { ($end > $start) && (($end - $start) <= 60) ? - "ok" : + "ok" : "test should have taken 0-60 ms, actually took [expr $end - $start]"} } {ok} test clock-33.6 {clock clicks, milli with too much abbreviation} { @@ -35664,6 +35664,14 @@ test clock-34.18 {clock scan, ISO 8601 point in time format} { set time [clock scan "19921023T000000"] clock format $time -format {%b %d, %Y %H:%M:%S} } "Oct 23, 1992 00:00:00" +test clock-34.19 {clock scan, ISO 8601 point in time format} { + set time [clock scan "19921023T00:00:00"] + clock format $time -format {%b %d, %Y %H:%M:%S} +} "Oct 23, 1992 00:00:00" +test clock-34.20 {clock scan, ISO 8601 point in time format} { + set time [clock scan "1992-10-23T00:00:00"] + clock format $time -format {%b %d, %Y %H:%M:%S} +} "Oct 23, 1992 00:00:00" # CLOCK SCAN REAL TESTS # We use 5am PST, 31-12-1999 as the base for these scans because irrespective -- cgit v0.12 From 2956fdc0e0aee7805920004202230103f98d11a9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 27 May 2020 21:11:36 +0000 Subject: clock-iso-2.patch --- generic/tclDate.c | 68 +++++++++++++++++++++++++++------------------------- generic/tclGetDate.y | 58 ++++++++++++++++++++++---------------------- tests/clock.test | 16 +++++++++++++ 3 files changed, 81 insertions(+), 61 deletions(-) diff --git a/generic/tclDate.c b/generic/tclDate.c index 7b32604..3a7e46e 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -628,11 +628,11 @@ static const yytype_int8 yyrhs[] = static const yytype_uint16 yyrline[] = { 0, 223, 223, 224, 227, 230, 233, 236, 239, 242, - 245, 249, 254, 257, 263, 269, 277, 283, 294, 298, - 302, 308, 312, 316, 320, 324, 330, 334, 339, 344, - 349, 354, 358, 363, 367, 372, 379, 383, 389, 399, - 408, 417, 427, 441, 446, 449, 452, 455, 458, 461, - 466, 469, 474, 478, 482, 488, 506, 509 + 245, 249, 254, 257, 263, 269, 277, 283, 294, 299, + 304, 310, 314, 318, 322, 326, 332, 336, 341, 346, + 351, 356, 360, 365, 369, 374, 381, 385, 391, 401, + 410, 419, 429, 443, 448, 451, 454, 457, 460, 463, + 468, 471, 476, 480, 484, 490, 508, 511 }; #endif @@ -1733,6 +1733,7 @@ yyreduce: { yyTimezone = (yyvsp[(1) - (2)].Number); + if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSTon; ;} break; @@ -1741,6 +1742,7 @@ yyreduce: { yyTimezone = (yyvsp[(1) - (1)].Number); + if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSToff; ;} break; @@ -1899,7 +1901,7 @@ yyreduce: case 38: { - if ((yyvsp[(6) - (11)].Number) != HOUR( 7)) YYABORT; + if ((yyvsp[(6) - (11)].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[(1) - (11)].Number); yyMonth = (yyvsp[(3) - (11)].Number); yyDay = (yyvsp[(5) - (11)].Number); @@ -1912,7 +1914,7 @@ yyreduce: case 39: { - if ((yyvsp[(2) - (3)].Number) != HOUR( 7)) YYABORT; + if ((yyvsp[(2) - (3)].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[(1) - (3)].Number) / 10000; yyMonth = ((yyvsp[(1) - (3)].Number) % 10000)/100; yyDay = (yyvsp[(1) - (3)].Number) % 100; @@ -1925,7 +1927,7 @@ yyreduce: case 40: { - if ((yyvsp[(2) - (7)].Number) != HOUR( 7)) YYABORT; + if ((yyvsp[(2) - (7)].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[(1) - (7)].Number) / 10000; yyMonth = ((yyvsp[(1) - (7)].Number) % 10000)/100; yyDay = (yyvsp[(1) - (7)].Number) % 100; @@ -2476,31 +2478,31 @@ static const TABLE TimezoneTable[] = { */ static const TABLE MilitaryTable[] = { - { "a", tZONE, -HOUR( 1) }, - { "b", tZONE, -HOUR( 2) }, - { "c", tZONE, -HOUR( 3) }, - { "d", tZONE, -HOUR( 4) }, - { "e", tZONE, -HOUR( 5) }, - { "f", tZONE, -HOUR( 6) }, - { "g", tZONE, -HOUR( 7) }, - { "h", tZONE, -HOUR( 8) }, - { "i", tZONE, -HOUR( 9) }, - { "k", tZONE, -HOUR(10) }, - { "l", tZONE, -HOUR(11) }, - { "m", tZONE, -HOUR(12) }, - { "n", tZONE, HOUR( 1) }, - { "o", tZONE, HOUR( 2) }, - { "p", tZONE, HOUR( 3) }, - { "q", tZONE, HOUR( 4) }, - { "r", tZONE, HOUR( 5) }, - { "s", tZONE, HOUR( 6) }, - { "t", tZONE, HOUR( 7) }, - { "u", tZONE, HOUR( 8) }, - { "v", tZONE, HOUR( 9) }, - { "w", tZONE, HOUR( 10) }, - { "x", tZONE, HOUR( 11) }, - { "y", tZONE, HOUR( 12) }, - { "z", tZONE, HOUR( 0) }, + { "a", tZONE, -HOUR( 1) + HOUR(100) }, + { "b", tZONE, -HOUR( 2) + HOUR(100) }, + { "c", tZONE, -HOUR( 3) + HOUR(100) }, + { "d", tZONE, -HOUR( 4) + HOUR(100) }, + { "e", tZONE, -HOUR( 5) + HOUR(100) }, + { "f", tZONE, -HOUR( 6) + HOUR(100) }, + { "g", tZONE, -HOUR( 7) + HOUR(100) }, + { "h", tZONE, -HOUR( 8) + HOUR(100) }, + { "i", tZONE, -HOUR( 9) + HOUR(100) }, + { "k", tZONE, -HOUR(10) + HOUR(100) }, + { "l", tZONE, -HOUR(11) + HOUR(100) }, + { "m", tZONE, -HOUR(12) + HOUR(100) }, + { "n", tZONE, HOUR( 1) + HOUR(100) }, + { "o", tZONE, HOUR( 2) + HOUR(100) }, + { "p", tZONE, HOUR( 3) + HOUR(100) }, + { "q", tZONE, HOUR( 4) + HOUR(100) }, + { "r", tZONE, HOUR( 5) + HOUR(100) }, + { "s", tZONE, HOUR( 6) + HOUR(100) }, + { "t", tZONE, HOUR( 7) + HOUR(100) }, + { "u", tZONE, HOUR( 8) + HOUR(100) }, + { "v", tZONE, HOUR( 9) + HOUR(100) }, + { "w", tZONE, HOUR( 10) + HOUR(100) }, + { "x", tZONE, HOUR( 11) + HOUR(100) }, + { "y", tZONE, HOUR( 12) + HOUR(100) }, + { "z", tZONE, HOUR( 0) + HOUR(100) }, { NULL, 0, 0 } }; diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 4ef10d8..2bf211b 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -293,10 +293,12 @@ time : tUNUMBER tMERIDIAN { zone : tZONE tDST { yyTimezone = $1; + if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSTon; } | tZONE { yyTimezone = $1; + if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSToff; } | tDAYZONE { @@ -388,7 +390,7 @@ ordMonth: tNEXT tMONTH { iso : tUNUMBER '-' tUNUMBER '-' tUNUMBER tZONE tUNUMBER ':' tUNUMBER ':' tUNUMBER { - if ($6 != HOUR( 7)) YYABORT; + if ($6 != HOUR( 7) + HOUR(100)) YYABORT; yyYear = $1; yyMonth = $3; yyDay = $5; @@ -397,7 +399,7 @@ iso : tUNUMBER '-' tUNUMBER '-' tUNUMBER tZONE yySeconds = $11; } | tISOBASE tZONE tISOBASE { - if ($2 != HOUR( 7)) YYABORT; + if ($2 != HOUR( 7) + HOUR(100)) YYABORT; yyYear = $1 / 10000; yyMonth = ($1 % 10000)/100; yyDay = $1 % 100; @@ -406,7 +408,7 @@ iso : tUNUMBER '-' tUNUMBER '-' tUNUMBER tZONE yySeconds = $3 % 100; } | tISOBASE tZONE tUNUMBER ':' tUNUMBER ':' tUNUMBER { - if ($2 != HOUR( 7)) YYABORT; + if ($2 != HOUR( 7) + HOUR(100)) YYABORT; yyYear = $1 / 10000; yyMonth = ($1 % 10000)/100; yyDay = $1 % 100; @@ -685,31 +687,31 @@ static const TABLE TimezoneTable[] = { */ static const TABLE MilitaryTable[] = { - { "a", tZONE, -HOUR( 1) }, - { "b", tZONE, -HOUR( 2) }, - { "c", tZONE, -HOUR( 3) }, - { "d", tZONE, -HOUR( 4) }, - { "e", tZONE, -HOUR( 5) }, - { "f", tZONE, -HOUR( 6) }, - { "g", tZONE, -HOUR( 7) }, - { "h", tZONE, -HOUR( 8) }, - { "i", tZONE, -HOUR( 9) }, - { "k", tZONE, -HOUR(10) }, - { "l", tZONE, -HOUR(11) }, - { "m", tZONE, -HOUR(12) }, - { "n", tZONE, HOUR( 1) }, - { "o", tZONE, HOUR( 2) }, - { "p", tZONE, HOUR( 3) }, - { "q", tZONE, HOUR( 4) }, - { "r", tZONE, HOUR( 5) }, - { "s", tZONE, HOUR( 6) }, - { "t", tZONE, HOUR( 7) }, - { "u", tZONE, HOUR( 8) }, - { "v", tZONE, HOUR( 9) }, - { "w", tZONE, HOUR( 10) }, - { "x", tZONE, HOUR( 11) }, - { "y", tZONE, HOUR( 12) }, - { "z", tZONE, HOUR( 0) }, + { "a", tZONE, -HOUR( 1) + HOUR(100) }, + { "b", tZONE, -HOUR( 2) + HOUR(100) }, + { "c", tZONE, -HOUR( 3) + HOUR(100) }, + { "d", tZONE, -HOUR( 4) + HOUR(100) }, + { "e", tZONE, -HOUR( 5) + HOUR(100) }, + { "f", tZONE, -HOUR( 6) + HOUR(100) }, + { "g", tZONE, -HOUR( 7) + HOUR(100) }, + { "h", tZONE, -HOUR( 8) + HOUR(100) }, + { "i", tZONE, -HOUR( 9) + HOUR(100) }, + { "k", tZONE, -HOUR(10) + HOUR(100) }, + { "l", tZONE, -HOUR(11) + HOUR(100) }, + { "m", tZONE, -HOUR(12) + HOUR(100) }, + { "n", tZONE, HOUR( 1) + HOUR(100) }, + { "o", tZONE, HOUR( 2) + HOUR(100) }, + { "p", tZONE, HOUR( 3) + HOUR(100) }, + { "q", tZONE, HOUR( 4) + HOUR(100) }, + { "r", tZONE, HOUR( 5) + HOUR(100) }, + { "s", tZONE, HOUR( 6) + HOUR(100) }, + { "t", tZONE, HOUR( 7) + HOUR(100) }, + { "u", tZONE, HOUR( 8) + HOUR(100) }, + { "v", tZONE, HOUR( 9) + HOUR(100) }, + { "w", tZONE, HOUR( 10) + HOUR(100) }, + { "x", tZONE, HOUR( 11) + HOUR(100) }, + { "y", tZONE, HOUR( 12) + HOUR(100) }, + { "z", tZONE, HOUR( 0) + HOUR(100) }, { NULL, 0, 0 } }; diff --git a/tests/clock.test b/tests/clock.test index df0315b..f7da08f 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -35672,6 +35672,22 @@ test clock-34.20 {clock scan, ISO 8601 point in time format} { set time [clock scan "1992-10-23T00:00:00"] clock format $time -format {%b %d, %Y %H:%M:%S} } "Oct 23, 1992 00:00:00" +test clock-34.21 {clock scan, ISO 8601 invalid TZ} -body { + set time [clock scan "19921023MST000000"] + clock format $time -format {%b %d, %Y %H:%M:%S} +} -returnCodes error -match glob -result {unable to convert date-time string*} +test clock-34.22 {clock scan, ISO 8601 invalid TZ} -body { + set time [clock scan "19921023M000000"] + clock format $time -format {%b %d, %Y %H:%M:%S} +} -returnCodes error -match glob -result {unable to convert date-time string*} +test clock-34.23 {clock scan, ISO 8601 invalid TZ} -body { + set time [clock scan "1992-10-23M00:00:00"] + clock format $time -format {%b %d, %Y %H:%M:%S} +} -returnCodes error -match glob -result {unable to convert date-time string*} +test clock-34.24 {clock scan, ISO 8601 invalid TZ} -body { + set time [clock scan "1992-10-23MST00:00:00"] + clock format $time -format {%b %d, %Y %H:%M:%S} +} -returnCodes error -match glob -result {unable to convert date-time string*} # CLOCK SCAN REAL TESTS # We use 5am PST, 31-12-1999 as the base for these scans because irrespective -- cgit v0.12 From 75376fc361851e388acdc9c4a64c1987446b808f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 23 Jun 2020 07:13:15 +0000 Subject: re-generate with bison 3.1 --- generic/tclDate.c | 315 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 206 insertions(+), 109 deletions(-) diff --git a/generic/tclDate.c b/generic/tclDate.c index daeb1d9..dcb85e9 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.4.2. */ +/* A Bison parser, made by GNU Bison 3.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, - Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 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 @@ -41,14 +40,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.4.2" +#define YYBISON_VERSION "3.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -71,7 +67,8 @@ #define yynerrs TclDatenerrs -/* First part of user prologue. */ +/* Copy the first part of user declarations. */ + /* * tclDate.c -- @@ -212,15 +209,12 @@ typedef enum _DSTMODE { + # ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr # else -# define YY_NULLPTR ((void*)0) +# define YY_NULLPTR 0 # endif # endif @@ -268,14 +262,17 @@ extern int TclDatedebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + union YYSTYPE { + time_t Number; enum _MERIDIAN Meridian; }; + typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -301,7 +298,8 @@ int TclDateparse (DateInfo* info); -/* Second part of user prologue. */ +/* Copy the second part of user declarations. */ + /* @@ -393,6 +391,15 @@ typedef short yytype_int16; # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -420,8 +427,6 @@ typedef short yytype_int16; #endif -#define YY_ASSERT(E) ((void) (0 && (E))) - #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -566,16 +571,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 89 +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 274 -/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex. */ + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -781,22 +786,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, info, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (0) +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, info, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) /* Error token number */ #define YYTERROR 1 @@ -855,10 +860,10 @@ do { \ /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ YY_ATTRIBUTE_UNUSED -static int +static unsigned yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { - int res = 0; + unsigned res = 0; int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; if (0 <= yylocp->first_line) { @@ -901,43 +906,41 @@ do { \ } while (0) -/*-----------------------------------. -| Print this symbol's value on YYO. | -`-----------------------------------*/ +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) { - FILE *yyoutput = yyo; - YYUSE (yyoutput); + FILE *yyo = yyoutput; + YYUSE (yyo); YYUSE (yylocationp); YYUSE (info); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*---------------------------. -| Print this symbol on YYO. | -`---------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ static void -yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) { - YYFPRINTF (yyo, "%s %s (", + YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - YY_LOCATION_PRINT (yyo, *yylocationp); - YYFPRINTF (yyo, ": "); - yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp, info); - YYFPRINTF (yyo, ")"); + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, info); + YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. @@ -982,7 +985,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &yyvsp[(yyi + 1) - (yynrhs)] + &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , info); YYFPRINTF (stderr, "\n"); } @@ -1086,10 +1089,7 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - else - goto append; - - append: + /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; @@ -1107,7 +1107,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); + return yystpcpy (yyres, yystr) - yyres; } # endif @@ -1185,10 +1185,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } } } @@ -1212,10 +1212,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1367,33 +1366,23 @@ YYLTYPE yylloc = yyloc_default; yylsp[0] = yylloc; goto yysetstate; - /*------------------------------------------------------------. -| yynewstate -- push a new state, which is found in yystate. | +| yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ -yynewstate: + yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - -/*--------------------------------------------------------------------. -| yynewstate -- set current state (the top of the stack) to yystate. | -`--------------------------------------------------------------------*/ -yysetstate: - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - YY_ASSERT (0 <= yystate && yystate < YYNSTATES); - *yyssp = (yytype_int16) yystate; + yysetstate: + *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) -#if !defined yyoverflow && !defined YYSTACK_RELOCATE - goto yyexhaustedlab; -#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); + YYSIZE_T yysize = yyssp - yyss + 1; -# if defined yyoverflow +#ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1411,11 +1400,15 @@ yysetstate: &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; - yyls = yyls1; } -# else /* defined YYSTACK_RELOCATE */ +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1432,11 +1425,12 @@ yysetstate: YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif +#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; @@ -1448,18 +1442,19 @@ yysetstate: if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: + /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1532,7 +1527,7 @@ yydefault: /*-----------------------------. -| yyreduce -- do a reduction. | +| yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1554,76 +1549,97 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: + case 4: + { yyHaveTime++; } + break; case 5: + { yyHaveZone++; } + break; case 6: + { yyHaveDate++; } + break; case 7: + { yyHaveOrdinalMonth++; } + break; case 8: + { yyHaveDay++; } + break; case 9: + { yyHaveRel++; } + break; case 10: + { yyHaveTime++; yyHaveDate++; } + break; case 11: + { yyHaveTime++; yyHaveDate++; yyHaveRel++; } + break; case 13: + { yyHour = (yyvsp[-1].Number); yyMinutes = 0; yySeconds = 0; yyMeridian = (yyvsp[0].Meridian); } + break; case 14: + { yyHour = (yyvsp[-3].Number); yyMinutes = (yyvsp[-1].Number); yySeconds = 0; yyMeridian = (yyvsp[0].Meridian); } + break; case 15: + { yyHour = (yyvsp[-4].Number); yyMinutes = (yyvsp[-2].Number); @@ -1632,18 +1648,22 @@ yyreduce: yyTimezone = ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60); ++yyHaveZone; } + break; case 16: + { yyHour = (yyvsp[-5].Number); yyMinutes = (yyvsp[-3].Number); yySeconds = (yyvsp[-1].Number); yyMeridian = (yyvsp[0].Meridian); } + break; case 17: + { yyHour = (yyvsp[-6].Number); yyMinutes = (yyvsp[-4].Number); @@ -1653,158 +1673,200 @@ yyreduce: yyTimezone = ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60); ++yyHaveZone; } + break; case 18: + { yyTimezone = (yyvsp[-1].Number); if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSTon; } + break; case 19: + { yyTimezone = (yyvsp[0].Number); if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSToff; } + break; case 20: + { yyTimezone = (yyvsp[0].Number); yyDSTmode = DSTon; } + break; case 21: + { yyDayOrdinal = 1; yyDayNumber = (yyvsp[0].Number); } + break; case 22: + { yyDayOrdinal = 1; yyDayNumber = (yyvsp[-1].Number); } + break; case 23: + { yyDayOrdinal = (yyvsp[-1].Number); yyDayNumber = (yyvsp[0].Number); } + break; case 24: + { yyDayOrdinal = (yyvsp[-2].Number) * (yyvsp[-1].Number); yyDayNumber = (yyvsp[0].Number); } + break; case 25: + { yyDayOrdinal = 2; yyDayNumber = (yyvsp[0].Number); } + break; case 26: + { yyMonth = (yyvsp[-2].Number); yyDay = (yyvsp[0].Number); } + break; case 27: + { yyMonth = (yyvsp[-4].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 28: + { yyYear = (yyvsp[0].Number) / 10000; yyMonth = ((yyvsp[0].Number) % 10000)/100; yyDay = (yyvsp[0].Number) % 100; } + break; case 29: + { yyDay = (yyvsp[-4].Number); yyMonth = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 30: + { yyMonth = (yyvsp[-2].Number); yyDay = (yyvsp[0].Number); yyYear = (yyvsp[-4].Number); } + break; case 31: + { yyMonth = (yyvsp[-1].Number); yyDay = (yyvsp[0].Number); } + break; case 32: + { yyMonth = (yyvsp[-3].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 33: + { yyMonth = (yyvsp[0].Number); yyDay = (yyvsp[-1].Number); } + break; case 34: + { yyMonth = 1; yyDay = 1; yyYear = EPOCH; } + break; case 35: + { yyMonth = (yyvsp[-1].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 36: + { yyMonthOrdinal = 1; yyMonth = (yyvsp[0].Number); } + break; case 37: + { yyMonthOrdinal = (yyvsp[-1].Number); yyMonth = (yyvsp[0].Number); } + break; case 38: + { if ((yyvsp[-5].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[-10].Number); @@ -1814,9 +1876,11 @@ yyreduce: yyMinutes = (yyvsp[-2].Number); yySeconds = (yyvsp[0].Number); } + break; case 39: + { if ((yyvsp[-1].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[-2].Number) / 10000; @@ -1826,9 +1890,11 @@ yyreduce: yyMinutes = ((yyvsp[0].Number) % 10000)/100; yySeconds = (yyvsp[0].Number) % 100; } + break; case 40: + { if ((yyvsp[-5].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[-6].Number) / 10000; @@ -1838,9 +1904,11 @@ yyreduce: yyMinutes = (yyvsp[-2].Number); yySeconds = (yyvsp[0].Number); } + break; case 41: + { yyYear = (yyvsp[-1].Number) / 10000; yyMonth = ((yyvsp[-1].Number) % 10000)/100; @@ -1849,9 +1917,11 @@ yyreduce: yyMinutes = ((yyvsp[0].Number) % 10000)/100; yySeconds = (yyvsp[0].Number) % 100; } + break; case 42: + { /* * Offset computed year by -377 so that the returned years will be @@ -1864,80 +1934,104 @@ yyreduce: yyRelDay += (((yyvsp[-2].Number)%1000)*(365 + IsLeapYear(yyYear)))/1000; yyRelSeconds += (yyvsp[0].Number) * 144 * 60; } + break; case 43: + { yyRelSeconds *= -1; yyRelMonth *= -1; yyRelDay *= -1; } + break; case 45: + { *yyRelPointer += (yyvsp[-2].Number) * (yyvsp[-1].Number) * (yyvsp[0].Number); } + break; case 46: + { *yyRelPointer += (yyvsp[-1].Number) * (yyvsp[0].Number); } + break; case 47: + { *yyRelPointer += (yyvsp[0].Number); } + break; case 48: + { *yyRelPointer += (yyvsp[-1].Number) * (yyvsp[0].Number); } + break; case 49: + { *yyRelPointer += (yyvsp[0].Number); } + break; case 50: + { (yyval.Number) = -1; } + break; case 51: + { (yyval.Number) = 1; } + break; case 52: + { (yyval.Number) = (yyvsp[0].Number); yyRelPointer = &yyRelSeconds; } + break; case 53: + { (yyval.Number) = (yyvsp[0].Number); yyRelPointer = &yyRelDay; } + break; case 54: + { (yyval.Number) = (yyvsp[0].Number); yyRelPointer = &yyRelMonth; } + break; case 55: + { if (yyHaveTime && yyHaveDate && !yyHaveRel) { yyYear = (yyvsp[0].Number); @@ -1954,18 +2048,23 @@ yyreduce: yyMeridian = MER24; } } + break; case 56: + { (yyval.Meridian) = MER24; } + break; case 57: + { (yyval.Meridian) = (yyvsp[0].Meridian); } + break; @@ -1995,13 +2094,14 @@ yyreduce: /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - { - const int yylhs = yyr1[yyn] - YYNTOKENS; - const int yyi = yypgoto[yylhs] + *yyssp; - yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp - ? yytable[yyi] - : yydefgoto[yylhs]); - } + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -2084,10 +2184,12 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and the - label yyerrorlab therefore never appears in user code. */ - if (0) - YYERROR; + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2154,7 +2256,6 @@ yyacceptlab: yyresult = 0; goto yyreturn; - /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2162,7 +2263,6 @@ yyabortlab: yyresult = 1; goto yyreturn; - #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -2173,10 +2273,6 @@ yyexhaustedlab: /* Fall through. */ #endif - -/*-----------------------------------------------------. -| yyreturn -- parsing is finished, return the result. | -`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2207,6 +2303,7 @@ yyreturn: return yyresult; } + /* * Month and day table. */ -- cgit v0.12