2 /* A Bison parser, made by GNU Bison 2.4.1. */
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
38 /* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
45 /* Identify Bison output. */
49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
63 /* Using locations. */
64 #define YYLSP_NEEDED 0
68 /* Copy the first part of user declarations. */
70 /* Line 189 of yacc.c */
71 #line 1 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
73 /* Parse a string into an internal time stamp.
75 Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Free Software
78 This program is free software; you can redistribute it and/or modify
79 it under the terms of the GNU General Public License as published by
80 the Free Software Foundation; either version 2, or (at your option)
83 This program is distributed in the hope that it will be useful,
84 but WITHOUT ANY WARRANTY; without even the implied warranty of
85 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86 GNU General Public License for more details.
88 You should have received a copy of the GNU General Public License
89 along with this program; if not, write to the Free Software Foundation,
90 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
92 /* Originally written by Steven M. Bellovin <smb@research.att.com> while
93 at the University of North Carolina at Chapel Hill. Later tweaked by
94 a couple of people on Usenet. Completely overhauled by Rich $alz
95 <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
97 Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do
98 the right thing about local DST. Also modified by Paul Eggert
99 <eggert@cs.ucla.edu> in February 2004 to support
100 nanosecond-resolution time stamps, and in October 2004 to support
101 TZ strings in dates. */
103 /* FIXME: Check for arithmetic overflow in all cases, not just
112 /* There's no need to extend the stack, so there's no need to involve
114 #define YYSTACK_USE_ALLOCA 0
116 /* Tell Bison how much stack space is needed. 20 should be plenty for
117 this grammar, which is not right recursive. Beware setting it too
118 high, since that might cause problems on machines whose
119 implementations have lame stack-overflow checking. */
120 #define YYMAXDEPTH 20
121 #define YYINITDEPTH YYMAXDEPTH
123 /* Since the code of getdate.y is not included in the Emacs executable
124 itself, there is no need to #define static in this file. Even if
125 the code were included in the Emacs executable, it probably
126 wouldn't do any harm to #undef it here; this will only cause
127 problems if we try to write to a static variable, which I don't
128 think this code needs to do. */
142 #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
143 # define IN_CTYPE_DOMAIN(c) 1
145 # define IN_CTYPE_DOMAIN(c) isascii (c)
148 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
149 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
150 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
152 /* ISDIGIT differs from isdigit, as follows:
153 - Its arg may be any int or unsigned int; it need not be an unsigned char.
154 - It's guaranteed to evaluate its argument exactly once.
155 - It's typically faster.
156 POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
157 isdigit unless it's important to use the locale's definition
158 of `digit' even when the host does not conform to POSIX. */
159 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
161 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
162 # define __attribute__(x)
165 #ifndef ATTRIBUTE_UNUSED
166 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
169 /* Shift A right by B bits portably, by dividing A by 2**B and
170 truncating towards minus infinity. A and B should be free of side
171 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
172 INT_BITS is the number of useful bits in an int. GNU code can
173 assume that INT_BITS is at least 32.
175 ISO C99 says that A >> B is implementation-defined if A < 0. Some
176 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
177 right in the usual way when A < 0, so SHR falls back on division if
178 ordinary A >> B doesn't seem to be the usual signed shift. */
182 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
184 #define EPOCH_YEAR 1970
185 #define TM_YEAR_BASE 1900
187 #define HOUR(x) ((x) * 60)
189 /* An integer value, and the number of digits in its textual
198 /* An entry in the lexical lookup table. */
206 /* Meridian: am, pm, or 24-hour style. */
207 enum { MERam
, MERpm
, MER24
};
209 enum { BILLION
= 1000000000, LOG10_BILLION
= 9 };
211 /* Information passed to and from the parser. */
214 /* The input string remaining to be parsed. */
217 /* N, if this is the Nth Tuesday. */
218 long int day_ordinal
;
220 /* Day of week; Sunday is 0. */
223 /* tm_isdst flag for the local zone. */
226 /* Time zone, in minutes east of UTC. */
229 /* Style used for time. */
232 /* Gregorian year, month, day, hour, minutes, seconds, and nanoseconds. */
238 struct timespec seconds
; /* includes nanoseconds */
240 /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */
245 long int rel_minutes
;
246 long int rel_seconds
;
249 /* Presence or counts of nonterminals of various flavors parsed so far. */
254 size_t local_zones_seen
;
259 /* Table of local time zone abbrevations, terminated by a null entry. */
260 table local_time_zone_table
[3];
264 static int yylex (union YYSTYPE
*, parser_control
*);
265 static int yyerror (parser_control
*, char *);
266 static long int time_zone_hhmm (textint
, long int);
270 /* Line 189 of yacc.c */
271 #line 272 "getdate.c"
273 /* Enabling traces. */
278 /* Enabling verbose error messages. */
279 #ifdef YYERROR_VERBOSE
280 # undef YYERROR_VERBOSE
281 # define YYERROR_VERBOSE 1
283 # define YYERROR_VERBOSE 0
286 /* Enabling the token table. */
287 #ifndef YYTOKEN_TABLE
288 # define YYTOKEN_TABLE 0
295 /* Put the tokens into the symbol table, so that GDB and other debuggers
315 tSDECIMAL_NUMBER
= 275,
316 tUDECIMAL_NUMBER
= 276
322 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
323 typedef union YYSTYPE
326 /* Line 214 of yacc.c */
327 #line 209 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
331 struct timespec timespec
;
335 /* Line 214 of yacc.c */
336 #line 337 "getdate.c"
338 # define YYSTYPE_IS_TRIVIAL 1
339 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
340 # define YYSTYPE_IS_DECLARED 1
344 /* Copy the second part of user declarations. */
347 /* Line 264 of yacc.c */
348 #line 349 "getdate.c"
355 typedef YYTYPE_UINT8 yytype_uint8
;
357 typedef unsigned char yytype_uint8
;
361 typedef YYTYPE_INT8 yytype_int8
;
362 #elif (defined __STDC__ || defined __C99__FUNC__ \
363 || defined __cplusplus || defined _MSC_VER)
364 typedef signed char yytype_int8
;
366 typedef short int yytype_int8
;
370 typedef YYTYPE_UINT16 yytype_uint16
;
372 typedef unsigned short int yytype_uint16
;
376 typedef YYTYPE_INT16 yytype_int16
;
378 typedef short int yytype_int16
;
382 # ifdef __SIZE_TYPE__
383 # define YYSIZE_T __SIZE_TYPE__
384 # elif defined size_t
385 # define YYSIZE_T size_t
386 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
387 || defined __cplusplus || defined _MSC_VER)
388 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
389 # define YYSIZE_T size_t
391 # define YYSIZE_T unsigned int
395 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
400 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
401 # define YY_(msgid) dgettext ("bison-runtime", msgid)
405 # define YY_(msgid) msgid
409 /* Suppress unused-variable warnings by "using" E. */
410 #if ! defined lint || defined __GNUC__
411 # define YYUSE(e) ((void) (e))
413 # define YYUSE(e) /* empty */
416 /* Identity function, used to suppress warnings about constant conditions. */
420 #if (defined __STDC__ || defined __C99__FUNC__ \
421 || defined __cplusplus || defined _MSC_VER)
434 #if ! defined yyoverflow || YYERROR_VERBOSE
436 /* The parser invokes alloca or malloc; define the necessary symbols. */
438 # ifdef YYSTACK_USE_ALLOCA
439 # if YYSTACK_USE_ALLOCA
441 # define YYSTACK_ALLOC __builtin_alloca
442 # elif defined __BUILTIN_VA_ARG_INCR
443 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
445 # define YYSTACK_ALLOC __alloca
446 # elif defined _MSC_VER
447 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
448 # define alloca _alloca
450 # define YYSTACK_ALLOC alloca
451 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
452 || defined __cplusplus || defined _MSC_VER)
453 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
462 # ifdef YYSTACK_ALLOC
463 /* Pacify GCC's `empty if-body' warning. */
464 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
465 # ifndef YYSTACK_ALLOC_MAXIMUM
466 /* The OS might guarantee only one guard page at the bottom of the stack,
467 and a page size can be as small as 4096 bytes. So we cannot safely
468 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
469 to allow for a few compiler-allocated temporary stack slots. */
470 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
473 # define YYSTACK_ALLOC YYMALLOC
474 # define YYSTACK_FREE YYFREE
475 # ifndef YYSTACK_ALLOC_MAXIMUM
476 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
478 # if (defined __cplusplus && ! defined _STDLIB_H \
479 && ! ((defined YYMALLOC || defined malloc) \
480 && (defined YYFREE || defined free)))
481 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
487 # define YYMALLOC malloc
488 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
489 || defined __cplusplus || defined _MSC_VER)
490 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
495 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
496 || defined __cplusplus || defined _MSC_VER)
497 void free (void *); /* INFRINGES ON USER NAME SPACE */
501 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
504 #if (! defined yyoverflow \
505 && (! defined __cplusplus \
506 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
508 /* A type that is properly aligned for any stack member. */
511 yytype_int16 yyss_alloc
;
515 /* The size of the maximum gap between one aligned stack and the next. */
516 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
518 /* The size of an array large to enough to hold all stacks, each with
520 # define YYSTACK_BYTES(N) \
521 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
522 + YYSTACK_GAP_MAXIMUM)
524 /* Copy COUNT objects from FROM to TO. The source and destination do
527 # if defined __GNUC__ && 1 < __GNUC__
528 # define YYCOPY(To, From, Count) \
529 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
531 # define YYCOPY(To, From, Count) \
535 for (yyi = 0; yyi < (Count); yyi++) \
536 (To)[yyi] = (From)[yyi]; \
542 /* Relocate STACK from its old location to the new one. The
543 local variables YYSIZE and YYSTACKSIZE give the old and new number of
544 elements in the stack, and YYPTR gives the new location of the
545 stack. Advance YYPTR to a properly aligned location for the next
547 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
550 YYSIZE_T yynewbytes; \
551 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
552 Stack = &yyptr->Stack_alloc; \
553 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
554 yyptr += yynewbytes / sizeof (*yyptr); \
560 /* YYFINAL -- State number of the termination state. */
562 /* YYLAST -- Last index in YYTABLE. */
565 /* YYNTOKENS -- Number of terminals. */
567 /* YYNNTS -- Number of nonterminals. */
569 /* YYNRULES -- Number of rules. */
571 /* YYNRULES -- Number of states. */
572 #define YYNSTATES 101
574 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
576 #define YYMAXUTOK 276
578 #define YYTRANSLATE(YYX) \
579 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
581 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
582 static const yytype_uint8 yytranslate
[] =
584 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
587 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
588 2, 2, 2, 2, 25, 2, 23, 26, 2, 2,
589 2, 2, 2, 2, 2, 2, 2, 2, 24, 2,
590 2, 2, 2, 2, 22, 2, 2, 2, 2, 2,
591 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
592 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
593 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
594 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
595 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
597 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
599 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
602 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
609 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
610 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
611 15, 16, 17, 18, 19, 20, 21
615 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
617 static const yytype_uint8 yyprhs
[] =
619 0, 0, 3, 5, 7, 10, 11, 14, 16, 18,
620 20, 22, 24, 26, 28, 30, 36, 39, 44, 50,
621 57, 65, 67, 70, 72, 75, 79, 81, 84, 86,
622 89, 92, 95, 99, 105, 109, 113, 117, 120, 125,
623 128, 132, 135, 137, 140, 143, 145, 148, 151, 153,
624 156, 159, 161, 164, 167, 169, 172, 175, 177, 180,
625 183, 186, 189, 191, 193, 196, 199, 202, 205, 208,
626 211, 213, 215, 217, 219, 221, 223, 225, 226, 229,
630 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
631 static const yytype_int8 yyrhs
[] =
633 28, 0, -1, 29, -1, 30, -1, 22, 41, -1,
634 -1, 30, 31, -1, 33, -1, 34, -1, 35, -1,
635 37, -1, 36, -1, 38, -1, 32, -1, 44, -1,
636 21, 23, 21, 23, 21, -1, 19, 10, -1, 19,
637 24, 19, 46, -1, 19, 24, 19, 18, 45, -1,
638 19, 24, 19, 24, 43, 46, -1, 19, 24, 19,
639 24, 43, 18, 45, -1, 9, -1, 9, 4, -1,
640 17, -1, 17, 40, -1, 17, 18, 45, -1, 7,
641 -1, 17, 4, -1, 5, -1, 5, 25, -1, 14,
642 5, -1, 19, 5, -1, 19, 26, 19, -1, 19,
643 26, 19, 26, 19, -1, 19, 18, 18, -1, 19,
644 12, 18, -1, 12, 18, 18, -1, 12, 19, -1,
645 12, 19, 25, 19, -1, 19, 12, -1, 19, 12,
646 19, -1, 39, 3, -1, 39, -1, 14, 16, -1,
647 19, 16, -1, 16, -1, 14, 13, -1, 19, 13,
648 -1, 13, -1, 14, 6, -1, 19, 6, -1, 6,
649 -1, 14, 8, -1, 19, 8, -1, 8, -1, 14,
650 11, -1, 19, 11, -1, 11, -1, 14, 15, -1,
651 19, 15, -1, 20, 15, -1, 21, 15, -1, 15,
652 -1, 40, -1, 18, 16, -1, 18, 13, -1, 18,
653 6, -1, 18, 8, -1, 18, 11, -1, 18, 15,
654 -1, 42, -1, 43, -1, 20, -1, 18, -1, 21,
655 -1, 19, -1, 19, -1, -1, 24, 19, -1, -1,
659 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
660 static const yytype_uint16 yyrline
[] =
662 0, 230, 230, 231, 235, 242, 244, 248, 250, 252,
663 254, 256, 258, 260, 266, 269, 296, 304, 312, 322,
664 329, 341, 346, 354, 356, 358, 360, 362, 367, 372,
665 377, 382, 390, 395, 415, 422, 430, 438, 443, 449,
666 454, 463, 473, 477, 479, 481, 483, 485, 487, 489,
667 491, 493, 495, 497, 499, 501, 503, 505, 507, 509,
668 511, 513, 515, 517, 521, 523, 525, 527, 529, 531,
669 535, 535, 538, 539, 544, 545, 550, 588, 589, 595,
674 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
675 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
676 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
677 static const char *const yytname
[] =
679 "$end", "error", "$undefined", "tAGO", "tDST", "tDAY", "tDAY_UNIT",
680 "tDAYZONE", "tHOUR_UNIT", "tLOCAL_ZONE", "tMERIDIAN", "tMINUTE_UNIT",
681 "tMONTH", "tMONTH_UNIT", "tORDINAL", "tSEC_UNIT", "tYEAR_UNIT", "tZONE",
682 "tSNUMBER", "tUNUMBER", "tSDECIMAL_NUMBER", "tUDECIMAL_NUMBER", "'@'",
683 "'.'", "':'", "','", "'/'", "$accept", "spec", "timespec", "items",
684 "item", "cvsstamp", "time", "local_zone", "zone", "day", "date", "rel",
685 "relunit", "relunit_snumber", "seconds", "signed_seconds",
686 "unsigned_seconds", "number", "o_colon_minutes", "o_merid", 0
691 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
693 static const yytype_uint16 yytoknum
[] =
695 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
696 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
697 275, 276, 64, 46, 58, 44, 47
701 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
702 static const yytype_uint8 yyr1
[] =
704 0, 27, 28, 28, 29, 30, 30, 31, 31, 31,
705 31, 31, 31, 31, 31, 32, 33, 33, 33, 33,
706 33, 34, 34, 35, 35, 35, 35, 35, 36, 36,
707 36, 36, 37, 37, 37, 37, 37, 37, 37, 37,
708 37, 38, 38, 39, 39, 39, 39, 39, 39, 39,
709 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
710 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
711 41, 41, 42, 42, 43, 43, 44, 45, 45, 46,
715 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
716 static const yytype_uint8 yyr2
[] =
718 0, 2, 1, 1, 2, 0, 2, 1, 1, 1,
719 1, 1, 1, 1, 1, 5, 2, 4, 5, 6,
720 7, 1, 2, 1, 2, 3, 1, 2, 1, 2,
721 2, 2, 3, 5, 3, 3, 3, 2, 4, 2,
722 3, 2, 1, 2, 2, 1, 2, 2, 1, 2,
723 2, 1, 2, 2, 1, 2, 2, 1, 2, 2,
724 2, 2, 1, 1, 2, 2, 2, 2, 2, 2,
725 1, 1, 1, 1, 1, 1, 1, 0, 2, 0,
729 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
730 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
731 means the default is an error. */
732 static const yytype_uint8 yydefact
[] =
734 5, 0, 0, 2, 3, 73, 75, 72, 74, 4,
735 70, 71, 1, 28, 51, 26, 54, 21, 57, 0,
736 48, 0, 62, 45, 23, 0, 76, 0, 0, 6,
737 13, 7, 8, 9, 11, 10, 12, 42, 63, 14,
738 29, 22, 0, 37, 30, 49, 52, 55, 46, 58,
739 43, 27, 77, 24, 66, 67, 68, 65, 69, 64,
740 31, 50, 53, 16, 56, 39, 47, 59, 44, 0,
741 0, 0, 60, 61, 0, 41, 36, 0, 0, 25,
742 35, 40, 34, 79, 32, 0, 38, 78, 80, 77,
743 0, 17, 0, 0, 18, 79, 33, 15, 77, 19,
747 /* YYDEFGOTO[NTERM-NUM]. */
748 static const yytype_int8 yydefgoto
[] =
750 -1, 2, 3, 4, 29, 30, 31, 32, 33, 34,
751 35, 36, 37, 38, 9, 10, 11, 39, 79, 91
754 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
756 #define YYPACT_NINF -76
757 static const yytype_int8 yypact
[] =
759 -13, 45, 67, -76, 23, -76, -76, -76, -76, -76,
760 -76, -76, -76, 47, -76, -76, -76, 69, -76, 8,
761 -76, 40, -76, -76, -2, 46, -5, 56, 35, -76,
762 -76, -76, -76, -76, -76, -76, -76, 71, -76, -76,
763 -76, -76, 57, 52, -76, -76, -76, -76, -76, -76,
764 -76, -76, 9, -76, -76, -76, -76, -76, -76, -76,
765 -76, -76, -76, -76, -76, 51, -76, -76, -76, 58,
766 59, 60, -76, -76, 61, -76, -76, 62, 64, -76,
767 -76, -76, -76, -6, 54, 63, -76, -76, -76, 65,
768 28, -76, 66, 70, -76, 50, -76, -76, 65, -76,
772 /* YYPGOTO[NTERM-NUM]. */
773 static const yytype_int8 yypgoto
[] =
775 -76, -76, -76, -76, -76, -76, -76, -76, -76, -76,
776 -76, -76, -76, 68, -76, -76, -3, -76, -75, -11
779 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
780 positive, shift that token. If negative, reduce the rule which
781 number is the opposite. If zero, do what YYDEFACT says.
782 If YYTABLE_NINF, syntax error. */
783 #define YYTABLE_NINF -1
784 static const yytype_uint8 yytable
[] =
786 60, 61, 51, 62, 88, 63, 64, 65, 66, 1,
787 67, 68, 89, 69, 94, 54, 52, 55, 90, 70,
788 56, 71, 57, 100, 58, 59, 42, 43, 13, 14,
789 15, 16, 17, 78, 18, 19, 20, 21, 22, 23,
790 24, 25, 26, 27, 28, 44, 45, 6, 46, 8,
791 73, 47, 54, 48, 55, 49, 50, 56, 74, 57,
792 88, 58, 59, 5, 6, 7, 8, 12, 98, 80,
793 81, 72, 40, 41, 75, 76, 82, 77, 83, 84,
794 92, 86, 85, 87, 99, 96, 93, 95, 0, 78,
798 static const yytype_int8 yycheck
[] =
800 5, 6, 4, 8, 10, 10, 11, 12, 13, 22,
801 15, 16, 18, 18, 89, 6, 18, 8, 24, 24,
802 11, 26, 13, 98, 15, 16, 18, 19, 5, 6,
803 7, 8, 9, 24, 11, 12, 13, 14, 15, 16,
804 17, 18, 19, 20, 21, 5, 6, 19, 8, 21,
805 15, 11, 6, 13, 8, 15, 16, 11, 23, 13,
806 10, 15, 16, 18, 19, 20, 21, 0, 18, 18,
807 19, 15, 25, 4, 3, 18, 18, 25, 19, 19,
808 26, 19, 21, 19, 95, 19, 23, 90, -1, 24,
812 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
813 symbol of state STATE-NUM. */
814 static const yytype_uint8 yystos
[] =
816 0, 22, 28, 29, 30, 18, 19, 20, 21, 41,
817 42, 43, 0, 5, 6, 7, 8, 9, 11, 12,
818 13, 14, 15, 16, 17, 18, 19, 20, 21, 31,
819 32, 33, 34, 35, 36, 37, 38, 39, 40, 44,
820 25, 4, 18, 19, 5, 6, 8, 11, 13, 15,
821 16, 4, 18, 40, 6, 8, 11, 13, 15, 16,
822 5, 6, 8, 10, 11, 12, 13, 15, 16, 18,
823 24, 26, 15, 15, 23, 3, 18, 25, 24, 45,
824 18, 19, 18, 19, 19, 21, 19, 19, 10, 18,
825 24, 46, 26, 23, 45, 43, 19, 21, 18, 46,
829 #define yyerrok (yyerrstatus = 0)
830 #define yyclearin (yychar = YYEMPTY)
834 #define YYACCEPT goto yyacceptlab
835 #define YYABORT goto yyabortlab
836 #define YYERROR goto yyerrorlab
839 /* Like YYERROR except do call yyerror. This remains here temporarily
840 to ease the transition to the new meaning of YYERROR, for GCC.
841 Once GCC version 2 has supplanted version 1, this can go. */
843 #define YYFAIL goto yyerrlab
845 #define YYRECOVERING() (!!yyerrstatus)
847 #define YYBACKUP(Token, Value) \
849 if (yychar == YYEMPTY && yylen == 1) \
853 yytoken = YYTRANSLATE (yychar); \
859 yyerror (pc, YY_("syntax error: cannot back up")); \
866 #define YYERRCODE 256
869 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
870 If N is 0, then set CURRENT to the empty location which ends
871 the previous symbol: RHS[0] (always defined). */
873 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
874 #ifndef YYLLOC_DEFAULT
875 # define YYLLOC_DEFAULT(Current, Rhs, N) \
879 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
880 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
881 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
882 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
886 (Current).first_line = (Current).last_line = \
887 YYRHSLOC (Rhs, 0).last_line; \
888 (Current).first_column = (Current).last_column = \
889 YYRHSLOC (Rhs, 0).last_column; \
895 /* YY_LOCATION_PRINT -- Print the location on the stream.
896 This macro was not mandated originally: define only if we know
897 we won't break user code: when these are the locations we know. */
899 #ifndef YY_LOCATION_PRINT
900 # if YYLTYPE_IS_TRIVIAL
901 # define YY_LOCATION_PRINT(File, Loc) \
902 fprintf (File, "%d.%d-%d.%d", \
903 (Loc).first_line, (Loc).first_column, \
904 (Loc).last_line, (Loc).last_column)
906 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
911 /* YYLEX -- calling `yylex' with the right arguments. */
914 # define YYLEX yylex (&yylval, YYLEX_PARAM)
916 # define YYLEX yylex (&yylval, pc)
919 /* Enable debugging if requested. */
923 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
924 # define YYFPRINTF fprintf
927 # define YYDPRINTF(Args) \
933 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
937 YYFPRINTF (stderr, "%s ", Title); \
938 yy_symbol_print (stderr, \
940 YYFPRINTF (stderr, "\n"); \
945 /*--------------------------------.
946 | Print this symbol on YYOUTPUT. |
947 `--------------------------------*/
950 #if (defined __STDC__ || defined __C99__FUNC__ \
951 || defined __cplusplus || defined _MSC_VER)
953 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, parser_control
*pc
)
956 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, pc
)
959 YYSTYPE
const * const yyvaluep
;
967 if (yytype
< YYNTOKENS
)
968 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
980 /*--------------------------------.
981 | Print this symbol on YYOUTPUT. |
982 `--------------------------------*/
984 #if (defined __STDC__ || defined __C99__FUNC__ \
985 || defined __cplusplus || defined _MSC_VER)
987 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, parser_control
*pc
)
990 yy_symbol_print (yyoutput
, yytype
, yyvaluep
, pc
)
993 YYSTYPE
const * const yyvaluep
;
997 if (yytype
< YYNTOKENS
)
998 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1000 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1002 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, pc
);
1003 YYFPRINTF (yyoutput
, ")");
1006 /*------------------------------------------------------------------.
1007 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1009 `------------------------------------------------------------------*/
1011 #if (defined __STDC__ || defined __C99__FUNC__ \
1012 || defined __cplusplus || defined _MSC_VER)
1014 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
1017 yy_stack_print (yybottom
, yytop
)
1018 yytype_int16
*yybottom
;
1019 yytype_int16
*yytop
;
1022 YYFPRINTF (stderr
, "Stack now");
1023 for (; yybottom
<= yytop
; yybottom
++)
1025 int yybot
= *yybottom
;
1026 YYFPRINTF (stderr
, " %d", yybot
);
1028 YYFPRINTF (stderr
, "\n");
1031 # define YY_STACK_PRINT(Bottom, Top) \
1034 yy_stack_print ((Bottom), (Top)); \
1038 /*------------------------------------------------.
1039 | Report that the YYRULE is going to be reduced. |
1040 `------------------------------------------------*/
1042 #if (defined __STDC__ || defined __C99__FUNC__ \
1043 || defined __cplusplus || defined _MSC_VER)
1045 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
, parser_control
*pc
)
1048 yy_reduce_print (yyvsp
, yyrule
, pc
)
1054 int yynrhs
= yyr2
[yyrule
];
1056 unsigned long int yylno
= yyrline
[yyrule
];
1057 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
1059 /* The symbols being reduced. */
1060 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1062 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1063 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
1064 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
1066 YYFPRINTF (stderr
, "\n");
1070 # define YY_REDUCE_PRINT(Rule) \
1073 yy_reduce_print (yyvsp, Rule, pc); \
1076 /* Nonzero means print parse trace. It is left uninitialized so that
1077 multiple parsers can coexist. */
1079 #else /* !YYDEBUG */
1080 # define YYDPRINTF(Args)
1081 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1082 # define YY_STACK_PRINT(Bottom, Top)
1083 # define YY_REDUCE_PRINT(Rule)
1084 #endif /* !YYDEBUG */
1087 /* YYINITDEPTH -- initial size of the parser's stacks. */
1089 # define YYINITDEPTH 200
1092 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1093 if the built-in stack extension method is used).
1095 Do not make this value too large; the results are undefined if
1096 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1097 evaluated with infinite-precision integer arithmetic. */
1100 # define YYMAXDEPTH 10000
1108 # if defined __GLIBC__ && defined _STRING_H
1109 # define yystrlen strlen
1111 /* Return the length of YYSTR. */
1112 #if (defined __STDC__ || defined __C99__FUNC__ \
1113 || defined __cplusplus || defined _MSC_VER)
1115 yystrlen (const char *yystr
)
1123 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1131 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1132 # define yystpcpy stpcpy
1134 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1136 #if (defined __STDC__ || defined __C99__FUNC__ \
1137 || defined __cplusplus || defined _MSC_VER)
1139 yystpcpy (char *yydest
, const char *yysrc
)
1142 yystpcpy (yydest
, yysrc
)
1148 const char *yys
= yysrc
;
1150 while ((*yyd
++ = *yys
++) != '\0')
1159 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1160 quotes and backslashes, so that it's suitable for yyerror. The
1161 heuristic is that double-quoting is unnecessary unless the string
1162 contains an apostrophe, a comma, or backslash (other than
1163 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1164 null, do not copy; instead, return the length of what the result
1167 yytnamerr (char *yyres
, const char *yystr
)
1172 char const *yyp
= yystr
;
1179 goto do_not_strip_quotes
;
1183 goto do_not_strip_quotes
;
1196 do_not_strip_quotes
: ;
1200 return yystrlen (yystr
);
1202 return yystpcpy (yyres
, yystr
) - yyres
;
1206 /* Copy into YYRESULT an error message about the unexpected token
1207 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1208 including the terminating null byte. If YYRESULT is null, do not
1209 copy anything; just return the number of bytes that would be
1210 copied. As a special case, return 0 if an ordinary "syntax error"
1211 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1212 size calculation. */
1214 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1216 int yyn
= yypact
[yystate
];
1218 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1222 int yytype
= YYTRANSLATE (yychar
);
1223 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1224 YYSIZE_T yysize
= yysize0
;
1226 int yysize_overflow
= 0;
1227 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1228 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1232 /* This is so xgettext sees the translatable formats that are
1233 constructed on the fly. */
1234 YY_("syntax error, unexpected %s");
1235 YY_("syntax error, unexpected %s, expecting %s");
1236 YY_("syntax error, unexpected %s, expecting %s or %s");
1237 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1238 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1242 static char const yyunexpected
[] = "syntax error, unexpected %s";
1243 static char const yyexpecting
[] = ", expecting %s";
1244 static char const yyor
[] = " or %s";
1245 char yyformat
[sizeof yyunexpected
1246 + sizeof yyexpecting
- 1
1247 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1248 * (sizeof yyor
- 1))];
1249 char const *yyprefix
= yyexpecting
;
1251 /* Start YYX at -YYN if negative to avoid negative indexes in
1253 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1255 /* Stay within bounds of both yycheck and yytname. */
1256 int yychecklim
= YYLAST
- yyn
+ 1;
1257 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1260 yyarg
[0] = yytname
[yytype
];
1261 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1263 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1264 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1266 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1270 yyformat
[sizeof yyunexpected
- 1] = '\0';
1273 yyarg
[yycount
++] = yytname
[yyx
];
1274 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1275 yysize_overflow
|= (yysize1
< yysize
);
1277 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1281 yyf
= YY_(yyformat
);
1282 yysize1
= yysize
+ yystrlen (yyf
);
1283 yysize_overflow
|= (yysize1
< yysize
);
1286 if (yysize_overflow
)
1287 return YYSIZE_MAXIMUM
;
1291 /* Avoid sprintf, as that infringes on the user's name space.
1292 Don't have undefined behavior even if the translation
1293 produced a string with the wrong number of "%s"s. */
1294 char *yyp
= yyresult
;
1296 while ((*yyp
= *yyf
) != '\0')
1298 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1300 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1313 #endif /* YYERROR_VERBOSE */
1316 /*-----------------------------------------------.
1317 | Release the memory associated to this symbol. |
1318 `-----------------------------------------------*/
1321 #if (defined __STDC__ || defined __C99__FUNC__ \
1322 || defined __cplusplus || defined _MSC_VER)
1324 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, parser_control
*pc
)
1327 yydestruct (yymsg
, yytype
, yyvaluep
, pc
)
1339 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1349 /* Prevent warnings from -Wmissing-prototypes. */
1350 #ifdef YYPARSE_PARAM
1351 #if defined __STDC__ || defined __cplusplus
1352 int yyparse (void *YYPARSE_PARAM
);
1356 #else /* ! YYPARSE_PARAM */
1357 #if defined __STDC__ || defined __cplusplus
1358 int yyparse (parser_control
*pc
);
1362 #endif /* ! YYPARSE_PARAM */
1368 /*-------------------------.
1369 | yyparse or yypush_parse. |
1370 `-------------------------*/
1372 #ifdef YYPARSE_PARAM
1373 #if (defined __STDC__ || defined __C99__FUNC__ \
1374 || defined __cplusplus || defined _MSC_VER)
1376 yyparse (void *YYPARSE_PARAM
)
1379 yyparse (YYPARSE_PARAM
)
1380 void *YYPARSE_PARAM
;
1382 #else /* ! YYPARSE_PARAM */
1383 #if (defined __STDC__ || defined __C99__FUNC__ \
1384 || defined __cplusplus || defined _MSC_VER)
1386 yyparse (parser_control
*pc
)
1394 /* The lookahead symbol. */
1397 /* The semantic value of the lookahead symbol. */
1400 /* Number of syntax errors so far. */
1404 /* Number of tokens to shift before error messages enabled. */
1407 /* The stacks and their tools:
1408 `yyss': related to states.
1409 `yyvs': related to semantic values.
1411 Refer to the stacks thru separate pointers, to allow yyoverflow
1412 to reallocate them elsewhere. */
1414 /* The state stack. */
1415 yytype_int16 yyssa
[YYINITDEPTH
];
1417 yytype_int16
*yyssp
;
1419 /* The semantic value stack. */
1420 YYSTYPE yyvsa
[YYINITDEPTH
];
1424 YYSIZE_T yystacksize
;
1428 /* Lookahead token as an internal (translated) token number. */
1430 /* The variables used to return semantic value and location from the
1435 /* Buffer for error messages, and its allocated size. */
1437 char *yymsg
= yymsgbuf
;
1438 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1441 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1443 /* The number of symbols on the RHS of the reduced rule.
1444 Keep to zero when no symbol should be popped. */
1450 yystacksize
= YYINITDEPTH
;
1452 YYDPRINTF ((stderr
, "Starting parse\n"));
1457 yychar
= YYEMPTY
; /* Cause a token to be read. */
1459 /* Initialize stack pointers.
1460 Waste one element of value and location stack
1461 so that they stay on the same level as the state stack.
1462 The wasted elements are never initialized. */
1468 /*------------------------------------------------------------.
1469 | yynewstate -- Push a new state, which is found in yystate. |
1470 `------------------------------------------------------------*/
1472 /* In all cases, when you get here, the value and location stacks
1473 have just been pushed. So pushing a state here evens the stacks. */
1479 if (yyss
+ yystacksize
- 1 <= yyssp
)
1481 /* Get the current used size of the three stacks, in elements. */
1482 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1486 /* Give user a chance to reallocate the stack. Use copies of
1487 these so that the &'s don't force the real ones into
1489 YYSTYPE
*yyvs1
= yyvs
;
1490 yytype_int16
*yyss1
= yyss
;
1492 /* Each stack pointer address is followed by the size of the
1493 data in use in that stack, in bytes. This used to be a
1494 conditional around just the two extra args, but that might
1495 be undefined if yyoverflow is a macro. */
1496 yyoverflow (YY_("memory exhausted"),
1497 &yyss1
, yysize
* sizeof (*yyssp
),
1498 &yyvs1
, yysize
* sizeof (*yyvsp
),
1504 #else /* no yyoverflow */
1505 # ifndef YYSTACK_RELOCATE
1506 goto yyexhaustedlab
;
1508 /* Extend the stack our own way. */
1509 if (YYMAXDEPTH
<= yystacksize
)
1510 goto yyexhaustedlab
;
1512 if (YYMAXDEPTH
< yystacksize
)
1513 yystacksize
= YYMAXDEPTH
;
1516 yytype_int16
*yyss1
= yyss
;
1517 union yyalloc
*yyptr
=
1518 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1520 goto yyexhaustedlab
;
1521 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1522 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1523 # undef YYSTACK_RELOCATE
1525 YYSTACK_FREE (yyss1
);
1528 #endif /* no yyoverflow */
1530 yyssp
= yyss
+ yysize
- 1;
1531 yyvsp
= yyvs
+ yysize
- 1;
1533 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1534 (unsigned long int) yystacksize
));
1536 if (yyss
+ yystacksize
- 1 <= yyssp
)
1540 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1542 if (yystate
== YYFINAL
)
1552 /* Do appropriate processing given the current state. Read a
1553 lookahead token if we need one and don't already have one. */
1555 /* First try to decide what to do without reference to lookahead token. */
1556 yyn
= yypact
[yystate
];
1557 if (yyn
== YYPACT_NINF
)
1560 /* Not known => get a lookahead token if don't already have one. */
1562 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1563 if (yychar
== YYEMPTY
)
1565 YYDPRINTF ((stderr
, "Reading a token: "));
1569 if (yychar
<= YYEOF
)
1571 yychar
= yytoken
= YYEOF
;
1572 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1576 yytoken
= YYTRANSLATE (yychar
);
1577 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1580 /* If the proper action on seeing token YYTOKEN is to reduce or to
1581 detect an error, take that action. */
1583 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1588 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1594 /* Count tokens shifted since error; after three, turn off error
1599 /* Shift the lookahead token. */
1600 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1602 /* Discard the shifted token. */
1611 /*-----------------------------------------------------------.
1612 | yydefault -- do the default action for the current state. |
1613 `-----------------------------------------------------------*/
1615 yyn
= yydefact
[yystate
];
1621 /*-----------------------------.
1622 | yyreduce -- Do a reduction. |
1623 `-----------------------------*/
1625 /* yyn is the number of a rule to reduce with. */
1628 /* If YYLEN is nonzero, implement the default value of the action:
1631 Otherwise, the following line sets YYVAL to garbage.
1632 This behavior is undocumented and Bison
1633 users should not rely upon it. Assigning to YYVAL
1634 unconditionally makes the parser a bit smaller, and it avoids a
1635 GCC warning that YYVAL may be used uninitialized. */
1636 yyval
= yyvsp
[1-yylen
];
1639 YY_REDUCE_PRINT (yyn
);
1644 /* Line 1455 of yacc.c */
1645 #line 236 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1647 pc
->seconds
= (yyvsp
[(2) - (2)].timespec
);
1648 pc
->timespec_seen
= true;
1654 /* Line 1455 of yacc.c */
1655 #line 249 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1656 { pc
->times_seen
++; ;}
1661 /* Line 1455 of yacc.c */
1662 #line 251 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1663 { pc
->local_zones_seen
++; ;}
1668 /* Line 1455 of yacc.c */
1669 #line 253 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1670 { pc
->zones_seen
++; ;}
1675 /* Line 1455 of yacc.c */
1676 #line 255 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1677 { pc
->dates_seen
++; ;}
1682 /* Line 1455 of yacc.c */
1683 #line 257 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1684 { pc
->days_seen
++; ;}
1689 /* Line 1455 of yacc.c */
1690 #line 259 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1691 { pc
->rels_seen
= true; ;}
1696 /* Line 1455 of yacc.c */
1697 #line 261 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1707 /* Line 1455 of yacc.c */
1708 #line 270 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1711 pc
->year
.negative
= 0;
1712 pc
->year
.value
= (yyvsp
[(1) - (5)].timespec
).tv_sec
;
1714 if (pc
->year
.value
< 70)
1715 pc
->year
.value
+= 2000;
1716 else if (pc
->year
.value
< 100)
1717 pc
->year
.value
+= 1900;
1719 for (i
= pc
->year
.value
, pc
->year
.digits
= 0; i
; i
/= 10, pc
->year
.digits
++)
1721 if (pc
->year
.digits
== 0)
1724 pc
->month
= (yyvsp
[(1) - (5)].timespec
).tv_nsec
/ 10000000;
1725 pc
->day
= (yyvsp
[(3) - (5)].timespec
).tv_sec
;
1726 pc
->hour
= (yyvsp
[(3) - (5)].timespec
).tv_nsec
/ 10000000;
1727 pc
->minutes
= (yyvsp
[(5) - (5)].timespec
).tv_sec
;
1728 pc
->seconds
.tv_sec
= (yyvsp
[(5) - (5)].timespec
).tv_nsec
/ 10000000;
1729 pc
->seconds
.tv_nsec
= 0;
1730 pc
->meridian
= MER24
;
1737 /* Line 1455 of yacc.c */
1738 #line 297 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1740 pc
->hour
= (yyvsp
[(1) - (2)].textintval
).value
;
1742 pc
->seconds
.tv_sec
= 0;
1743 pc
->seconds
.tv_nsec
= 0;
1744 pc
->meridian
= (yyvsp
[(2) - (2)].intval
);
1750 /* Line 1455 of yacc.c */
1751 #line 305 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1753 pc
->hour
= (yyvsp
[(1) - (4)].textintval
).value
;
1754 pc
->minutes
= (yyvsp
[(3) - (4)].textintval
).value
;
1755 pc
->seconds
.tv_sec
= 0;
1756 pc
->seconds
.tv_nsec
= 0;
1757 pc
->meridian
= (yyvsp
[(4) - (4)].intval
);
1763 /* Line 1455 of yacc.c */
1764 #line 313 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1766 pc
->hour
= (yyvsp
[(1) - (5)].textintval
).value
;
1767 pc
->minutes
= (yyvsp
[(3) - (5)].textintval
).value
;
1768 pc
->seconds
.tv_sec
= 0;
1769 pc
->seconds
.tv_nsec
= 0;
1770 pc
->meridian
= MER24
;
1772 pc
->time_zone
= time_zone_hhmm ((yyvsp
[(4) - (5)].textintval
), (yyvsp
[(5) - (5)].intval
));
1778 /* Line 1455 of yacc.c */
1779 #line 323 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1781 pc
->hour
= (yyvsp
[(1) - (6)].textintval
).value
;
1782 pc
->minutes
= (yyvsp
[(3) - (6)].textintval
).value
;
1783 pc
->seconds
= (yyvsp
[(5) - (6)].timespec
);
1784 pc
->meridian
= (yyvsp
[(6) - (6)].intval
);
1790 /* Line 1455 of yacc.c */
1791 #line 330 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1793 pc
->hour
= (yyvsp
[(1) - (7)].textintval
).value
;
1794 pc
->minutes
= (yyvsp
[(3) - (7)].textintval
).value
;
1795 pc
->seconds
= (yyvsp
[(5) - (7)].timespec
);
1796 pc
->meridian
= MER24
;
1798 pc
->time_zone
= time_zone_hhmm ((yyvsp
[(6) - (7)].textintval
), (yyvsp
[(7) - (7)].intval
));
1804 /* Line 1455 of yacc.c */
1805 #line 342 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1807 pc
->local_isdst
= (yyvsp
[(1) - (1)].intval
);
1808 pc
->dsts_seen
+= (0 < (yyvsp
[(1) - (1)].intval
));
1814 /* Line 1455 of yacc.c */
1815 #line 347 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1817 pc
->local_isdst
= 1;
1818 pc
->dsts_seen
+= (0 < (yyvsp
[(1) - (2)].intval
)) + 1;
1824 /* Line 1455 of yacc.c */
1825 #line 355 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1826 { pc
->time_zone
= (yyvsp
[(1) - (1)].intval
); ;}
1831 /* Line 1455 of yacc.c */
1832 #line 357 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1833 { pc
->time_zone
= (yyvsp
[(1) - (2)].intval
); pc
->rels_seen
= true; ;}
1838 /* Line 1455 of yacc.c */
1839 #line 359 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1840 { pc
->time_zone
= (yyvsp
[(1) - (3)].intval
) + time_zone_hhmm ((yyvsp
[(2) - (3)].textintval
), (yyvsp
[(3) - (3)].intval
)); ;}
1845 /* Line 1455 of yacc.c */
1846 #line 361 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1847 { pc
->time_zone
= (yyvsp
[(1) - (1)].intval
) + 60; ;}
1852 /* Line 1455 of yacc.c */
1853 #line 363 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1854 { pc
->time_zone
= (yyvsp
[(1) - (2)].intval
) + 60; ;}
1859 /* Line 1455 of yacc.c */
1860 #line 368 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1862 pc
->day_ordinal
= 1;
1863 pc
->day_number
= (yyvsp
[(1) - (1)].intval
);
1869 /* Line 1455 of yacc.c */
1870 #line 373 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1872 pc
->day_ordinal
= 1;
1873 pc
->day_number
= (yyvsp
[(1) - (2)].intval
);
1879 /* Line 1455 of yacc.c */
1880 #line 378 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1882 pc
->day_ordinal
= (yyvsp
[(1) - (2)].intval
);
1883 pc
->day_number
= (yyvsp
[(2) - (2)].intval
);
1889 /* Line 1455 of yacc.c */
1890 #line 383 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1892 pc
->day_ordinal
= (yyvsp
[(1) - (2)].textintval
).value
;
1893 pc
->day_number
= (yyvsp
[(2) - (2)].intval
);
1899 /* Line 1455 of yacc.c */
1900 #line 391 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1902 pc
->month
= (yyvsp
[(1) - (3)].textintval
).value
;
1903 pc
->day
= (yyvsp
[(3) - (3)].textintval
).value
;
1909 /* Line 1455 of yacc.c */
1910 #line 396 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1912 /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
1913 otherwise as MM/DD/YY.
1914 The goal in recognizing YYYY/MM/DD is solely to support legacy
1915 machine-generated dates like those in an RCS log listing. If
1916 you want portability, use the ISO 8601 format. */
1917 if (4 <= (yyvsp
[(1) - (5)].textintval
).digits
)
1919 pc
->year
= (yyvsp
[(1) - (5)].textintval
);
1920 pc
->month
= (yyvsp
[(3) - (5)].textintval
).value
;
1921 pc
->day
= (yyvsp
[(5) - (5)].textintval
).value
;
1925 pc
->month
= (yyvsp
[(1) - (5)].textintval
).value
;
1926 pc
->day
= (yyvsp
[(3) - (5)].textintval
).value
;
1927 pc
->year
= (yyvsp
[(5) - (5)].textintval
);
1934 /* Line 1455 of yacc.c */
1935 #line 416 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1937 /* ISO 8601 format. YYYY-MM-DD. */
1938 pc
->year
= (yyvsp
[(1) - (3)].textintval
);
1939 pc
->month
= -(yyvsp
[(2) - (3)].textintval
).value
;
1940 pc
->day
= -(yyvsp
[(3) - (3)].textintval
).value
;
1946 /* Line 1455 of yacc.c */
1947 #line 423 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1949 /* e.g. 17-JUN-1992. */
1950 pc
->day
= (yyvsp
[(1) - (3)].textintval
).value
;
1951 pc
->month
= (yyvsp
[(2) - (3)].intval
);
1952 pc
->year
.value
= -(yyvsp
[(3) - (3)].textintval
).value
;
1953 pc
->year
.digits
= (yyvsp
[(3) - (3)].textintval
).digits
;
1959 /* Line 1455 of yacc.c */
1960 #line 431 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1962 /* e.g. JUN-17-1992. */
1963 pc
->month
= (yyvsp
[(1) - (3)].intval
);
1964 pc
->day
= -(yyvsp
[(2) - (3)].textintval
).value
;
1965 pc
->year
.value
= -(yyvsp
[(3) - (3)].textintval
).value
;
1966 pc
->year
.digits
= (yyvsp
[(3) - (3)].textintval
).digits
;
1972 /* Line 1455 of yacc.c */
1973 #line 439 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1975 pc
->month
= (yyvsp
[(1) - (2)].intval
);
1976 pc
->day
= (yyvsp
[(2) - (2)].textintval
).value
;
1982 /* Line 1455 of yacc.c */
1983 #line 444 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1985 pc
->month
= (yyvsp
[(1) - (4)].intval
);
1986 pc
->day
= (yyvsp
[(2) - (4)].textintval
).value
;
1987 pc
->year
= (yyvsp
[(4) - (4)].textintval
);
1993 /* Line 1455 of yacc.c */
1994 #line 450 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
1996 pc
->day
= (yyvsp
[(1) - (2)].textintval
).value
;
1997 pc
->month
= (yyvsp
[(2) - (2)].intval
);
2003 /* Line 1455 of yacc.c */
2004 #line 455 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2006 pc
->day
= (yyvsp
[(1) - (3)].textintval
).value
;
2007 pc
->month
= (yyvsp
[(2) - (3)].intval
);
2008 pc
->year
= (yyvsp
[(3) - (3)].textintval
);
2014 /* Line 1455 of yacc.c */
2015 #line 464 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2017 pc
->rel_ns
= -pc
->rel_ns
;
2018 pc
->rel_seconds
= -pc
->rel_seconds
;
2019 pc
->rel_minutes
= -pc
->rel_minutes
;
2020 pc
->rel_hour
= -pc
->rel_hour
;
2021 pc
->rel_day
= -pc
->rel_day
;
2022 pc
->rel_month
= -pc
->rel_month
;
2023 pc
->rel_year
= -pc
->rel_year
;
2029 /* Line 1455 of yacc.c */
2030 #line 478 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2031 { pc
->rel_year
+= (yyvsp
[(1) - (2)].intval
) * (yyvsp
[(2) - (2)].intval
); ;}
2036 /* Line 1455 of yacc.c */
2037 #line 480 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2038 { pc
->rel_year
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2043 /* Line 1455 of yacc.c */
2044 #line 482 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2045 { pc
->rel_year
+= (yyvsp
[(1) - (1)].intval
); ;}
2050 /* Line 1455 of yacc.c */
2051 #line 484 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2052 { pc
->rel_month
+= (yyvsp
[(1) - (2)].intval
) * (yyvsp
[(2) - (2)].intval
); ;}
2057 /* Line 1455 of yacc.c */
2058 #line 486 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2059 { pc
->rel_month
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2064 /* Line 1455 of yacc.c */
2065 #line 488 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2066 { pc
->rel_month
+= (yyvsp
[(1) - (1)].intval
); ;}
2071 /* Line 1455 of yacc.c */
2072 #line 490 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2073 { pc
->rel_day
+= (yyvsp
[(1) - (2)].intval
) * (yyvsp
[(2) - (2)].intval
); ;}
2078 /* Line 1455 of yacc.c */
2079 #line 492 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2080 { pc
->rel_day
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2085 /* Line 1455 of yacc.c */
2086 #line 494 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2087 { pc
->rel_day
+= (yyvsp
[(1) - (1)].intval
); ;}
2092 /* Line 1455 of yacc.c */
2093 #line 496 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2094 { pc
->rel_hour
+= (yyvsp
[(1) - (2)].intval
) * (yyvsp
[(2) - (2)].intval
); ;}
2099 /* Line 1455 of yacc.c */
2100 #line 498 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2101 { pc
->rel_hour
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2106 /* Line 1455 of yacc.c */
2107 #line 500 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2108 { pc
->rel_hour
+= (yyvsp
[(1) - (1)].intval
); ;}
2113 /* Line 1455 of yacc.c */
2114 #line 502 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2115 { pc
->rel_minutes
+= (yyvsp
[(1) - (2)].intval
) * (yyvsp
[(2) - (2)].intval
); ;}
2120 /* Line 1455 of yacc.c */
2121 #line 504 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2122 { pc
->rel_minutes
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2127 /* Line 1455 of yacc.c */
2128 #line 506 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2129 { pc
->rel_minutes
+= (yyvsp
[(1) - (1)].intval
); ;}
2134 /* Line 1455 of yacc.c */
2135 #line 508 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2136 { pc
->rel_seconds
+= (yyvsp
[(1) - (2)].intval
) * (yyvsp
[(2) - (2)].intval
); ;}
2141 /* Line 1455 of yacc.c */
2142 #line 510 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2143 { pc
->rel_seconds
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2148 /* Line 1455 of yacc.c */
2149 #line 512 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2150 { pc
->rel_seconds
+= (yyvsp
[(1) - (2)].timespec
).tv_sec
* (yyvsp
[(2) - (2)].intval
); pc
->rel_ns
+= (yyvsp
[(1) - (2)].timespec
).tv_nsec
* (yyvsp
[(2) - (2)].intval
); ;}
2155 /* Line 1455 of yacc.c */
2156 #line 514 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2157 { pc
->rel_seconds
+= (yyvsp
[(1) - (2)].timespec
).tv_sec
* (yyvsp
[(2) - (2)].intval
); pc
->rel_ns
+= (yyvsp
[(1) - (2)].timespec
).tv_nsec
* (yyvsp
[(2) - (2)].intval
); ;}
2162 /* Line 1455 of yacc.c */
2163 #line 516 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2164 { pc
->rel_seconds
+= (yyvsp
[(1) - (1)].intval
); ;}
2169 /* Line 1455 of yacc.c */
2170 #line 522 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2171 { pc
->rel_year
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2176 /* Line 1455 of yacc.c */
2177 #line 524 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2178 { pc
->rel_month
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2183 /* Line 1455 of yacc.c */
2184 #line 526 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2185 { pc
->rel_day
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2190 /* Line 1455 of yacc.c */
2191 #line 528 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2192 { pc
->rel_hour
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2197 /* Line 1455 of yacc.c */
2198 #line 530 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2199 { pc
->rel_minutes
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2204 /* Line 1455 of yacc.c */
2205 #line 532 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2206 { pc
->rel_seconds
+= (yyvsp
[(1) - (2)].textintval
).value
* (yyvsp
[(2) - (2)].intval
); ;}
2211 /* Line 1455 of yacc.c */
2212 #line 540 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2213 { (yyval
.timespec
).tv_sec
= (yyvsp
[(1) - (1)].textintval
).value
; (yyval
.timespec
).tv_nsec
= 0; ;}
2218 /* Line 1455 of yacc.c */
2219 #line 546 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2220 { (yyval
.timespec
).tv_sec
= (yyvsp
[(1) - (1)].textintval
).value
; (yyval
.timespec
).tv_nsec
= 0; ;}
2225 /* Line 1455 of yacc.c */
2226 #line 551 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2228 if (pc
->dates_seen
&& ! pc
->year
.digits
2229 && ! pc
->rels_seen
&& (pc
->times_seen
|| 2 < (yyvsp
[(1) - (1)].textintval
).digits
))
2230 pc
->year
= (yyvsp
[(1) - (1)].textintval
);
2233 if (4 < (yyvsp
[(1) - (1)].textintval
).digits
)
2236 pc
->day
= (yyvsp
[(1) - (1)].textintval
).value
% 100;
2237 pc
->month
= ((yyvsp
[(1) - (1)].textintval
).value
/ 100) % 100;
2238 pc
->year
.value
= (yyvsp
[(1) - (1)].textintval
).value
/ 10000;
2239 pc
->year
.digits
= (yyvsp
[(1) - (1)].textintval
).digits
- 4;
2244 if ((yyvsp
[(1) - (1)].textintval
).digits
<= 2)
2246 pc
->hour
= (yyvsp
[(1) - (1)].textintval
).value
;
2251 pc
->hour
= (yyvsp
[(1) - (1)].textintval
).value
/ 100;
2252 pc
->minutes
= (yyvsp
[(1) - (1)].textintval
).value
% 100;
2254 pc
->seconds
.tv_sec
= 0;
2255 pc
->seconds
.tv_nsec
= 0;
2256 pc
->meridian
= MER24
;
2264 /* Line 1455 of yacc.c */
2265 #line 588 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2266 { (yyval
.intval
) = -1; ;}
2271 /* Line 1455 of yacc.c */
2272 #line 590 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2273 { (yyval
.intval
) = (yyvsp
[(2) - (2)].textintval
).value
; ;}
2278 /* Line 1455 of yacc.c */
2279 #line 595 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2280 { (yyval
.intval
) = MER24
; ;}
2285 /* Line 1455 of yacc.c */
2286 #line 597 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2287 { (yyval
.intval
) = (yyvsp
[(1) - (1)].intval
); ;}
2292 /* Line 1455 of yacc.c */
2293 #line 2294 "getdate.c"
2296 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
2300 YY_STACK_PRINT (yyss
, yyssp
);
2304 /* Now `shift' the result of the reduction. Determine what state
2305 that goes to, based on the state we popped back to and the rule
2306 number reduced by. */
2310 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2311 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2312 yystate
= yytable
[yystate
];
2314 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2319 /*------------------------------------.
2320 | yyerrlab -- here on detecting error |
2321 `------------------------------------*/
2323 /* If not already recovering from an error, report this error. */
2327 #if ! YYERROR_VERBOSE
2328 yyerror (pc
, YY_("syntax error"));
2331 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
2332 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
2334 YYSIZE_T yyalloc
= 2 * yysize
;
2335 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
2336 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
2337 if (yymsg
!= yymsgbuf
)
2338 YYSTACK_FREE (yymsg
);
2339 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
2341 yymsg_alloc
= yyalloc
;
2345 yymsg_alloc
= sizeof yymsgbuf
;
2349 if (0 < yysize
&& yysize
<= yymsg_alloc
)
2351 (void) yysyntax_error (yymsg
, yystate
, yychar
);
2352 yyerror (pc
, yymsg
);
2356 yyerror (pc
, YY_("syntax error"));
2358 goto yyexhaustedlab
;
2366 if (yyerrstatus
== 3)
2368 /* If just tried and failed to reuse lookahead token after an
2369 error, discard it. */
2371 if (yychar
<= YYEOF
)
2373 /* Return failure if at end of input. */
2374 if (yychar
== YYEOF
)
2379 yydestruct ("Error: discarding",
2380 yytoken
, &yylval
, pc
);
2385 /* Else will try to reuse lookahead token after shifting the error
2390 /*---------------------------------------------------.
2391 | yyerrorlab -- error raised explicitly by YYERROR. |
2392 `---------------------------------------------------*/
2395 /* Pacify compilers like GCC when the user code never invokes
2396 YYERROR and the label yyerrorlab therefore never appears in user
2398 if (/*CONSTCOND*/ 0)
2401 /* Do not reclaim the symbols of the rule which action triggered
2405 YY_STACK_PRINT (yyss
, yyssp
);
2410 /*-------------------------------------------------------------.
2411 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2412 `-------------------------------------------------------------*/
2414 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2418 yyn
= yypact
[yystate
];
2419 if (yyn
!= YYPACT_NINF
)
2422 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2430 /* Pop the current state because it cannot handle the error token. */
2435 yydestruct ("Error: popping",
2436 yystos
[yystate
], yyvsp
, pc
);
2439 YY_STACK_PRINT (yyss
, yyssp
);
2445 /* Shift the error token. */
2446 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2452 /*-------------------------------------.
2453 | yyacceptlab -- YYACCEPT comes here. |
2454 `-------------------------------------*/
2459 /*-----------------------------------.
2460 | yyabortlab -- YYABORT comes here. |
2461 `-----------------------------------*/
2466 #if !defined(yyoverflow) || YYERROR_VERBOSE
2467 /*-------------------------------------------------.
2468 | yyexhaustedlab -- memory exhaustion comes here. |
2469 `-------------------------------------------------*/
2471 yyerror (pc
, YY_("memory exhausted"));
2477 if (yychar
!= YYEMPTY
)
2478 yydestruct ("Cleanup: discarding lookahead",
2479 yytoken
, &yylval
, pc
);
2480 /* Do not reclaim the symbols of the rule which action triggered
2481 this YYABORT or YYACCEPT. */
2483 YY_STACK_PRINT (yyss
, yyssp
);
2484 while (yyssp
!= yyss
)
2486 yydestruct ("Cleanup: popping",
2487 yystos
[*yyssp
], yyvsp
, pc
);
2492 YYSTACK_FREE (yyss
);
2495 if (yymsg
!= yymsgbuf
)
2496 YYSTACK_FREE (yymsg
);
2498 /* Make sure YYID is used. */
2499 return YYID (yyresult
);
2504 /* Line 1675 of yacc.c */
2505 #line 600 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
2508 static table
const meridian_table
[] =
2510 { "AM", tMERIDIAN
, MERam
},
2511 { "A.M.", tMERIDIAN
, MERam
},
2512 { "PM", tMERIDIAN
, MERpm
},
2513 { "P.M.", tMERIDIAN
, MERpm
},
2517 static table
const dst_table
[] =
2522 static table
const month_and_day_table
[] =
2524 { "JANUARY", tMONTH
, 1 },
2525 { "FEBRUARY", tMONTH
, 2 },
2526 { "MARCH", tMONTH
, 3 },
2527 { "APRIL", tMONTH
, 4 },
2528 { "MAY", tMONTH
, 5 },
2529 { "JUNE", tMONTH
, 6 },
2530 { "JULY", tMONTH
, 7 },
2531 { "AUGUST", tMONTH
, 8 },
2532 { "SEPTEMBER",tMONTH
, 9 },
2533 { "SEPT", tMONTH
, 9 },
2534 { "OCTOBER", tMONTH
, 10 },
2535 { "NOVEMBER", tMONTH
, 11 },
2536 { "DECEMBER", tMONTH
, 12 },
2537 { "SUNDAY", tDAY
, 0 },
2538 { "MONDAY", tDAY
, 1 },
2539 { "TUESDAY", tDAY
, 2 },
2540 { "TUES", tDAY
, 2 },
2541 { "WEDNESDAY",tDAY
, 3 },
2542 { "WEDNES", tDAY
, 3 },
2543 { "THURSDAY", tDAY
, 4 },
2544 { "THUR", tDAY
, 4 },
2545 { "THURS", tDAY
, 4 },
2546 { "FRIDAY", tDAY
, 5 },
2547 { "SATURDAY", tDAY
, 6 },
2551 static table
const time_units_table
[] =
2553 { "YEAR", tYEAR_UNIT
, 1 },
2554 { "MONTH", tMONTH_UNIT
, 1 },
2555 { "FORTNIGHT",tDAY_UNIT
, 14 },
2556 { "WEEK", tDAY_UNIT
, 7 },
2557 { "DAY", tDAY_UNIT
, 1 },
2558 { "HOUR", tHOUR_UNIT
, 1 },
2559 { "MINUTE", tMINUTE_UNIT
, 1 },
2560 { "MIN", tMINUTE_UNIT
, 1 },
2561 { "SECOND", tSEC_UNIT
, 1 },
2562 { "SEC", tSEC_UNIT
, 1 },
2566 /* Assorted relative-time words. */
2567 static table
const relative_time_table
[] =
2569 { "TOMORROW", tDAY_UNIT
, 1 },
2570 { "YESTERDAY",tDAY_UNIT
, -1 },
2571 { "TODAY", tDAY_UNIT
, 0 },
2572 { "NOW", tDAY_UNIT
, 0 },
2573 { "LAST", tORDINAL
, -1 },
2574 { "THIS", tORDINAL
, 0 },
2575 { "NEXT", tORDINAL
, 1 },
2576 { "FIRST", tORDINAL
, 1 },
2577 /*{ "SECOND", tORDINAL, 2 }, */
2578 { "THIRD", tORDINAL
, 3 },
2579 { "FOURTH", tORDINAL
, 4 },
2580 { "FIFTH", tORDINAL
, 5 },
2581 { "SIXTH", tORDINAL
, 6 },
2582 { "SEVENTH", tORDINAL
, 7 },
2583 { "EIGHTH", tORDINAL
, 8 },
2584 { "NINTH", tORDINAL
, 9 },
2585 { "TENTH", tORDINAL
, 10 },
2586 { "ELEVENTH", tORDINAL
, 11 },
2587 { "TWELFTH", tORDINAL
, 12 },
2592 /* The universal time zone table. These labels can be used even for
2593 time stamps that would not otherwise be valid, e.g., GMT time
2594 stamps in London during summer. */
2595 static table
const universal_time_zone_table
[] =
2597 { "GMT", tZONE
, HOUR ( 0) }, /* Greenwich Mean */
2598 { "UT", tZONE
, HOUR ( 0) }, /* Universal (Coordinated) */
2599 { "UTC", tZONE
, HOUR ( 0) },
2603 /* The time zone table. This table is necessarily incomplete, as time
2604 zone abbreviations are ambiguous; e.g. Australians interpret "EST"
2605 as Eastern time in Australia, not as US Eastern Standard Time.
2606 You cannot rely on getdate to handle arbitrary time zone
2607 abbreviations; use numeric abbreviations like `-0500' instead. */
2608 static table
const time_zone_table
[] =
2610 { "WET", tZONE
, HOUR ( 0) }, /* Western European */
2611 { "WEST", tDAYZONE
, HOUR ( 0) }, /* Western European Summer */
2612 { "BST", tDAYZONE
, HOUR ( 0) }, /* British Summer */
2613 { "ART", tZONE
, -HOUR ( 3) }, /* Argentina */
2614 { "BRT", tZONE
, -HOUR ( 3) }, /* Brazil */
2615 { "BRST", tDAYZONE
, -HOUR ( 3) }, /* Brazil Summer */
2616 { "NST", tZONE
, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */
2617 { "NDT", tDAYZONE
,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */
2618 { "AST", tZONE
, -HOUR ( 4) }, /* Atlantic Standard */
2619 { "ADT", tDAYZONE
, -HOUR ( 4) }, /* Atlantic Daylight */
2620 { "CLT", tZONE
, -HOUR ( 4) }, /* Chile */
2621 { "CLST", tDAYZONE
, -HOUR ( 4) }, /* Chile Summer */
2622 { "EST", tZONE
, -HOUR ( 5) }, /* Eastern Standard */
2623 { "EDT", tDAYZONE
, -HOUR ( 5) }, /* Eastern Daylight */
2624 { "CST", tZONE
, -HOUR ( 6) }, /* Central Standard */
2625 { "CDT", tDAYZONE
, -HOUR ( 6) }, /* Central Daylight */
2626 { "MST", tZONE
, -HOUR ( 7) }, /* Mountain Standard */
2627 { "MDT", tDAYZONE
, -HOUR ( 7) }, /* Mountain Daylight */
2628 { "PST", tZONE
, -HOUR ( 8) }, /* Pacific Standard */
2629 { "PDT", tDAYZONE
, -HOUR ( 8) }, /* Pacific Daylight */
2630 { "AKST", tZONE
, -HOUR ( 9) }, /* Alaska Standard */
2631 { "AKDT", tDAYZONE
, -HOUR ( 9) }, /* Alaska Daylight */
2632 { "HST", tZONE
, -HOUR (10) }, /* Hawaii Standard */
2633 { "HAST", tZONE
, -HOUR (10) }, /* Hawaii-Aleutian Standard */
2634 { "HADT", tDAYZONE
, -HOUR (10) }, /* Hawaii-Aleutian Daylight */
2635 { "SST", tZONE
, -HOUR (12) }, /* Samoa Standard */
2636 { "WAT", tZONE
, HOUR ( 1) }, /* West Africa */
2637 { "CET", tZONE
, HOUR ( 1) }, /* Central European */
2638 { "CEST", tDAYZONE
, HOUR ( 1) }, /* Central European Summer */
2639 { "MET", tZONE
, HOUR ( 1) }, /* Middle European */
2640 { "MEZ", tZONE
, HOUR ( 1) }, /* Middle European */
2641 { "MEST", tDAYZONE
, HOUR ( 1) }, /* Middle European Summer */
2642 { "MESZ", tDAYZONE
, HOUR ( 1) }, /* Middle European Summer */
2643 { "EET", tZONE
, HOUR ( 2) }, /* Eastern European */
2644 { "EEST", tDAYZONE
, HOUR ( 2) }, /* Eastern European Summer */
2645 { "CAT", tZONE
, HOUR ( 2) }, /* Central Africa */
2646 { "SAST", tZONE
, HOUR ( 2) }, /* South Africa Standard */
2647 { "EAT", tZONE
, HOUR ( 3) }, /* East Africa */
2648 { "MSK", tZONE
, HOUR ( 3) }, /* Moscow */
2649 { "MSD", tDAYZONE
, HOUR ( 3) }, /* Moscow Daylight */
2650 { "IST", tZONE
, (HOUR ( 5) + 30) }, /* India Standard */
2651 { "SGT", tZONE
, HOUR ( 8) }, /* Singapore */
2652 { "KST", tZONE
, HOUR ( 9) }, /* Korea Standard */
2653 { "JST", tZONE
, HOUR ( 9) }, /* Japan Standard */
2654 { "GST", tZONE
, HOUR (10) }, /* Guam Standard */
2655 { "NZST", tZONE
, HOUR (12) }, /* New Zealand Standard */
2656 { "NZDT", tDAYZONE
, HOUR (12) }, /* New Zealand Daylight */
2660 /* Military time zone table. */
2661 static table
const military_table
[] =
2663 { "A", tZONE
, -HOUR ( 1) },
2664 { "B", tZONE
, -HOUR ( 2) },
2665 { "C", tZONE
, -HOUR ( 3) },
2666 { "D", tZONE
, -HOUR ( 4) },
2667 { "E", tZONE
, -HOUR ( 5) },
2668 { "F", tZONE
, -HOUR ( 6) },
2669 { "G", tZONE
, -HOUR ( 7) },
2670 { "H", tZONE
, -HOUR ( 8) },
2671 { "I", tZONE
, -HOUR ( 9) },
2672 { "K", tZONE
, -HOUR (10) },
2673 { "L", tZONE
, -HOUR (11) },
2674 { "M", tZONE
, -HOUR (12) },
2675 { "N", tZONE
, HOUR ( 1) },
2676 { "O", tZONE
, HOUR ( 2) },
2677 { "P", tZONE
, HOUR ( 3) },
2678 { "Q", tZONE
, HOUR ( 4) },
2679 { "R", tZONE
, HOUR ( 5) },
2680 { "S", tZONE
, HOUR ( 6) },
2681 { "T", tZONE
, HOUR ( 7) },
2682 { "U", tZONE
, HOUR ( 8) },
2683 { "V", tZONE
, HOUR ( 9) },
2684 { "W", tZONE
, HOUR (10) },
2685 { "X", tZONE
, HOUR (11) },
2686 { "Y", tZONE
, HOUR (12) },
2687 { "Z", tZONE
, HOUR ( 0) },
2693 /* Convert a time zone expressed as HH:MM into an integer count of
2694 minutes. If MM is negative, then S is of the form HHMM and needs
2695 to be picked apart; otherwise, S is of the form HH. */
2698 time_zone_hhmm (textint s
, long int mm
)
2701 return (s
.value
/ 100) * 60 + s
.value
% 100;
2703 return s
.value
* 60 + (s
.negative
? -mm
: mm
);
2707 to_hour (long int hours
, int meridian
)
2711 default: /* Pacify GCC. */
2713 return 0 <= hours
&& hours
< 24 ? hours
: -1;
2715 return 0 < hours
&& hours
< 12 ? hours
: hours
== 12 ? 0 : -1;
2717 return 0 < hours
&& hours
< 12 ? hours
+ 12 : hours
== 12 ? 12 : -1;
2722 to_year (textint textyear
)
2724 long int year
= textyear
.value
;
2729 /* XPG4 suggests that years 00-68 map to 2000-2068, and
2730 years 69-99 map to 1969-1999. */
2731 else if (textyear
.digits
== 2)
2732 year
+= year
< 69 ? 2000 : 1900;
2737 static table
const *
2738 lookup_zone (parser_control
const *pc
, char const *name
)
2742 for (tp
= universal_time_zone_table
; tp
->name
; tp
++)
2743 if (strcmp (name
, tp
->name
) == 0)
2746 /* Try local zone abbreviations before those in time_zone_table, as
2747 the local ones are more likely to be right. */
2748 for (tp
= pc
->local_time_zone_table
; tp
->name
; tp
++)
2749 if (strcmp (name
, tp
->name
) == 0)
2752 for (tp
= time_zone_table
; tp
->name
; tp
++)
2753 if (strcmp (name
, tp
->name
) == 0)
2759 #if ! HAVE_TM_GMTOFF
2760 /* Yield the difference between *A and *B,
2761 measured in seconds, ignoring leap seconds.
2762 The body of this function is taken directly from the GNU C Library;
2763 see src/strftime.c. */
2765 tm_diff (struct tm
const *a
, struct tm
const *b
)
2767 /* Compute intervening leap days correctly even if year is negative.
2768 Take care to avoid int overflow in leap day calculations. */
2769 int a4
= SHR (a
->tm_year
, 2) + SHR (TM_YEAR_BASE
, 2) - ! (a
->tm_year
& 3);
2770 int b4
= SHR (b
->tm_year
, 2) + SHR (TM_YEAR_BASE
, 2) - ! (b
->tm_year
& 3);
2771 int a100
= a4
/ 25 - (a4
% 25 < 0);
2772 int b100
= b4
/ 25 - (b4
% 25 < 0);
2773 int a400
= SHR (a100
, 2);
2774 int b400
= SHR (b100
, 2);
2775 int intervening_leap_days
= (a4
- b4
) - (a100
- b100
) + (a400
- b400
);
2776 long int ayear
= a
->tm_year
;
2777 long int years
= ayear
- b
->tm_year
;
2778 long int days
= (365 * years
+ intervening_leap_days
2779 + (a
->tm_yday
- b
->tm_yday
));
2780 return (60 * (60 * (24 * days
+ (a
->tm_hour
- b
->tm_hour
))
2781 + (a
->tm_min
- b
->tm_min
))
2782 + (a
->tm_sec
- b
->tm_sec
));
2784 #endif /* ! HAVE_TM_GMTOFF */
2786 static table
const *
2787 lookup_word (parser_control
const *pc
, char *word
)
2796 /* Make it uppercase. */
2797 for (p
= word
; *p
; p
++)
2799 unsigned char ch
= *p
;
2804 for (tp
= meridian_table
; tp
->name
; tp
++)
2805 if (strcmp (word
, tp
->name
) == 0)
2808 /* See if we have an abbreviation for a month. */
2809 wordlen
= strlen (word
);
2810 abbrev
= wordlen
== 3 || (wordlen
== 4 && word
[3] == '.');
2812 for (tp
= month_and_day_table
; tp
->name
; tp
++)
2813 if ((abbrev
? strncmp (word
, tp
->name
, 3) : strcmp (word
, tp
->name
)) == 0)
2816 if ((tp
= lookup_zone (pc
, word
)))
2819 if (strcmp (word
, dst_table
[0].name
) == 0)
2822 for (tp
= time_units_table
; tp
->name
; tp
++)
2823 if (strcmp (word
, tp
->name
) == 0)
2826 /* Strip off any plural and try the units table again. */
2827 if (word
[wordlen
- 1] == 'S')
2829 word
[wordlen
- 1] = '\0';
2830 for (tp
= time_units_table
; tp
->name
; tp
++)
2831 if (strcmp (word
, tp
->name
) == 0)
2833 word
[wordlen
- 1] = 'S'; /* For "this" in relative_time_table. */
2836 for (tp
= relative_time_table
; tp
->name
; tp
++)
2837 if (strcmp (word
, tp
->name
) == 0)
2840 /* Military time zones. */
2842 for (tp
= military_table
; tp
->name
; tp
++)
2843 if (word
[0] == tp
->name
[0])
2846 /* Drop out any periods and try the time zone table again. */
2847 for (period_found
= false, p
= q
= word
; (*p
= *q
); q
++)
2849 period_found
= true;
2852 if (period_found
&& (tp
= lookup_zone (pc
, word
)))
2859 yylex (YYSTYPE
*lvalp
, parser_control
*pc
)
2866 while (c
= *pc
->input
, ISSPACE (c
))
2869 if (ISDIGIT (c
) || c
== '-' || c
== '+')
2873 unsigned long int value
;
2874 if (c
== '-' || c
== '+')
2876 sign
= c
== '-' ? -1 : 1;
2877 while (c
= *++pc
->input
, ISSPACE (c
))
2880 /* skip the '-' sign */
2886 for (value
= 0; ; value
*= 10)
2888 unsigned long int value1
= value
+ (c
- '0');
2895 if (ULONG_MAX
/ 10 < value
)
2898 if ((c
== '.' || c
== ',') && ISDIGIT (p
[1]))
2903 unsigned long int value1
;
2905 /* Check for overflow when converting value to time_t. */
2920 if (value
!= value1
)
2923 /* Accumulate fraction, to ns precision. */
2926 for (digits
= 2; digits
<= LOG10_BILLION
; digits
++)
2933 /* Skip excess digits, truncating toward -Infinity. */
2935 for (; ISDIGIT (*p
); p
++)
2941 while (ISDIGIT (*p
))
2944 /* Adjust to the timespec convention, which is that
2945 tv_nsec is always a positive offset even if tv_sec is
2955 lvalp
->timespec
.tv_sec
= s
;
2956 lvalp
->timespec
.tv_nsec
= ns
;
2958 return sign
? tSDECIMAL_NUMBER
: tUDECIMAL_NUMBER
;
2962 lvalp
->textintval
.negative
= sign
< 0;
2965 lvalp
->textintval
.value
= - value
;
2966 if (0 < lvalp
->textintval
.value
)
2971 lvalp
->textintval
.value
= value
;
2972 if (lvalp
->textintval
.value
< 0)
2975 lvalp
->textintval
.digits
= p
- pc
->input
;
2977 return sign
? tSNUMBER
: tUNUMBER
;
2989 if (p
< buff
+ sizeof buff
- 1)
2993 while (ISALPHA (c
) || c
== '.');
2996 tp
= lookup_word (pc
, buff
);
2999 lvalp
->intval
= tp
->value
;
3004 return *pc
->input
++;
3020 /* Do nothing if the parser reports an error. */
3022 yyerror (parser_control
*pc ATTRIBUTE_UNUSED
, char *s ATTRIBUTE_UNUSED
)
3027 /* If *TM0 is the old and *TM1 is the new value of a struct tm after
3028 passing it to mktime, return true if it's OK that mktime returned T.
3029 It's not OK if *TM0 has out-of-range members. */
3032 mktime_ok (struct tm
const *tm0
, struct tm
const *tm1
, time_t t
)
3034 if (t
== (time_t) -1)
3036 /* Guard against falsely reporting an error when parsing a time
3037 stamp that happens to equal (time_t) -1, on a host that
3038 supports such a time stamp. */
3039 tm1
= localtime (&t
);
3044 return ! ((tm0
->tm_sec
^ tm1
->tm_sec
)
3045 | (tm0
->tm_min
^ tm1
->tm_min
)
3046 | (tm0
->tm_hour
^ tm1
->tm_hour
)
3047 | (tm0
->tm_mday
^ tm1
->tm_mday
)
3048 | (tm0
->tm_mon
^ tm1
->tm_mon
)
3049 | (tm0
->tm_year
^ tm1
->tm_year
));
3052 /* A reasonable upper bound for the size of ordinary TZ strings.
3053 Use heap allocation if TZ's length exceeds this. */
3054 enum { TZBUFSIZE
= 100 };
3056 /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated
3059 get_tz (char tzbuf
[TZBUFSIZE
])
3061 char *tz
= getenv ("TZ");
3064 size_t tzsize
= strlen (tz
) + 1;
3065 tz
= (tzsize
<= TZBUFSIZE
3066 ? memcpy (tzbuf
, tz
, tzsize
)
3067 : xmemdup (tz
, tzsize
));
3072 /* Parse a date/time string, storing the resulting time value into *RESULT.
3073 The string itself is pointed to by P. Return true if successful.
3074 P can be an incomplete or relative time specification; if so, use
3075 *NOW as the basis for the returned time. */
3077 get_date (struct timespec
*result
, char const *p
, struct timespec
const *now
)
3081 struct tm
const *tmp
;
3085 struct timespec gettime_buffer
;
3087 bool tz_was_altered
= false;
3089 char tz0buf
[TZBUFSIZE
];
3094 gettime (&gettime_buffer
);
3095 now
= &gettime_buffer
;
3098 Start
= now
->tv_sec
;
3099 Start_ns
= now
->tv_nsec
;
3101 tmp
= localtime (&now
->tv_sec
);
3105 while (c
= *p
, ISSPACE (c
))
3108 if (strncmp (p
, "TZ=\"", 4) == 0)
3110 char const *tzbase
= p
+ 4;
3114 for (s
= tzbase
; *s
; s
++, tzsize
++)
3118 if (! (*s
== '\\' || *s
== '"'))
3125 char tz1buf
[TZBUFSIZE
];
3126 bool large_tz
= TZBUFSIZE
< tzsize
;
3128 tz0
= get_tz (tz0buf
);
3129 z
= tz1
= large_tz
? xmalloc (tzsize
) : tz1buf
;
3130 for (s
= tzbase
; *s
!= '"'; s
++)
3131 *z
++ = *(s
+= *s
== '\\');
3133 setenv_ok
= setenv ("TZ", tz1
, 1) == 0;
3138 tz_was_altered
= true;
3144 pc
.year
.value
= tmp
->tm_year
;
3145 pc
.year
.value
+= TM_YEAR_BASE
;
3147 pc
.month
= tmp
->tm_mon
+ 1;
3148 pc
.day
= tmp
->tm_mday
;
3149 pc
.hour
= tmp
->tm_hour
;
3150 pc
.minutes
= tmp
->tm_min
;
3151 pc
.seconds
.tv_sec
= tmp
->tm_sec
;
3152 pc
.seconds
.tv_nsec
= Start_ns
;
3153 tm
.tm_isdst
= tmp
->tm_isdst
;
3155 pc
.meridian
= MER24
;
3163 pc
.timespec_seen
= false;
3164 pc
.rels_seen
= false;
3168 pc
.local_zones_seen
= 0;
3172 #if HAVE_STRUCT_TM_TM_ZONE
3173 pc
.local_time_zone_table
[0].name
= tmp
->tm_zone
;
3174 pc
.local_time_zone_table
[0].type
= tLOCAL_ZONE
;
3175 pc
.local_time_zone_table
[0].value
= tmp
->tm_isdst
;
3176 pc
.local_time_zone_table
[1].name
= NULL
;
3178 /* Probe the names used in the next three calendar quarters, looking
3179 for a tm_isdst different from the one we already have. */
3182 for (quarter
= 1; quarter
<= 3; quarter
++)
3184 time_t probe
= Start
+ quarter
* (90 * 24 * 60 * 60);
3185 struct tm
const *probe_tm
= localtime (&probe
);
3186 if (probe_tm
&& probe_tm
->tm_zone
3187 && probe_tm
->tm_isdst
!= pc
.local_time_zone_table
[0].value
)
3190 pc
.local_time_zone_table
[1].name
= probe_tm
->tm_zone
;
3191 pc
.local_time_zone_table
[1].type
= tLOCAL_ZONE
;
3192 pc
.local_time_zone_table
[1].value
= probe_tm
->tm_isdst
;
3193 pc
.local_time_zone_table
[2].name
= NULL
;
3203 extern char *tzname
[];
3206 for (i
= 0; i
< 2; i
++)
3208 pc
.local_time_zone_table
[i
].name
= tzname
[i
];
3209 pc
.local_time_zone_table
[i
].type
= tLOCAL_ZONE
;
3210 pc
.local_time_zone_table
[i
].value
= i
;
3212 pc
.local_time_zone_table
[i
].name
= NULL
;
3215 pc
.local_time_zone_table
[0].name
= NULL
;
3219 if (pc
.local_time_zone_table
[0].name
&& pc
.local_time_zone_table
[1].name
3220 && ! strcmp (pc
.local_time_zone_table
[0].name
,
3221 pc
.local_time_zone_table
[1].name
))
3223 /* This locale uses the same abbrevation for standard and
3224 daylight times. So if we see that abbreviation, we don't
3225 know whether it's daylight time. */
3226 pc
.local_time_zone_table
[0].value
= -1;
3227 pc
.local_time_zone_table
[1].name
= NULL
;
3230 if (yyparse (&pc
) != 0)
3233 if (pc
.timespec_seen
)
3234 *result
= pc
.seconds
;
3237 if (1 < (pc
.times_seen
| pc
.dates_seen
| pc
.days_seen
| pc
.dsts_seen
3238 | (pc
.local_zones_seen
+ pc
.zones_seen
)))
3241 tm
.tm_year
= to_year (pc
.year
) - TM_YEAR_BASE
;
3242 tm
.tm_mon
= pc
.month
- 1;
3243 tm
.tm_mday
= pc
.day
;
3244 if (pc
.times_seen
|| (pc
.rels_seen
&& ! pc
.dates_seen
&& ! pc
.days_seen
))
3246 tm
.tm_hour
= to_hour (pc
.hour
, pc
.meridian
);
3249 tm
.tm_min
= pc
.minutes
;
3250 tm
.tm_sec
= pc
.seconds
.tv_sec
;
3254 tm
.tm_hour
= tm
.tm_min
= tm
.tm_sec
= 0;
3255 pc
.seconds
.tv_nsec
= 0;
3258 /* Let mktime deduce tm_isdst if we have an absolute time stamp. */
3262 /* But if the input explicitly specifies local time with or without
3263 DST, give mktime that information. */
3264 if (pc
.local_zones_seen
)
3265 tm
.tm_isdst
= pc
.local_isdst
;
3269 Start
= mktime (&tm
);
3271 if (! mktime_ok (&tm0
, &tm
, Start
))
3273 if (! pc
.zones_seen
)
3277 /* Guard against falsely reporting errors near the time_t
3278 boundaries when parsing times in other time zones. For
3279 example, suppose the input string "1969-12-31 23:00:00 -0100",
3280 the current time zone is 8 hours ahead of UTC, and the min
3281 time_t value is 1970-01-01 00:00:00 UTC. Then the min
3282 localtime value is 1970-01-01 08:00:00, and mktime will
3283 therefore fail on 1969-12-31 23:00:00. To work around the
3284 problem, set the time zone to 1 hour behind UTC temporarily
3285 by setting TZ="XXX1:00" and try mktime again. */
3287 long int time_zone
= pc
.time_zone
;
3288 long int abs_time_zone
= time_zone
< 0 ? - time_zone
: time_zone
;
3289 long int abs_time_zone_hour
= abs_time_zone
/ 60;
3290 int abs_time_zone_min
= abs_time_zone
% 60;
3291 char tz1buf
[sizeof "XXX+0:00"
3292 + sizeof pc
.time_zone
* CHAR_BIT
/ 3];
3293 if (!tz_was_altered
)
3294 tz0
= get_tz (tz0buf
);
3295 sprintf (tz1buf
, "XXX%s%ld:%02d", "-" + (time_zone
< 0),
3296 abs_time_zone_hour
, abs_time_zone_min
);
3297 if (setenv ("TZ", tz1buf
, 1) != 0)
3299 tz_was_altered
= true;
3301 Start
= mktime (&tm
);
3302 if (! mktime_ok (&tm0
, &tm
, Start
))
3307 if (pc
.days_seen
&& ! pc
.dates_seen
)
3309 tm
.tm_mday
+= ((pc
.day_number
- tm
.tm_wday
+ 7) % 7
3310 + 7 * (pc
.day_ordinal
- (0 < pc
.day_ordinal
)));
3312 Start
= mktime (&tm
);
3313 if (Start
== (time_t) -1)
3319 long int delta
= pc
.time_zone
* 60;
3321 #ifdef HAVE_TM_GMTOFF
3322 delta
-= tm
.tm_gmtoff
;
3325 struct tm
const *gmt
= gmtime (&t
);
3328 delta
-= tm_diff (&tm
, gmt
);
3331 if ((Start
< t1
) != (delta
< 0))
3332 goto fail
; /* time_t overflow */
3336 /* Add relative date. */
3337 if (pc
.rel_year
| pc
.rel_month
| pc
.rel_day
)
3339 int year
= tm
.tm_year
+ pc
.rel_year
;
3340 int month
= tm
.tm_mon
+ pc
.rel_month
;
3341 int day
= tm
.tm_mday
+ pc
.rel_day
;
3342 if (((year
< tm
.tm_year
) ^ (pc
.rel_year
< 0))
3343 | ((month
< tm
.tm_mon
) ^ (pc
.rel_month
< 0))
3344 | ((day
< tm
.tm_mday
) ^ (pc
.rel_day
< 0)))
3349 Start
= mktime (&tm
);
3350 if (Start
== (time_t) -1)
3354 /* Add relative hours, minutes, and seconds. On hosts that support
3355 leap seconds, ignore the possibility of leap seconds; e.g.,
3356 "+ 10 minutes" adds 600 seconds, even if one of them is a
3357 leap second. Typically this is not what the user wants, but it's
3358 too hard to do it the other way, because the time zone indicator
3359 must be applied before relative times, and if mktime is applied
3360 again the time zone will be lost. */
3362 long int sum_ns
= pc
.seconds
.tv_nsec
+ pc
.rel_ns
;
3363 long int normalized_ns
= (sum_ns
% BILLION
+ BILLION
) % BILLION
;
3365 long int d1
= 60 * 60 * pc
.rel_hour
;
3366 time_t t1
= t0
+ d1
;
3367 long int d2
= 60 * pc
.rel_minutes
;
3368 time_t t2
= t1
+ d2
;
3369 long int d3
= pc
.rel_seconds
;
3370 time_t t3
= t2
+ d3
;
3371 long int d4
= (sum_ns
- normalized_ns
) / BILLION
;
3372 time_t t4
= t3
+ d4
;
3374 if ((d1
/ (60 * 60) ^ pc
.rel_hour
)
3375 | (d2
/ 60 ^ pc
.rel_minutes
)
3376 | ((t1
< t0
) ^ (d1
< 0))
3377 | ((t2
< t1
) ^ (d2
< 0))
3378 | ((t3
< t2
) ^ (d3
< 0))
3379 | ((t4
< t3
) ^ (d4
< 0)))
3382 result
->tv_sec
= t4
;
3383 result
->tv_nsec
= normalized_ns
;
3393 ok
&= (tz0
? setenv ("TZ", tz0
, 1) : unsetenv ("TZ")) == 0;
3402 main (int ac
, char **av
)
3406 printf ("Enter date, or blank line to exit.\n\t> ");
3409 buff
[BUFSIZ
- 1] = '\0';
3410 while (fgets (buff
, BUFSIZ
- 1, stdin
) && buff
[0])
3413 struct tm
const *tm
;
3414 if (! get_date (&d
, buff
, NULL
))
3415 printf ("Bad format - couldn't convert.\n");
3416 else if (! (tm
= localtime (&d
.tv_sec
)))
3418 long int sec
= d
.tv_sec
;
3419 printf ("localtime (%ld) failed\n", sec
);
3424 printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n",
3425 tm
->tm_year
+ 1900L, tm
->tm_mon
+ 1, tm
->tm_mday
,
3426 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
, ns
);