1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
87 tSDECIMAL_NUMBER = 276,
88 tUDECIMAL_NUMBER = 277
94 #define tYEAR_UNIT 260
95 #define tMONTH_UNIT 261
96 #define tHOUR_UNIT 262
97 #define tMINUTE_UNIT 263
100 #define tDAY_SHIFT 266
103 #define tLOCAL_ZONE 269
104 #define tMERIDIAN 270
110 #define tSDECIMAL_NUMBER 276
111 #define tUDECIMAL_NUMBER 277
116 /* Copy the first part of user declarations. */
119 /* Parse a string into an internal time stamp.
121 Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
122 2010 Free Software Foundation, Inc.
124 This program is free software: you can redistribute it and/or modify
125 it under the terms of the GNU General Public License as published by
126 the Free Software Foundation; either version 3 of the License, or
127 (at your option) any later version.
129 This program is distributed in the hope that it will be useful,
130 but WITHOUT ANY WARRANTY; without even the implied warranty of
131 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132 GNU General Public License for more details.
134 You should have received a copy of the GNU General Public License
135 along with this program. If not, see <http://www.gnu.org/licenses/>. */
137 /* Originally written by Steven M. Bellovin <smb@research.att.com> while
138 at the University of North Carolina at Chapel Hill. Later tweaked by
139 a couple of people on Usenet. Completely overhauled by Rich $alz
140 <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
142 Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do
143 the right thing about local DST. Also modified by Paul Eggert
144 <eggert@cs.ucla.edu> in February 2004 to support
145 nanosecond-resolution time stamps, and in October 2004 to support
146 TZ strings in dates. */
148 /* FIXME: Check for arithmetic overflow in all cases, not just
155 #include "intprops.h"
156 #include "timespec.h"
159 /* There's no need to extend the stack, so there's no need to involve
161 #define YYSTACK_USE_ALLOCA 0
163 /* Tell Bison how much stack space is needed. 20 should be plenty for
164 this grammar, which is not right recursive. Beware setting it too
165 high, since that might cause problems on machines whose
166 implementations have lame stack-overflow checking. */
167 #define YYMAXDEPTH 20
168 #define YYINITDEPTH YYMAXDEPTH
170 /* Since the code of getdate.y is not included in the Emacs executable
171 itself, there is no need to #define static in this file. Even if
172 the code were included in the Emacs executable, it probably
173 wouldn't do any harm to #undef it here; this will only cause
174 problems if we try to write to a static variable, which I don't
175 think this code needs to do. */
189 /* ISDIGIT differs from isdigit, as follows:
190 - Its arg may be any int or unsigned int; it need not be an unsigned char
192 - It's typically faster.
193 POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
194 isdigit unless it's important to use the locale's definition
195 of `digit' even when the host does not conform to POSIX. */
196 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
198 /* Shift A right by B bits portably, by dividing A by 2**B and
199 truncating towards minus infinity. A and B should be free of side
200 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
201 INT_BITS is the number of useful bits in an int. GNU code can
202 assume that INT_BITS is at least 32.
204 ISO C99 says that A >> B is implementation-defined if A < 0. Some
205 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
206 right in the usual way when A < 0, so SHR falls back on division if
207 ordinary A >> B doesn't seem to be the usual signed shift. */
211 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
213 #define EPOCH_YEAR 1970
214 #define TM_YEAR_BASE 1900
216 #define HOUR(x) ((x) * 60)
218 /* long_time_t is a signed integer type that contains all time_t values. */
219 verify (TYPE_IS_INTEGER (time_t));
220 #if TIME_T_FITS_IN_LONG_INT
221 typedef long int long_time_t;
223 typedef time_t long_time_t;
226 /* Lots of this code assumes time_t and time_t-like values fit into
228 verify (TYPE_MINIMUM (long_time_t) <= TYPE_MINIMUM (time_t)
229 && TYPE_MAXIMUM (time_t) <= TYPE_MAXIMUM (long_time_t));
231 /* FIXME: It also assumes that signed integer overflow silently wraps around,
232 but this is not true any more with recent versions of GCC 4. */
234 /* An integer value, and the number of digits in its textual
243 /* An entry in the lexical lookup table. */
251 /* Meridian: am, pm, or 24-hour style. */
252 enum { MERam, MERpm, MER24 };
254 enum { BILLION = 1000000000, LOG10_BILLION = 9 };
256 /* Relative times. */
259 /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */
269 #if HAVE_COMPOUND_LITERALS
270 # define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 })
272 static relative_time const RELATIVE_TIME_0;
275 /* Information passed to and from the parser. */
278 /* The input string remaining to be parsed. */
281 /* N, if this is the Nth Tuesday. */
282 long int day_ordinal;
284 /* Day of week; Sunday is 0. */
287 /* tm_isdst flag for the local zone. */
290 /* Time zone, in minutes east of UTC. */
293 /* Style used for time. */
296 /* Gregorian year, month, day, hour, minutes, seconds, and nanoseconds. */
302 struct timespec seconds; /* includes nanoseconds */
304 /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */
307 /* Presence or counts of nonterminals of various flavors parsed so far. */
312 size_t local_zones_seen;
317 /* Table of local time zone abbrevations, terminated by a null entry. */
318 table local_time_zone_table[3];
322 static int yylex (union YYSTYPE *, parser_control *);
323 static int yyerror (parser_control const *, char const *);
324 static long int time_zone_hhmm (parser_control *, textint, long int);
326 /* Extract into *PC any date and time info from a string of digits
327 of the form e.g., YYYYMMDD, YYMMDD, HHMM, HH (and sometimes YYY,
330 digits_to_date_time (parser_control *pc, textint text_int)
332 if (pc->dates_seen && ! pc->year.digits
333 && ! pc->rels_seen && (pc->times_seen || 2 < text_int.digits))
337 if (4 < text_int.digits)
340 pc->day = text_int.value % 100;
341 pc->month = (text_int.value / 100) % 100;
342 pc->year.value = text_int.value / 10000;
343 pc->year.digits = text_int.digits - 4;
348 if (text_int.digits <= 2)
350 pc->hour = text_int.value;
355 pc->hour = text_int.value / 100;
356 pc->minutes = text_int.value % 100;
358 pc->seconds.tv_sec = 0;
359 pc->seconds.tv_nsec = 0;
360 pc->meridian = MER24;
365 /* Increment PC->rel by FACTOR * REL (FACTOR is 1 or -1). */
367 apply_relative_time (parser_control *pc, relative_time rel, int factor)
369 pc->rel.ns += factor * rel.ns;
370 pc->rel.seconds += factor * rel.seconds;
371 pc->rel.minutes += factor * rel.minutes;
372 pc->rel.hour += factor * rel.hour;
373 pc->rel.day += factor * rel.day;
374 pc->rel.month += factor * rel.month;
375 pc->rel.year += factor * rel.year;
376 pc->rels_seen = true;
379 /* Set PC-> hour, minutes, seconds and nanoseconds members from arguments. */
381 set_hhmmss (parser_control *pc, long int hour, long int minutes,
382 time_t sec, long int nsec)
385 pc->minutes = minutes;
386 pc->seconds.tv_sec = sec;
387 pc->seconds.tv_nsec = nsec;
392 /* Enabling traces. */
397 /* Enabling verbose error messages. */
398 #ifdef YYERROR_VERBOSE
399 # undef YYERROR_VERBOSE
400 # define YYERROR_VERBOSE 1
402 # define YYERROR_VERBOSE 0
405 /* Enabling the token table. */
406 #ifndef YYTOKEN_TABLE
407 # define YYTOKEN_TABLE 0
410 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
411 typedef union YYSTYPE
412 #line 285 "getdate.y"
416 struct timespec timespec;
419 /* Line 187 of yacc.c. */
420 #line 421 "getdate.c"
422 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
423 # define YYSTYPE_IS_DECLARED 1
424 # define YYSTYPE_IS_TRIVIAL 1
429 /* Copy the second part of user declarations. */
432 /* Line 216 of yacc.c. */
433 #line 434 "getdate.c"
440 typedef YYTYPE_UINT8 yytype_uint8;
442 typedef unsigned char yytype_uint8;
446 typedef YYTYPE_INT8 yytype_int8;
447 #elif (defined __STDC__ || defined __C99__FUNC__ \
448 || defined __cplusplus || defined _MSC_VER)
449 typedef signed char yytype_int8;
451 typedef short int yytype_int8;
455 typedef YYTYPE_UINT16 yytype_uint16;
457 typedef unsigned short int yytype_uint16;
461 typedef YYTYPE_INT16 yytype_int16;
463 typedef short int yytype_int16;
467 # ifdef __SIZE_TYPE__
468 # define YYSIZE_T __SIZE_TYPE__
469 # elif defined size_t
470 # define YYSIZE_T size_t
471 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
472 || defined __cplusplus || defined _MSC_VER)
473 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
474 # define YYSIZE_T size_t
476 # define YYSIZE_T unsigned int
480 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
485 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
486 # define YY_(msgid) dgettext ("bison-runtime", msgid)
490 # define YY_(msgid) msgid
494 /* Suppress unused-variable warnings by "using" E. */
495 #if ! defined lint || defined __GNUC__
496 # define YYUSE(e) ((void) (e))
498 # define YYUSE(e) /* empty */
501 /* Identity function, used to suppress warnings about constant conditions. */
505 #if (defined __STDC__ || defined __C99__FUNC__ \
506 || defined __cplusplus || defined _MSC_VER)
519 #if ! defined yyoverflow || YYERROR_VERBOSE
521 /* The parser invokes alloca or malloc; define the necessary symbols. */
523 # ifdef YYSTACK_USE_ALLOCA
524 # if YYSTACK_USE_ALLOCA
526 # define YYSTACK_ALLOC __builtin_alloca
527 # elif defined __BUILTIN_VA_ARG_INCR
528 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
530 # define YYSTACK_ALLOC __alloca
531 # elif defined _MSC_VER
532 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
533 # define alloca _alloca
535 # define YYSTACK_ALLOC alloca
536 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
537 || defined __cplusplus || defined _MSC_VER)
538 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
547 # ifdef YYSTACK_ALLOC
548 /* Pacify GCC's `empty if-body' warning. */
549 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
550 # ifndef YYSTACK_ALLOC_MAXIMUM
551 /* The OS might guarantee only one guard page at the bottom of the stack,
552 and a page size can be as small as 4096 bytes. So we cannot safely
553 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
554 to allow for a few compiler-allocated temporary stack slots. */
555 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
558 # define YYSTACK_ALLOC YYMALLOC
559 # define YYSTACK_FREE YYFREE
560 # ifndef YYSTACK_ALLOC_MAXIMUM
561 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
563 # if (defined __cplusplus && ! defined _STDLIB_H \
564 && ! ((defined YYMALLOC || defined malloc) \
565 && (defined YYFREE || defined free)))
566 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
572 # define YYMALLOC malloc
573 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
574 || defined __cplusplus || defined _MSC_VER)
575 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
580 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
581 || defined __cplusplus || defined _MSC_VER)
582 void free (void *); /* INFRINGES ON USER NAME SPACE */
586 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
589 #if (! defined yyoverflow \
590 && (! defined __cplusplus \
591 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
593 /* A type that is properly aligned for any stack member. */
600 /* The size of the maximum gap between one aligned stack and the next. */
601 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
603 /* The size of an array large to enough to hold all stacks, each with
605 # define YYSTACK_BYTES(N) \
606 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
607 + YYSTACK_GAP_MAXIMUM)
609 /* Copy COUNT objects from FROM to TO. The source and destination do
612 # if defined __GNUC__ && 1 < __GNUC__
613 # define YYCOPY(To, From, Count) \
614 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
616 # define YYCOPY(To, From, Count) \
620 for (yyi = 0; yyi < (Count); yyi++) \
621 (To)[yyi] = (From)[yyi]; \
627 /* Relocate STACK from its old location to the new one. The
628 local variables YYSIZE and YYSTACKSIZE give the old and new number of
629 elements in the stack, and YYPTR gives the new location of the
630 stack. Advance YYPTR to a properly aligned location for the next
632 # define YYSTACK_RELOCATE(Stack) \
635 YYSIZE_T yynewbytes; \
636 YYCOPY (&yyptr->Stack, Stack, yysize); \
637 Stack = &yyptr->Stack; \
638 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
639 yyptr += yynewbytes / sizeof (*yyptr); \
645 /* YYFINAL -- State number of the termination state. */
647 /* YYLAST -- Last index in YYTABLE. */
650 /* YYNTOKENS -- Number of terminals. */
652 /* YYNNTS -- Number of nonterminals. */
654 /* YYNRULES -- Number of rules. */
656 /* YYNRULES -- Number of states. */
657 #define YYNSTATES 100
659 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
661 #define YYMAXUTOK 277
663 #define YYTRANSLATE(YYX) \
664 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
666 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
667 static const yytype_uint8 yytranslate[] =
669 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
670 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
671 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
672 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
673 2, 2, 2, 2, 25, 2, 2, 26, 2, 2,
674 2, 2, 2, 2, 2, 2, 2, 2, 24, 2,
675 2, 2, 2, 2, 23, 2, 2, 2, 2, 2,
676 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
677 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
678 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
679 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
680 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
694 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
695 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
696 15, 16, 17, 18, 19, 20, 21, 22
700 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
702 static const yytype_uint8 yyprhs[] =
704 0, 0, 3, 5, 7, 10, 11, 14, 16, 18,
705 20, 22, 24, 26, 28, 30, 33, 38, 44, 51,
706 59, 61, 64, 66, 69, 73, 75, 78, 80, 83,
707 86, 89, 93, 99, 103, 107, 111, 114, 119, 122,
708 126, 129, 131, 133, 136, 139, 141, 144, 147, 149,
709 152, 155, 157, 160, 163, 165, 168, 171, 173, 176,
710 179, 182, 185, 187, 189, 192, 195, 198, 201, 204,
711 207, 209, 211, 213, 215, 217, 219, 221, 223, 226,
715 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
716 static const yytype_int8 yyrhs[] =
718 28, 0, -1, 29, -1, 30, -1, 23, 41, -1,
719 -1, 30, 31, -1, 32, -1, 33, -1, 34, -1,
720 36, -1, 35, -1, 37, -1, 44, -1, 45, -1,
721 20, 15, -1, 20, 24, 20, 47, -1, 20, 24,
722 20, 19, 46, -1, 20, 24, 20, 24, 43, 47,
723 -1, 20, 24, 20, 24, 43, 19, 46, -1, 14,
724 -1, 14, 4, -1, 18, -1, 18, 39, -1, 18,
725 19, 46, -1, 13, -1, 18, 4, -1, 12, -1,
726 12, 25, -1, 17, 12, -1, 20, 12, -1, 20,
727 26, 20, -1, 20, 26, 20, 26, 20, -1, 20,
728 19, 19, -1, 20, 16, 19, -1, 16, 19, 19,
729 -1, 16, 20, -1, 16, 20, 25, 20, -1, 20,
730 16, -1, 20, 16, 20, -1, 38, 3, -1, 38,
731 -1, 40, -1, 17, 5, -1, 20, 5, -1, 5,
732 -1, 17, 6, -1, 20, 6, -1, 6, -1, 17,
733 10, -1, 20, 10, -1, 10, -1, 17, 7, -1,
734 20, 7, -1, 7, -1, 17, 8, -1, 20, 8,
735 -1, 8, -1, 17, 9, -1, 20, 9, -1, 21,
736 9, -1, 22, 9, -1, 9, -1, 39, -1, 19,
737 5, -1, 19, 6, -1, 19, 10, -1, 19, 7,
738 -1, 19, 8, -1, 19, 9, -1, 11, -1, 42,
739 -1, 43, -1, 21, -1, 19, -1, 22, -1, 20,
740 -1, 20, -1, 20, 39, -1, -1, 24, 20, -1,
744 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
745 static const yytype_uint16 yyrline[] =
747 0, 311, 311, 312, 316, 323, 325, 329, 331, 333,
748 335, 337, 339, 340, 341, 345, 350, 355, 362, 367,
749 377, 382, 390, 392, 395, 397, 399, 404, 409, 414,
750 419, 427, 432, 452, 459, 467, 475, 480, 486, 491,
751 500, 502, 504, 509, 511, 513, 515, 517, 519, 521,
752 523, 525, 527, 529, 531, 533, 535, 537, 539, 541,
753 543, 545, 547, 549, 553, 555, 557, 559, 561, 563,
754 568, 572, 572, 575, 576, 581, 582, 587, 592, 603,
759 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
760 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
761 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
762 static const char *const yytname[] =
764 "$end", "error", "$undefined", "tAGO", "tDST", "tYEAR_UNIT",
765 "tMONTH_UNIT", "tHOUR_UNIT", "tMINUTE_UNIT", "tSEC_UNIT", "tDAY_UNIT",
766 "tDAY_SHIFT", "tDAY", "tDAYZONE", "tLOCAL_ZONE", "tMERIDIAN", "tMONTH",
767 "tORDINAL", "tZONE", "tSNUMBER", "tUNUMBER", "tSDECIMAL_NUMBER",
768 "tUDECIMAL_NUMBER", "'@'", "':'", "','", "'/'", "$accept", "spec",
769 "timespec", "items", "item", "time", "local_zone", "zone", "day", "date",
770 "rel", "relunit", "relunit_snumber", "dayshift", "seconds",
771 "signed_seconds", "unsigned_seconds", "number", "hybrid",
772 "o_colon_minutes", "o_merid", 0
777 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
779 static const yytype_uint16 yytoknum[] =
781 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
782 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
783 275, 276, 277, 64, 58, 44, 47
787 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
788 static const yytype_uint8 yyr1[] =
790 0, 27, 28, 28, 29, 30, 30, 31, 31, 31,
791 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
792 33, 33, 34, 34, 34, 34, 34, 35, 35, 35,
793 35, 36, 36, 36, 36, 36, 36, 36, 36, 36,
794 37, 37, 37, 38, 38, 38, 38, 38, 38, 38,
795 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
796 38, 38, 38, 38, 39, 39, 39, 39, 39, 39,
797 40, 41, 41, 42, 42, 43, 43, 44, 45, 46,
801 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
802 static const yytype_uint8 yyr2[] =
804 0, 2, 1, 1, 2, 0, 2, 1, 1, 1,
805 1, 1, 1, 1, 1, 2, 4, 5, 6, 7,
806 1, 2, 1, 2, 3, 1, 2, 1, 2, 2,
807 2, 3, 5, 3, 3, 3, 2, 4, 2, 3,
808 2, 1, 1, 2, 2, 1, 2, 2, 1, 2,
809 2, 1, 2, 2, 1, 2, 2, 1, 2, 2,
810 2, 2, 1, 1, 2, 2, 2, 2, 2, 2,
811 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
815 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
816 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
817 means the default is an error. */
818 static const yytype_uint8 yydefact[] =
820 5, 0, 0, 2, 3, 74, 76, 73, 75, 4,
821 71, 72, 1, 45, 48, 54, 57, 62, 51, 70,
822 27, 25, 20, 0, 0, 22, 0, 77, 0, 0,
823 6, 7, 8, 9, 11, 10, 12, 41, 63, 42,
824 13, 14, 28, 21, 0, 36, 43, 46, 52, 55,
825 58, 49, 29, 26, 79, 23, 64, 65, 67, 68,
826 69, 66, 44, 47, 53, 56, 59, 50, 30, 15,
827 38, 0, 0, 0, 78, 60, 61, 40, 35, 0,
828 0, 24, 34, 39, 33, 81, 31, 37, 80, 82,
829 79, 0, 16, 0, 17, 81, 32, 79, 18, 19
832 /* YYDEFGOTO[NTERM-NUM]. */
833 static const yytype_int8 yydefgoto[] =
835 -1, 2, 3, 4, 30, 31, 32, 33, 34, 35,
836 36, 37, 38, 39, 9, 10, 11, 40, 41, 81,
840 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
842 #define YYPACT_NINF -82
843 static const yytype_int8 yypact[] =
845 -17, 56, 15, -82, 26, -82, -82, -82, -82, -82,
846 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
847 36, -82, 68, 10, 50, 9, 59, -5, 72, 73,
848 -82, -82, -82, -82, -82, -82, -82, 80, -82, -82,
849 -82, -82, -82, -82, 65, 61, -82, -82, -82, -82,
850 -82, -82, -82, -82, 17, -82, -82, -82, -82, -82,
851 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
852 60, 44, 67, 69, -82, -82, -82, -82, -82, 70,
853 71, -82, -82, -82, -82, -7, 62, -82, -82, -82,
854 74, -2, -82, 75, -82, 55, -82, 74, -82, -82
857 /* YYPGOTO[NTERM-NUM]. */
858 static const yytype_int8 yypgoto[] =
860 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
861 -82, -82, 46, -82, -82, -82, -6, -82, -82, -81,
865 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
866 positive, shift that token. If negative, reduce the rule which
867 number is the opposite. If zero, do what YYDEFACT says.
868 If YYTABLE_NINF, syntax error. */
869 #define YYTABLE_NINF -1
870 static const yytype_uint8 yytable[] =
872 62, 63, 64, 65, 66, 67, 1, 68, 89, 94,
873 69, 70, 90, 53, 71, 12, 99, 91, 6, 72,
874 8, 73, 56, 57, 58, 59, 60, 61, 54, 44,
875 45, 13, 14, 15, 16, 17, 18, 19, 20, 21,
876 22, 80, 23, 24, 25, 26, 27, 28, 29, 56,
877 57, 58, 59, 60, 61, 46, 47, 48, 49, 50,
878 51, 42, 52, 84, 56, 57, 58, 59, 60, 61,
879 89, 55, 43, 74, 97, 5, 6, 7, 8, 82,
880 83, 75, 76, 77, 78, 95, 79, 85, 93, 86,
881 87, 88, 98, 0, 0, 96, 0, 0, 80
884 static const yytype_int8 yycheck[] =
886 5, 6, 7, 8, 9, 10, 23, 12, 15, 90,
887 15, 16, 19, 4, 19, 0, 97, 24, 20, 24,
888 22, 26, 5, 6, 7, 8, 9, 10, 19, 19,
889 20, 5, 6, 7, 8, 9, 10, 11, 12, 13,
890 14, 24, 16, 17, 18, 19, 20, 21, 22, 5,
891 6, 7, 8, 9, 10, 5, 6, 7, 8, 9,
892 10, 25, 12, 19, 5, 6, 7, 8, 9, 10,
893 15, 25, 4, 27, 19, 19, 20, 21, 22, 19,
894 20, 9, 9, 3, 19, 91, 25, 20, 26, 20,
895 20, 20, 95, -1, -1, 20, -1, -1, 24
898 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
899 symbol of state STATE-NUM. */
900 static const yytype_uint8 yystos[] =
902 0, 23, 28, 29, 30, 19, 20, 21, 22, 41,
903 42, 43, 0, 5, 6, 7, 8, 9, 10, 11,
904 12, 13, 14, 16, 17, 18, 19, 20, 21, 22,
905 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
906 44, 45, 25, 4, 19, 20, 5, 6, 7, 8,
907 9, 10, 12, 4, 19, 39, 5, 6, 7, 8,
908 9, 10, 5, 6, 7, 8, 9, 10, 12, 15,
909 16, 19, 24, 26, 39, 9, 9, 3, 19, 25,
910 24, 46, 19, 20, 19, 20, 20, 20, 20, 15,
911 19, 24, 47, 26, 46, 43, 20, 19, 47, 46
914 #define yyerrok (yyerrstatus = 0)
915 #define yyclearin (yychar = YYEMPTY)
919 #define YYACCEPT goto yyacceptlab
920 #define YYABORT goto yyabortlab
921 #define YYERROR goto yyerrorlab
924 /* Like YYERROR except do call yyerror. This remains here temporarily
925 to ease the transition to the new meaning of YYERROR, for GCC.
926 Once GCC version 2 has supplanted version 1, this can go. */
928 #define YYFAIL goto yyerrlab
930 #define YYRECOVERING() (!!yyerrstatus)
932 #define YYBACKUP(Token, Value) \
934 if (yychar == YYEMPTY && yylen == 1) \
938 yytoken = YYTRANSLATE (yychar); \
944 yyerror (pc, YY_("syntax error: cannot back up")); \
951 #define YYERRCODE 256
954 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
955 If N is 0, then set CURRENT to the empty location which ends
956 the previous symbol: RHS[0] (always defined). */
958 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
959 #ifndef YYLLOC_DEFAULT
960 # define YYLLOC_DEFAULT(Current, Rhs, N) \
964 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
965 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
966 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
967 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
971 (Current).first_line = (Current).last_line = \
972 YYRHSLOC (Rhs, 0).last_line; \
973 (Current).first_column = (Current).last_column = \
974 YYRHSLOC (Rhs, 0).last_column; \
980 /* YY_LOCATION_PRINT -- Print the location on the stream.
981 This macro was not mandated originally: define only if we know
982 we won't break user code: when these are the locations we know. */
984 #ifndef YY_LOCATION_PRINT
985 # if YYLTYPE_IS_TRIVIAL
986 # define YY_LOCATION_PRINT(File, Loc) \
987 fprintf (File, "%d.%d-%d.%d", \
988 (Loc).first_line, (Loc).first_column, \
989 (Loc).last_line, (Loc).last_column)
991 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
996 /* YYLEX -- calling `yylex' with the right arguments. */
999 # define YYLEX yylex (&yylval, YYLEX_PARAM)
1001 # define YYLEX yylex (&yylval, pc)
1004 /* Enable debugging if requested. */
1008 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1009 # define YYFPRINTF fprintf
1012 # define YYDPRINTF(Args) \
1018 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1022 YYFPRINTF (stderr, "%s ", Title); \
1023 yy_symbol_print (stderr, \
1025 YYFPRINTF (stderr, "\n"); \
1030 /*--------------------------------.
1031 | Print this symbol on YYOUTPUT. |
1032 `--------------------------------*/
1035 #if (defined __STDC__ || defined __C99__FUNC__ \
1036 || defined __cplusplus || defined _MSC_VER)
1038 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc)
1041 yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc)
1044 YYSTYPE const * const yyvaluep;
1052 if (yytype < YYNTOKENS)
1053 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1065 /*--------------------------------.
1066 | Print this symbol on YYOUTPUT. |
1067 `--------------------------------*/
1069 #if (defined __STDC__ || defined __C99__FUNC__ \
1070 || defined __cplusplus || defined _MSC_VER)
1072 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc)
1075 yy_symbol_print (yyoutput, yytype, yyvaluep, pc)
1078 YYSTYPE const * const yyvaluep;
1082 if (yytype < YYNTOKENS)
1083 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1085 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1087 yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc);
1088 YYFPRINTF (yyoutput, ")");
1091 /*------------------------------------------------------------------.
1092 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1094 `------------------------------------------------------------------*/
1096 #if (defined __STDC__ || defined __C99__FUNC__ \
1097 || defined __cplusplus || defined _MSC_VER)
1099 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
1102 yy_stack_print (bottom, top)
1103 yytype_int16 *bottom;
1107 YYFPRINTF (stderr, "Stack now");
1108 for (; bottom <= top; ++bottom)
1109 YYFPRINTF (stderr, " %d", *bottom);
1110 YYFPRINTF (stderr, "\n");
1113 # define YY_STACK_PRINT(Bottom, Top) \
1116 yy_stack_print ((Bottom), (Top)); \
1120 /*------------------------------------------------.
1121 | Report that the YYRULE is going to be reduced. |
1122 `------------------------------------------------*/
1124 #if (defined __STDC__ || defined __C99__FUNC__ \
1125 || defined __cplusplus || defined _MSC_VER)
1127 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parser_control *pc)
1130 yy_reduce_print (yyvsp, yyrule, pc)
1136 int yynrhs = yyr2[yyrule];
1138 unsigned long int yylno = yyrline[yyrule];
1139 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1141 /* The symbols being reduced. */
1142 for (yyi = 0; yyi < yynrhs; yyi++)
1144 fprintf (stderr, " $%d = ", yyi + 1);
1145 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1146 &(yyvsp[(yyi + 1) - (yynrhs)])
1148 fprintf (stderr, "\n");
1152 # define YY_REDUCE_PRINT(Rule) \
1155 yy_reduce_print (yyvsp, Rule, pc); \
1158 /* Nonzero means print parse trace. It is left uninitialized so that
1159 multiple parsers can coexist. */
1161 #else /* !YYDEBUG */
1162 # define YYDPRINTF(Args)
1163 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1164 # define YY_STACK_PRINT(Bottom, Top)
1165 # define YY_REDUCE_PRINT(Rule)
1166 #endif /* !YYDEBUG */
1169 /* YYINITDEPTH -- initial size of the parser's stacks. */
1171 # define YYINITDEPTH 200
1174 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1175 if the built-in stack extension method is used).
1177 Do not make this value too large; the results are undefined if
1178 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1179 evaluated with infinite-precision integer arithmetic. */
1182 # define YYMAXDEPTH 10000
1190 # if defined __GLIBC__ && defined _STRING_H
1191 # define yystrlen strlen
1193 /* Return the length of YYSTR. */
1194 #if (defined __STDC__ || defined __C99__FUNC__ \
1195 || defined __cplusplus || defined _MSC_VER)
1197 yystrlen (const char *yystr)
1205 for (yylen = 0; yystr[yylen]; yylen++)
1213 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1214 # define yystpcpy stpcpy
1216 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1218 #if (defined __STDC__ || defined __C99__FUNC__ \
1219 || defined __cplusplus || defined _MSC_VER)
1221 yystpcpy (char *yydest, const char *yysrc)
1224 yystpcpy (yydest, yysrc)
1230 const char *yys = yysrc;
1232 while ((*yyd++ = *yys++) != '\0')
1241 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1242 quotes and backslashes, so that it's suitable for yyerror. The
1243 heuristic is that double-quoting is unnecessary unless the string
1244 contains an apostrophe, a comma, or backslash (other than
1245 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1246 null, do not copy; instead, return the length of what the result
1249 yytnamerr (char *yyres, const char *yystr)
1254 char const *yyp = yystr;
1261 goto do_not_strip_quotes;
1265 goto do_not_strip_quotes;
1278 do_not_strip_quotes: ;
1282 return yystrlen (yystr);
1284 return yystpcpy (yyres, yystr) - yyres;
1288 /* Copy into YYRESULT an error message about the unexpected token
1289 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1290 including the terminating null byte. If YYRESULT is null, do not
1291 copy anything; just return the number of bytes that would be
1292 copied. As a special case, return 0 if an ordinary "syntax error"
1293 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1294 size calculation. */
1296 yysyntax_error (char *yyresult, int yystate, int yychar)
1298 int yyn = yypact[yystate];
1300 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1304 int yytype = YYTRANSLATE (yychar);
1305 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1306 YYSIZE_T yysize = yysize0;
1308 int yysize_overflow = 0;
1309 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1310 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1314 /* This is so xgettext sees the translatable formats that are
1315 constructed on the fly. */
1316 YY_("syntax error, unexpected %s");
1317 YY_("syntax error, unexpected %s, expecting %s");
1318 YY_("syntax error, unexpected %s, expecting %s or %s");
1319 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1320 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1324 static char const yyunexpected[] = "syntax error, unexpected %s";
1325 static char const yyexpecting[] = ", expecting %s";
1326 static char const yyor[] = " or %s";
1327 char yyformat[sizeof yyunexpected
1328 + sizeof yyexpecting - 1
1329 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1330 * (sizeof yyor - 1))];
1331 char const *yyprefix = yyexpecting;
1333 /* Start YYX at -YYN if negative to avoid negative indexes in
1335 int yyxbegin = yyn < 0 ? -yyn : 0;
1337 /* Stay within bounds of both yycheck and yytname. */
1338 int yychecklim = YYLAST - yyn + 1;
1339 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1342 yyarg[0] = yytname[yytype];
1343 yyfmt = yystpcpy (yyformat, yyunexpected);
1345 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1346 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1348 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1352 yyformat[sizeof yyunexpected - 1] = '\0';
1355 yyarg[yycount++] = yytname[yyx];
1356 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1357 yysize_overflow |= (yysize1 < yysize);
1359 yyfmt = yystpcpy (yyfmt, yyprefix);
1363 yyf = YY_(yyformat);
1364 yysize1 = yysize + yystrlen (yyf);
1365 yysize_overflow |= (yysize1 < yysize);
1368 if (yysize_overflow)
1369 return YYSIZE_MAXIMUM;
1373 /* Avoid sprintf, as that infringes on the user's name space.
1374 Don't have undefined behavior even if the translation
1375 produced a string with the wrong number of "%s"s. */
1376 char *yyp = yyresult;
1378 while ((*yyp = *yyf) != '\0')
1380 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1382 yyp += yytnamerr (yyp, yyarg[yyi++]);
1395 #endif /* YYERROR_VERBOSE */
1398 /*-----------------------------------------------.
1399 | Release the memory associated to this symbol. |
1400 `-----------------------------------------------*/
1403 #if (defined __STDC__ || defined __C99__FUNC__ \
1404 || defined __cplusplus || defined _MSC_VER)
1406 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parser_control *pc)
1409 yydestruct (yymsg, yytype, yyvaluep, pc)
1421 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1432 /* Prevent warnings from -Wmissing-prototypes. */
1434 #ifdef YYPARSE_PARAM
1435 #if defined __STDC__ || defined __cplusplus
1436 int yyparse (void *YYPARSE_PARAM);
1440 #else /* ! YYPARSE_PARAM */
1441 #if defined __STDC__ || defined __cplusplus
1442 int yyparse (parser_control *pc);
1446 #endif /* ! YYPARSE_PARAM */
1457 #ifdef YYPARSE_PARAM
1458 #if (defined __STDC__ || defined __C99__FUNC__ \
1459 || defined __cplusplus || defined _MSC_VER)
1461 yyparse (void *YYPARSE_PARAM)
1464 yyparse (YYPARSE_PARAM)
1465 void *YYPARSE_PARAM;
1467 #else /* ! YYPARSE_PARAM */
1468 #if (defined __STDC__ || defined __C99__FUNC__ \
1469 || defined __cplusplus || defined _MSC_VER)
1471 yyparse (parser_control *pc)
1479 /* The look-ahead symbol. */
1482 /* The semantic value of the look-ahead symbol. */
1485 /* Number of syntax errors so far. */
1491 /* Number of tokens to shift before error messages enabled. */
1493 /* Look-ahead token as an internal (translated) token number. */
1496 /* Buffer for error messages, and its allocated size. */
1498 char *yymsg = yymsgbuf;
1499 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1502 /* Three stacks and their tools:
1503 `yyss': related to states,
1504 `yyvs': related to semantic values,
1505 `yyls': related to locations.
1507 Refer to the stacks thru separate pointers, to allow yyoverflow
1508 to reallocate them elsewhere. */
1510 /* The state stack. */
1511 yytype_int16 yyssa[YYINITDEPTH];
1512 yytype_int16 *yyss = yyssa;
1513 yytype_int16 *yyssp;
1515 /* The semantic value stack. */
1516 YYSTYPE yyvsa[YYINITDEPTH];
1517 YYSTYPE *yyvs = yyvsa;
1522 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1524 YYSIZE_T yystacksize = YYINITDEPTH;
1526 /* The variables used to return semantic value and location from the
1531 /* The number of symbols on the RHS of the reduced rule.
1532 Keep to zero when no symbol should be popped. */
1535 YYDPRINTF ((stderr, "Starting parse\n"));
1540 yychar = YYEMPTY; /* Cause a token to be read. */
1542 /* Initialize stack pointers.
1543 Waste one element of value and location stack
1544 so that they stay on the same level as the state stack.
1545 The wasted elements are never initialized. */
1552 /*------------------------------------------------------------.
1553 | yynewstate -- Push a new state, which is found in yystate. |
1554 `------------------------------------------------------------*/
1556 /* In all cases, when you get here, the value and location stacks
1557 have just been pushed. So pushing a state here evens the stacks. */
1563 if (yyss + yystacksize - 1 <= yyssp)
1565 /* Get the current used size of the three stacks, in elements. */
1566 YYSIZE_T yysize = yyssp - yyss + 1;
1570 /* Give user a chance to reallocate the stack. Use copies of
1571 these so that the &'s don't force the real ones into
1573 YYSTYPE *yyvs1 = yyvs;
1574 yytype_int16 *yyss1 = yyss;
1577 /* Each stack pointer address is followed by the size of the
1578 data in use in that stack, in bytes. This used to be a
1579 conditional around just the two extra args, but that might
1580 be undefined if yyoverflow is a macro. */
1581 yyoverflow (YY_("memory exhausted"),
1582 &yyss1, yysize * sizeof (*yyssp),
1583 &yyvs1, yysize * sizeof (*yyvsp),
1590 #else /* no yyoverflow */
1591 # ifndef YYSTACK_RELOCATE
1592 goto yyexhaustedlab;
1594 /* Extend the stack our own way. */
1595 if (YYMAXDEPTH <= yystacksize)
1596 goto yyexhaustedlab;
1598 if (YYMAXDEPTH < yystacksize)
1599 yystacksize = YYMAXDEPTH;
1602 yytype_int16 *yyss1 = yyss;
1603 union yyalloc *yyptr =
1604 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1606 goto yyexhaustedlab;
1607 YYSTACK_RELOCATE (yyss);
1608 YYSTACK_RELOCATE (yyvs);
1610 # undef YYSTACK_RELOCATE
1612 YYSTACK_FREE (yyss1);
1615 #endif /* no yyoverflow */
1617 yyssp = yyss + yysize - 1;
1618 yyvsp = yyvs + yysize - 1;
1621 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1622 (unsigned long int) yystacksize));
1624 if (yyss + yystacksize - 1 <= yyssp)
1628 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1637 /* Do appropriate processing given the current state. Read a
1638 look-ahead token if we need one and don't already have one. */
1640 /* First try to decide what to do without reference to look-ahead token. */
1641 yyn = yypact[yystate];
1642 if (yyn == YYPACT_NINF)
1645 /* Not known => get a look-ahead token if don't already have one. */
1647 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1648 if (yychar == YYEMPTY)
1650 YYDPRINTF ((stderr, "Reading a token: "));
1654 if (yychar <= YYEOF)
1656 yychar = yytoken = YYEOF;
1657 YYDPRINTF ((stderr, "Now at end of input.\n"));
1661 yytoken = YYTRANSLATE (yychar);
1662 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1665 /* If the proper action on seeing token YYTOKEN is to reduce or to
1666 detect an error, take that action. */
1668 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1673 if (yyn == 0 || yyn == YYTABLE_NINF)
1682 /* Count tokens shifted since error; after three, turn off error
1687 /* Shift the look-ahead token. */
1688 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1690 /* Discard the shifted token unless it is eof. */
1691 if (yychar != YYEOF)
1700 /*-----------------------------------------------------------.
1701 | yydefault -- do the default action for the current state. |
1702 `-----------------------------------------------------------*/
1704 yyn = yydefact[yystate];
1710 /*-----------------------------.
1711 | yyreduce -- Do a reduction. |
1712 `-----------------------------*/
1714 /* yyn is the number of a rule to reduce with. */
1717 /* If YYLEN is nonzero, implement the default value of the action:
1720 Otherwise, the following line sets YYVAL to garbage.
1721 This behavior is undocumented and Bison
1722 users should not rely upon it. Assigning to YYVAL
1723 unconditionally makes the parser a bit smaller, and it avoids a
1724 GCC warning that YYVAL may be used uninitialized. */
1725 yyval = yyvsp[1-yylen];
1728 YY_REDUCE_PRINT (yyn);
1732 #line 317 "getdate.y"
1734 pc->seconds = (yyvsp[(2) - (2)].timespec);
1735 pc->timespec_seen = true;
1740 #line 330 "getdate.y"
1741 { pc->times_seen++; }
1745 #line 332 "getdate.y"
1746 { pc->local_zones_seen++; }
1750 #line 334 "getdate.y"
1751 { pc->zones_seen++; }
1755 #line 336 "getdate.y"
1756 { pc->dates_seen++; }
1760 #line 338 "getdate.y"
1761 { pc->days_seen++; }
1765 #line 346 "getdate.y"
1767 set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0);
1768 pc->meridian = (yyvsp[(2) - (2)].intval);
1773 #line 351 "getdate.y"
1775 set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0);
1776 pc->meridian = (yyvsp[(4) - (4)].intval);
1781 #line 356 "getdate.y"
1783 set_hhmmss (pc, (yyvsp[(1) - (5)].textintval).value, (yyvsp[(3) - (5)].textintval).value, 0, 0);
1784 pc->meridian = MER24;
1786 pc->time_zone = time_zone_hhmm (pc, (yyvsp[(4) - (5)].textintval), (yyvsp[(5) - (5)].intval));
1791 #line 363 "getdate.y"
1793 set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec);
1794 pc->meridian = (yyvsp[(6) - (6)].intval);
1799 #line 368 "getdate.y"
1801 set_hhmmss (pc, (yyvsp[(1) - (7)].textintval).value, (yyvsp[(3) - (7)].textintval).value, (yyvsp[(5) - (7)].timespec).tv_sec, (yyvsp[(5) - (7)].timespec).tv_nsec);
1802 pc->meridian = MER24;
1804 pc->time_zone = time_zone_hhmm (pc, (yyvsp[(6) - (7)].textintval), (yyvsp[(7) - (7)].intval));
1809 #line 378 "getdate.y"
1811 pc->local_isdst = (yyvsp[(1) - (1)].intval);
1812 pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval));
1817 #line 383 "getdate.y"
1819 pc->local_isdst = 1;
1820 pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1;
1825 #line 391 "getdate.y"
1826 { pc->time_zone = (yyvsp[(1) - (1)].intval); }
1830 #line 393 "getdate.y"
1831 { pc->time_zone = (yyvsp[(1) - (2)].intval);
1832 apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); }
1836 #line 396 "getdate.y"
1837 { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm (pc, (yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); }
1841 #line 398 "getdate.y"
1842 { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; }
1846 #line 400 "getdate.y"
1847 { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; }
1851 #line 405 "getdate.y"
1853 pc->day_ordinal = 0;
1854 pc->day_number = (yyvsp[(1) - (1)].intval);
1859 #line 410 "getdate.y"
1861 pc->day_ordinal = 0;
1862 pc->day_number = (yyvsp[(1) - (2)].intval);
1867 #line 415 "getdate.y"
1869 pc->day_ordinal = (yyvsp[(1) - (2)].intval);
1870 pc->day_number = (yyvsp[(2) - (2)].intval);
1875 #line 420 "getdate.y"
1877 pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value;
1878 pc->day_number = (yyvsp[(2) - (2)].intval);
1883 #line 428 "getdate.y"
1885 pc->month = (yyvsp[(1) - (3)].textintval).value;
1886 pc->day = (yyvsp[(3) - (3)].textintval).value;
1891 #line 433 "getdate.y"
1893 /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
1894 otherwise as MM/DD/YY.
1895 The goal in recognizing YYYY/MM/DD is solely to support legacy
1896 machine-generated dates like those in an RCS log listing. If
1897 you want portability, use the ISO 8601 format. */
1898 if (4 <= (yyvsp[(1) - (5)].textintval).digits)
1900 pc->year = (yyvsp[(1) - (5)].textintval);
1901 pc->month = (yyvsp[(3) - (5)].textintval).value;
1902 pc->day = (yyvsp[(5) - (5)].textintval).value;
1906 pc->month = (yyvsp[(1) - (5)].textintval).value;
1907 pc->day = (yyvsp[(3) - (5)].textintval).value;
1908 pc->year = (yyvsp[(5) - (5)].textintval);
1914 #line 453 "getdate.y"
1916 /* ISO 8601 format. YYYY-MM-DD. */
1917 pc->year = (yyvsp[(1) - (3)].textintval);
1918 pc->month = -(yyvsp[(2) - (3)].textintval).value;
1919 pc->day = -(yyvsp[(3) - (3)].textintval).value;
1924 #line 460 "getdate.y"
1926 /* e.g. 17-JUN-1992. */
1927 pc->day = (yyvsp[(1) - (3)].textintval).value;
1928 pc->month = (yyvsp[(2) - (3)].intval);
1929 pc->year.value = -(yyvsp[(3) - (3)].textintval).value;
1930 pc->year.digits = (yyvsp[(3) - (3)].textintval).digits;
1935 #line 468 "getdate.y"
1937 /* e.g. JUN-17-1992. */
1938 pc->month = (yyvsp[(1) - (3)].intval);
1939 pc->day = -(yyvsp[(2) - (3)].textintval).value;
1940 pc->year.value = -(yyvsp[(3) - (3)].textintval).value;
1941 pc->year.digits = (yyvsp[(3) - (3)].textintval).digits;
1946 #line 476 "getdate.y"
1948 pc->month = (yyvsp[(1) - (2)].intval);
1949 pc->day = (yyvsp[(2) - (2)].textintval).value;
1954 #line 481 "getdate.y"
1956 pc->month = (yyvsp[(1) - (4)].intval);
1957 pc->day = (yyvsp[(2) - (4)].textintval).value;
1958 pc->year = (yyvsp[(4) - (4)].textintval);
1963 #line 487 "getdate.y"
1965 pc->day = (yyvsp[(1) - (2)].textintval).value;
1966 pc->month = (yyvsp[(2) - (2)].intval);
1971 #line 492 "getdate.y"
1973 pc->day = (yyvsp[(1) - (3)].textintval).value;
1974 pc->month = (yyvsp[(2) - (3)].intval);
1975 pc->year = (yyvsp[(3) - (3)].textintval);
1980 #line 501 "getdate.y"
1981 { apply_relative_time (pc, (yyvsp[(1) - (2)].rel), -1); }
1985 #line 503 "getdate.y"
1986 { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); }
1990 #line 505 "getdate.y"
1991 { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); }
1995 #line 510 "getdate.y"
1996 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].intval); }
2000 #line 512 "getdate.y"
2001 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; }
2005 #line 514 "getdate.y"
2006 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = 1; }
2010 #line 516 "getdate.y"
2011 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].intval); }
2015 #line 518 "getdate.y"
2016 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; }
2020 #line 520 "getdate.y"
2021 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = 1; }
2025 #line 522 "getdate.y"
2026 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); }
2030 #line 524 "getdate.y"
2031 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); }
2035 #line 526 "getdate.y"
2036 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); }
2040 #line 528 "getdate.y"
2041 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].intval); }
2045 #line 530 "getdate.y"
2046 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; }
2050 #line 532 "getdate.y"
2051 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = 1; }
2055 #line 534 "getdate.y"
2056 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].intval); }
2060 #line 536 "getdate.y"
2061 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; }
2065 #line 538 "getdate.y"
2066 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = 1; }
2070 #line 540 "getdate.y"
2071 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].intval); }
2075 #line 542 "getdate.y"
2076 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; }
2080 #line 544 "getdate.y"
2081 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; }
2085 #line 546 "getdate.y"
2086 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; }
2090 #line 548 "getdate.y"
2091 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = 1; }
2095 #line 554 "getdate.y"
2096 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; }
2100 #line 556 "getdate.y"
2101 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; }
2105 #line 558 "getdate.y"
2106 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); }
2110 #line 560 "getdate.y"
2111 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; }
2115 #line 562 "getdate.y"
2116 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; }
2120 #line 564 "getdate.y"
2121 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; }
2125 #line 569 "getdate.y"
2126 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); }
2130 #line 577 "getdate.y"
2131 { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; }
2135 #line 583 "getdate.y"
2136 { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; }
2140 #line 588 "getdate.y"
2141 { digits_to_date_time (pc, (yyvsp[(1) - (1)].textintval)); }
2145 #line 593 "getdate.y"
2147 /* Hybrid all-digit and relative offset, so that we accept e.g.,
2148 "YYYYMMDD +N days" as well as "YYYYMMDD N days". */
2149 digits_to_date_time (pc, (yyvsp[(1) - (2)].textintval));
2150 apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1);
2155 #line 603 "getdate.y"
2156 { (yyval.intval) = -1; }
2160 #line 605 "getdate.y"
2161 { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; }
2165 #line 610 "getdate.y"
2166 { (yyval.intval) = MER24; }
2170 #line 612 "getdate.y"
2171 { (yyval.intval) = (yyvsp[(1) - (1)].intval); }
2175 /* Line 1267 of yacc.c. */
2176 #line 2177 "getdate.c"
2179 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2183 YY_STACK_PRINT (yyss, yyssp);
2188 /* Now `shift' the result of the reduction. Determine what state
2189 that goes to, based on the state we popped back to and the rule
2190 number reduced by. */
2194 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2195 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2196 yystate = yytable[yystate];
2198 yystate = yydefgoto[yyn - YYNTOKENS];
2203 /*------------------------------------.
2204 | yyerrlab -- here on detecting error |
2205 `------------------------------------*/
2207 /* If not already recovering from an error, report this error. */
2211 #if ! YYERROR_VERBOSE
2212 yyerror (pc, YY_("syntax error"));
2215 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2216 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2218 YYSIZE_T yyalloc = 2 * yysize;
2219 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2220 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2221 if (yymsg != yymsgbuf)
2222 YYSTACK_FREE (yymsg);
2223 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2225 yymsg_alloc = yyalloc;
2229 yymsg_alloc = sizeof yymsgbuf;
2233 if (0 < yysize && yysize <= yymsg_alloc)
2235 (void) yysyntax_error (yymsg, yystate, yychar);
2236 yyerror (pc, yymsg);
2240 yyerror (pc, YY_("syntax error"));
2242 goto yyexhaustedlab;
2250 if (yyerrstatus == 3)
2252 /* If just tried and failed to reuse look-ahead token after an
2253 error, discard it. */
2255 if (yychar <= YYEOF)
2257 /* Return failure if at end of input. */
2258 if (yychar == YYEOF)
2263 yydestruct ("Error: discarding",
2264 yytoken, &yylval, pc);
2269 /* Else will try to reuse look-ahead token after shifting the error
2274 /*---------------------------------------------------.
2275 | yyerrorlab -- error raised explicitly by YYERROR. |
2276 `---------------------------------------------------*/
2279 /* Pacify compilers like GCC when the user code never invokes
2280 YYERROR and the label yyerrorlab therefore never appears in user
2282 if (/*CONSTCOND*/ 0)
2285 /* Do not reclaim the symbols of the rule which action triggered
2289 YY_STACK_PRINT (yyss, yyssp);
2294 /*-------------------------------------------------------------.
2295 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2296 `-------------------------------------------------------------*/
2298 yyerrstatus = 3; /* Each real token shifted decrements this. */
2302 yyn = yypact[yystate];
2303 if (yyn != YYPACT_NINF)
2306 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2314 /* Pop the current state because it cannot handle the error token. */
2319 yydestruct ("Error: popping",
2320 yystos[yystate], yyvsp, pc);
2323 YY_STACK_PRINT (yyss, yyssp);
2332 /* Shift the error token. */
2333 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2339 /*-------------------------------------.
2340 | yyacceptlab -- YYACCEPT comes here. |
2341 `-------------------------------------*/
2346 /*-----------------------------------.
2347 | yyabortlab -- YYABORT comes here. |
2348 `-----------------------------------*/
2354 /*-------------------------------------------------.
2355 | yyexhaustedlab -- memory exhaustion comes here. |
2356 `-------------------------------------------------*/
2358 yyerror (pc, YY_("memory exhausted"));
2364 if (yychar != YYEOF && yychar != YYEMPTY)
2365 yydestruct ("Cleanup: discarding lookahead",
2366 yytoken, &yylval, pc);
2367 /* Do not reclaim the symbols of the rule which action triggered
2368 this YYABORT or YYACCEPT. */
2370 YY_STACK_PRINT (yyss, yyssp);
2371 while (yyssp != yyss)
2373 yydestruct ("Cleanup: popping",
2374 yystos[*yyssp], yyvsp, pc);
2379 YYSTACK_FREE (yyss);
2382 if (yymsg != yymsgbuf)
2383 YYSTACK_FREE (yymsg);
2385 /* Make sure YYID is used. */
2386 return YYID (yyresult);
2390 #line 615 "getdate.y"
2393 static table const meridian_table[] =
2395 { "AM", tMERIDIAN, MERam },
2396 { "A.M.", tMERIDIAN, MERam },
2397 { "PM", tMERIDIAN, MERpm },
2398 { "P.M.", tMERIDIAN, MERpm },
2402 static table const dst_table[] =
2407 static table const month_and_day_table[] =
2409 { "JANUARY", tMONTH, 1 },
2410 { "FEBRUARY", tMONTH, 2 },
2411 { "MARCH", tMONTH, 3 },
2412 { "APRIL", tMONTH, 4 },
2413 { "MAY", tMONTH, 5 },
2414 { "JUNE", tMONTH, 6 },
2415 { "JULY", tMONTH, 7 },
2416 { "AUGUST", tMONTH, 8 },
2417 { "SEPTEMBER",tMONTH, 9 },
2418 { "SEPT", tMONTH, 9 },
2419 { "OCTOBER", tMONTH, 10 },
2420 { "NOVEMBER", tMONTH, 11 },
2421 { "DECEMBER", tMONTH, 12 },
2422 { "SUNDAY", tDAY, 0 },
2423 { "MONDAY", tDAY, 1 },
2424 { "TUESDAY", tDAY, 2 },
2425 { "TUES", tDAY, 2 },
2426 { "WEDNESDAY",tDAY, 3 },
2427 { "WEDNES", tDAY, 3 },
2428 { "THURSDAY", tDAY, 4 },
2429 { "THUR", tDAY, 4 },
2430 { "THURS", tDAY, 4 },
2431 { "FRIDAY", tDAY, 5 },
2432 { "SATURDAY", tDAY, 6 },
2436 static table const time_units_table[] =
2438 { "YEAR", tYEAR_UNIT, 1 },
2439 { "MONTH", tMONTH_UNIT, 1 },
2440 { "FORTNIGHT",tDAY_UNIT, 14 },
2441 { "WEEK", tDAY_UNIT, 7 },
2442 { "DAY", tDAY_UNIT, 1 },
2443 { "HOUR", tHOUR_UNIT, 1 },
2444 { "MINUTE", tMINUTE_UNIT, 1 },
2445 { "MIN", tMINUTE_UNIT, 1 },
2446 { "SECOND", tSEC_UNIT, 1 },
2447 { "SEC", tSEC_UNIT, 1 },
2451 /* Assorted relative-time words. */
2452 static table const relative_time_table[] =
2454 { "TOMORROW", tDAY_SHIFT, 1 },
2455 { "YESTERDAY",tDAY_SHIFT, -1 },
2456 { "TODAY", tDAY_SHIFT, 0 },
2457 { "NOW", tDAY_SHIFT, 0 },
2458 { "LAST", tORDINAL, -1 },
2459 { "THIS", tORDINAL, 0 },
2460 { "NEXT", tORDINAL, 1 },
2461 { "FIRST", tORDINAL, 1 },
2462 /*{ "SECOND", tORDINAL, 2 }, */
2463 { "THIRD", tORDINAL, 3 },
2464 { "FOURTH", tORDINAL, 4 },
2465 { "FIFTH", tORDINAL, 5 },
2466 { "SIXTH", tORDINAL, 6 },
2467 { "SEVENTH", tORDINAL, 7 },
2468 { "EIGHTH", tORDINAL, 8 },
2469 { "NINTH", tORDINAL, 9 },
2470 { "TENTH", tORDINAL, 10 },
2471 { "ELEVENTH", tORDINAL, 11 },
2472 { "TWELFTH", tORDINAL, 12 },
2477 /* The universal time zone table. These labels can be used even for
2478 time stamps that would not otherwise be valid, e.g., GMT time
2479 stamps in London during summer. */
2480 static table const universal_time_zone_table[] =
2482 { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */
2483 { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
2484 { "UTC", tZONE, HOUR ( 0) },
2488 /* The time zone table. This table is necessarily incomplete, as time
2489 zone abbreviations are ambiguous; e.g. Australians interpret "EST"
2490 as Eastern time in Australia, not as US Eastern Standard Time.
2491 You cannot rely on getdate to handle arbitrary time zone
2492 abbreviations; use numeric abbreviations like `-0500' instead. */
2493 static table const time_zone_table[] =
2495 { "WET", tZONE, HOUR ( 0) }, /* Western European */
2496 { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */
2497 { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */
2498 { "ART", tZONE, -HOUR ( 3) }, /* Argentina */
2499 { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */
2500 { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */
2501 { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */
2502 { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */
2503 { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */
2504 { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */
2505 { "CLT", tZONE, -HOUR ( 4) }, /* Chile */
2506 { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */
2507 { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */
2508 { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */
2509 { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */
2510 { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */
2511 { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */
2512 { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */
2513 { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */
2514 { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */
2515 { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */
2516 { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */
2517 { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */
2518 { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */
2519 { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */
2520 { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */
2521 { "WAT", tZONE, HOUR ( 1) }, /* West Africa */
2522 { "CET", tZONE, HOUR ( 1) }, /* Central European */
2523 { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */
2524 { "MET", tZONE, HOUR ( 1) }, /* Middle European */
2525 { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */
2526 { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */
2527 { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */
2528 { "EET", tZONE, HOUR ( 2) }, /* Eastern European */
2529 { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */
2530 { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */
2531 { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */
2532 { "EAT", tZONE, HOUR ( 3) }, /* East Africa */
2533 { "MSK", tZONE, HOUR ( 3) }, /* Moscow */
2534 { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */
2535 { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */
2536 { "SGT", tZONE, HOUR ( 8) }, /* Singapore */
2537 { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */
2538 { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */
2539 { "GST", tZONE, HOUR (10) }, /* Guam Standard */
2540 { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */
2541 { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */
2545 /* Military time zone table. */
2546 static table const military_table[] =
2548 { "A", tZONE, -HOUR ( 1) },
2549 { "B", tZONE, -HOUR ( 2) },
2550 { "C", tZONE, -HOUR ( 3) },
2551 { "D", tZONE, -HOUR ( 4) },
2552 { "E", tZONE, -HOUR ( 5) },
2553 { "F", tZONE, -HOUR ( 6) },
2554 { "G", tZONE, -HOUR ( 7) },
2555 { "H", tZONE, -HOUR ( 8) },
2556 { "I", tZONE, -HOUR ( 9) },
2557 { "K", tZONE, -HOUR (10) },
2558 { "L", tZONE, -HOUR (11) },
2559 { "M", tZONE, -HOUR (12) },
2560 { "N", tZONE, HOUR ( 1) },
2561 { "O", tZONE, HOUR ( 2) },
2562 { "P", tZONE, HOUR ( 3) },
2563 { "Q", tZONE, HOUR ( 4) },
2564 { "R", tZONE, HOUR ( 5) },
2565 { "S", tZONE, HOUR ( 6) },
2566 { "T", tZONE, HOUR ( 7) },
2567 { "U", tZONE, HOUR ( 8) },
2568 { "V", tZONE, HOUR ( 9) },
2569 { "W", tZONE, HOUR (10) },
2570 { "X", tZONE, HOUR (11) },
2571 { "Y", tZONE, HOUR (12) },
2572 { "Z", tZONE, HOUR ( 0) },
2578 /* Convert a time zone expressed as HH:MM into an integer count of
2579 minutes. If MM is negative, then S is of the form HHMM and needs
2580 to be picked apart; otherwise, S is of the form HH. As specified in
2581 http://www.opengroup.org/susv3xbd/xbd_chap08.html#tag_08_03, allow
2582 only valid TZ range, and consider first two digits as hours, if no
2583 minutes specified. */
2586 time_zone_hhmm (parser_control *pc, textint s, long int mm)
2590 /* If the length of S is 1 or 2 and no minutes are specified,
2591 interpret it as a number of hours. */
2592 if (s.digits <= 2 && mm < 0)
2596 n_minutes = (s.value / 100) * 60 + s.value % 100;
2598 n_minutes = s.value * 60 + (s.negative ? -mm : mm);
2600 /* If the absolute number of minutes is larger than 24 hours,
2601 arrange to reject it by incrementing pc->zones_seen. Thus,
2602 we allow only values in the range UTC-24:00 to UTC+24:00. */
2603 if (24 * 60 < abs (n_minutes))
2610 to_hour (long int hours, int meridian)
2614 default: /* Pacify GCC. */
2616 return 0 <= hours && hours < 24 ? hours : -1;
2618 return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
2620 return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
2625 to_year (textint textyear)
2627 long int year = textyear.value;
2632 /* XPG4 suggests that years 00-68 map to 2000-2068, and
2633 years 69-99 map to 1969-1999. */
2634 else if (textyear.digits == 2)
2635 year += year < 69 ? 2000 : 1900;
2640 static table const *
2641 lookup_zone (parser_control const *pc, char const *name)
2645 for (tp = universal_time_zone_table; tp->name; tp++)
2646 if (strcmp (name, tp->name) == 0)
2649 /* Try local zone abbreviations before those in time_zone_table, as
2650 the local ones are more likely to be right. */
2651 for (tp = pc->local_time_zone_table; tp->name; tp++)
2652 if (strcmp (name, tp->name) == 0)
2655 for (tp = time_zone_table; tp->name; tp++)
2656 if (strcmp (name, tp->name) == 0)
2662 #if ! HAVE_TM_GMTOFF
2663 /* Yield the difference between *A and *B,
2664 measured in seconds, ignoring leap seconds.
2665 The body of this function is taken directly from the GNU C Library;
2666 see src/strftime.c. */
2668 tm_diff (struct tm const *a, struct tm const *b)
2670 /* Compute intervening leap days correctly even if year is negative.
2671 Take care to avoid int overflow in leap day calculations. */
2672 int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3);
2673 int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3);
2674 int a100 = a4 / 25 - (a4 % 25 < 0);
2675 int b100 = b4 / 25 - (b4 % 25 < 0);
2676 int a400 = SHR (a100, 2);
2677 int b400 = SHR (b100, 2);
2678 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
2679 long int ayear = a->tm_year;
2680 long int years = ayear - b->tm_year;
2681 long int days = (365 * years + intervening_leap_days
2682 + (a->tm_yday - b->tm_yday));
2683 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
2684 + (a->tm_min - b->tm_min))
2685 + (a->tm_sec - b->tm_sec));
2687 #endif /* ! HAVE_TM_GMTOFF */
2689 static table const *
2690 lookup_word (parser_control const *pc, char *word)
2699 /* Make it uppercase. */
2700 for (p = word; *p; p++)
2702 unsigned char ch = *p;
2703 *p = c_toupper (ch);
2706 for (tp = meridian_table; tp->name; tp++)
2707 if (strcmp (word, tp->name) == 0)
2710 /* See if we have an abbreviation for a month. */
2711 wordlen = strlen (word);
2712 abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.');
2714 for (tp = month_and_day_table; tp->name; tp++)
2715 if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0)
2718 if ((tp = lookup_zone (pc, word)))
2721 if (strcmp (word, dst_table[0].name) == 0)
2724 for (tp = time_units_table; tp->name; tp++)
2725 if (strcmp (word, tp->name) == 0)
2728 /* Strip off any plural and try the units table again. */
2729 if (word[wordlen - 1] == 'S')
2731 word[wordlen - 1] = '\0';
2732 for (tp = time_units_table; tp->name; tp++)
2733 if (strcmp (word, tp->name) == 0)
2735 word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */
2738 for (tp = relative_time_table; tp->name; tp++)
2739 if (strcmp (word, tp->name) == 0)
2742 /* Military time zones. */
2744 for (tp = military_table; tp->name; tp++)
2745 if (word[0] == tp->name[0])
2748 /* Drop out any periods and try the time zone table again. */
2749 for (period_found = false, p = q = word; (*p = *q); q++)
2751 period_found = true;
2754 if (period_found && (tp = lookup_zone (pc, word)))
2761 yylex (YYSTYPE *lvalp, parser_control *pc)
2768 while (c = *pc->input, c_isspace (c))
2771 if (ISDIGIT (c) || c == '-' || c == '+')
2775 unsigned long int value;
2776 if (c == '-' || c == '+')
2778 sign = c == '-' ? -1 : 1;
2779 while (c = *++pc->input, c_isspace (c))
2782 /* skip the '-' sign */
2788 for (value = 0; ; value *= 10)
2790 unsigned long int value1 = value + (c - '0');
2797 if (ULONG_MAX / 10 < value)
2800 if ((c == '.' || c == ',') && ISDIGIT (p[1]))
2805 unsigned long int value1;
2807 /* Check for overflow when converting value to time_t. */
2822 if (value != value1)
2825 /* Accumulate fraction, to ns precision. */
2828 for (digits = 2; digits <= LOG10_BILLION; digits++)
2835 /* Skip excess digits, truncating toward -Infinity. */
2837 for (; ISDIGIT (*p); p++)
2843 while (ISDIGIT (*p))
2846 /* Adjust to the timespec convention, which is that
2847 tv_nsec is always a positive offset even if tv_sec is
2857 lvalp->timespec.tv_sec = s;
2858 lvalp->timespec.tv_nsec = ns;
2860 return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER;
2864 lvalp->textintval.negative = sign < 0;
2867 lvalp->textintval.value = - value;
2868 if (0 < lvalp->textintval.value)
2873 lvalp->textintval.value = value;
2874 if (lvalp->textintval.value < 0)
2877 lvalp->textintval.digits = p - pc->input;
2879 return sign ? tSNUMBER : tUNUMBER;
2891 if (p < buff + sizeof buff - 1)
2895 while (c_isalpha (c) || c == '.');
2898 tp = lookup_word (pc, buff);
2901 lvalp->intval = tp->value;
2906 return *pc->input++;
2922 /* Do nothing if the parser reports an error. */
2924 yyerror (parser_control const *pc _GL_UNUSED,
2925 char const *s _GL_UNUSED)
2930 /* If *TM0 is the old and *TM1 is the new value of a struct tm after
2931 passing it to mktime, return true if it's OK that mktime returned T.
2932 It's not OK if *TM0 has out-of-range members. */
2935 mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t)
2937 if (t == (time_t) -1)
2939 /* Guard against falsely reporting an error when parsing a time
2940 stamp that happens to equal (time_t) -1, on a host that
2941 supports such a time stamp. */
2942 tm1 = localtime (&t);
2947 return ! ((tm0->tm_sec ^ tm1->tm_sec)
2948 | (tm0->tm_min ^ tm1->tm_min)
2949 | (tm0->tm_hour ^ tm1->tm_hour)
2950 | (tm0->tm_mday ^ tm1->tm_mday)
2951 | (tm0->tm_mon ^ tm1->tm_mon)
2952 | (tm0->tm_year ^ tm1->tm_year));
2955 /* A reasonable upper bound for the size of ordinary TZ strings.
2956 Use heap allocation if TZ's length exceeds this. */
2957 enum { TZBUFSIZE = 100 };
2959 /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated
2962 get_tz (char tzbuf[TZBUFSIZE])
2964 char *tz = getenv ("TZ");
2967 size_t tzsize = strlen (tz) + 1;
2968 tz = (tzsize <= TZBUFSIZE
2969 ? memcpy (tzbuf, tz, tzsize)
2970 : xmemdup (tz, tzsize));
2975 /* Parse a date/time string, storing the resulting time value into *RESULT.
2976 The string itself is pointed to by P. Return true if successful.
2977 P can be an incomplete or relative time specification; if so, use
2978 *NOW as the basis for the returned time. */
2980 get_date (struct timespec *result, char const *p, struct timespec const *now)
2984 struct tm const *tmp;
2988 struct timespec gettime_buffer;
2990 bool tz_was_altered = false;
2992 char tz0buf[TZBUFSIZE];
2997 gettime (&gettime_buffer);
2998 now = &gettime_buffer;
3001 Start = now->tv_sec;
3002 Start_ns = now->tv_nsec;
3004 tmp = localtime (&now->tv_sec);
3008 while (c = *p, c_isspace (c))
3011 if (strncmp (p, "TZ=\"", 4) == 0)
3013 char const *tzbase = p + 4;
3017 for (s = tzbase; *s; s++, tzsize++)
3021 if (! (*s == '\\' || *s == '"'))
3028 char tz1buf[TZBUFSIZE];
3029 bool large_tz = TZBUFSIZE < tzsize;
3031 /* Free tz0, in case this is the 2nd or subsequent time through. */
3033 tz0 = get_tz (tz0buf);
3034 z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
3035 for (s = tzbase; *s != '"'; s++)
3036 *z++ = *(s += *s == '\\');
3038 setenv_ok = setenv ("TZ", tz1, 1) == 0;
3043 tz_was_altered = true;
3048 /* As documented, be careful to treat the empty string just like
3049 a date string of "0". Without this, an empty string would be
3050 declared invalid when parsed during a DST transition. */
3055 pc.year.value = tmp->tm_year;
3056 pc.year.value += TM_YEAR_BASE;
3058 pc.month = tmp->tm_mon + 1;
3059 pc.day = tmp->tm_mday;
3060 pc.hour = tmp->tm_hour;
3061 pc.minutes = tmp->tm_min;
3062 pc.seconds.tv_sec = tmp->tm_sec;
3063 pc.seconds.tv_nsec = Start_ns;
3064 tm.tm_isdst = tmp->tm_isdst;
3066 pc.meridian = MER24;
3067 pc.rel = RELATIVE_TIME_0;
3068 pc.timespec_seen = false;
3069 pc.rels_seen = false;
3073 pc.local_zones_seen = 0;
3077 #if HAVE_STRUCT_TM_TM_ZONE
3078 pc.local_time_zone_table[0].name = tmp->tm_zone;
3079 pc.local_time_zone_table[0].type = tLOCAL_ZONE;
3080 pc.local_time_zone_table[0].value = tmp->tm_isdst;
3081 pc.local_time_zone_table[1].name = NULL;
3083 /* Probe the names used in the next three calendar quarters, looking
3084 for a tm_isdst different from the one we already have. */
3087 for (quarter = 1; quarter <= 3; quarter++)
3089 time_t probe = Start + quarter * (90 * 24 * 60 * 60);
3090 struct tm const *probe_tm = localtime (&probe);
3091 if (probe_tm && probe_tm->tm_zone
3092 && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
3095 pc.local_time_zone_table[1].name = probe_tm->tm_zone;
3096 pc.local_time_zone_table[1].type = tLOCAL_ZONE;
3097 pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
3098 pc.local_time_zone_table[2].name = NULL;
3107 # if !HAVE_DECL_TZNAME
3108 extern char *tzname[];
3111 for (i = 0; i < 2; i++)
3113 pc.local_time_zone_table[i].name = tzname[i];
3114 pc.local_time_zone_table[i].type = tLOCAL_ZONE;
3115 pc.local_time_zone_table[i].value = i;
3117 pc.local_time_zone_table[i].name = NULL;
3120 pc.local_time_zone_table[0].name = NULL;
3124 if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
3125 && ! strcmp (pc.local_time_zone_table[0].name,
3126 pc.local_time_zone_table[1].name))
3128 /* This locale uses the same abbrevation for standard and
3129 daylight times. So if we see that abbreviation, we don't
3130 know whether it's daylight time. */
3131 pc.local_time_zone_table[0].value = -1;
3132 pc.local_time_zone_table[1].name = NULL;
3135 if (yyparse (&pc) != 0)
3138 if (pc.timespec_seen)
3139 *result = pc.seconds;
3142 if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen
3143 | (pc.local_zones_seen + pc.zones_seen)))
3146 tm.tm_year = to_year (pc.year) - TM_YEAR_BASE;
3147 tm.tm_mon = pc.month - 1;
3148 tm.tm_mday = pc.day;
3149 if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
3151 tm.tm_hour = to_hour (pc.hour, pc.meridian);
3154 tm.tm_min = pc.minutes;
3155 tm.tm_sec = pc.seconds.tv_sec;
3159 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
3160 pc.seconds.tv_nsec = 0;
3163 /* Let mktime deduce tm_isdst if we have an absolute time stamp. */
3164 if (pc.dates_seen | pc.days_seen | pc.times_seen)
3167 /* But if the input explicitly specifies local time with or without
3168 DST, give mktime that information. */
3169 if (pc.local_zones_seen)
3170 tm.tm_isdst = pc.local_isdst;
3174 Start = mktime (&tm);
3176 if (! mktime_ok (&tm0, &tm, Start))
3178 if (! pc.zones_seen)
3182 /* Guard against falsely reporting errors near the time_t
3183 boundaries when parsing times in other time zones. For
3184 example, suppose the input string "1969-12-31 23:00:00 -0100",
3185 the current time zone is 8 hours ahead of UTC, and the min
3186 time_t value is 1970-01-01 00:00:00 UTC. Then the min
3187 localtime value is 1970-01-01 08:00:00, and mktime will
3188 therefore fail on 1969-12-31 23:00:00. To work around the
3189 problem, set the time zone to 1 hour behind UTC temporarily
3190 by setting TZ="XXX1:00" and try mktime again. */
3192 long int time_zone = pc.time_zone;
3193 long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone;
3194 long int abs_time_zone_hour = abs_time_zone / 60;
3195 int abs_time_zone_min = abs_time_zone % 60;
3196 char tz1buf[sizeof "XXX+0:00"
3197 + sizeof pc.time_zone * CHAR_BIT / 3];
3198 if (!tz_was_altered)
3199 tz0 = get_tz (tz0buf);
3200 sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0),
3201 abs_time_zone_hour, abs_time_zone_min);
3202 if (setenv ("TZ", tz1buf, 1) != 0)
3204 tz_was_altered = true;
3206 Start = mktime (&tm);
3207 if (! mktime_ok (&tm0, &tm, Start))
3212 if (pc.days_seen && ! pc.dates_seen)
3214 tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
3215 + 7 * (pc.day_ordinal
3216 - (0 < pc.day_ordinal
3217 && tm.tm_wday != pc.day_number)));
3219 Start = mktime (&tm);
3220 if (Start == (time_t) -1)
3224 /* Add relative date. */
3225 if (pc.rel.year | pc.rel.month | pc.rel.day)
3227 int year = tm.tm_year + pc.rel.year;
3228 int month = tm.tm_mon + pc.rel.month;
3229 int day = tm.tm_mday + pc.rel.day;
3230 if (((year < tm.tm_year) ^ (pc.rel.year < 0))
3231 | ((month < tm.tm_mon) ^ (pc.rel.month < 0))
3232 | ((day < tm.tm_mday) ^ (pc.rel.day < 0)))
3237 tm.tm_hour = tm0.tm_hour;
3238 tm.tm_min = tm0.tm_min;
3239 tm.tm_sec = tm0.tm_sec;
3240 tm.tm_isdst = tm0.tm_isdst;
3241 Start = mktime (&tm);
3242 if (Start == (time_t) -1)
3246 /* The only "output" of this if-block is an updated Start value,
3247 so this block must follow others that clobber Start. */
3250 long int delta = pc.time_zone * 60;
3252 #ifdef HAVE_TM_GMTOFF
3253 delta -= tm.tm_gmtoff;
3256 struct tm const *gmt = gmtime (&t);
3259 delta -= tm_diff (&tm, gmt);
3262 if ((Start < t1) != (delta < 0))
3263 goto fail; /* time_t overflow */
3267 /* Add relative hours, minutes, and seconds. On hosts that support
3268 leap seconds, ignore the possibility of leap seconds; e.g.,
3269 "+ 10 minutes" adds 600 seconds, even if one of them is a
3270 leap second. Typically this is not what the user wants, but it's
3271 too hard to do it the other way, because the time zone indicator
3272 must be applied before relative times, and if mktime is applied
3273 again the time zone will be lost. */
3275 long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns;
3276 long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION;
3278 long int d1 = 60 * 60 * pc.rel.hour;
3279 time_t t1 = t0 + d1;
3280 long int d2 = 60 * pc.rel.minutes;
3281 time_t t2 = t1 + d2;
3282 long_time_t d3 = pc.rel.seconds;
3283 long_time_t t3 = t2 + d3;
3284 long int d4 = (sum_ns - normalized_ns) / BILLION;
3285 long_time_t t4 = t3 + d4;
3288 if ((d1 / (60 * 60) ^ pc.rel.hour)
3289 | (d2 / 60 ^ pc.rel.minutes)
3290 | ((t1 < t0) ^ (d1 < 0))
3291 | ((t2 < t1) ^ (d2 < 0))
3292 | ((t3 < t2) ^ (d3 < 0))
3293 | ((t4 < t3) ^ (d4 < 0))
3297 result->tv_sec = t5;
3298 result->tv_nsec = normalized_ns;
3308 ok &= (tz0 ? setenv ("TZ", tz0, 1) : unsetenv ("TZ")) == 0;
3317 main (int ac, char **av)
3321 printf ("Enter date, or blank line to exit.\n\t> ");
3324 buff[BUFSIZ - 1] = '\0';
3325 while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
3328 struct tm const *tm;
3329 if (! get_date (&d, buff, NULL))
3330 printf ("Bad format - couldn't convert.\n");
3331 else if (! (tm = localtime (&d.tv_sec)))
3333 long int sec = d.tv_sec;
3334 printf ("localtime (%ld) failed\n", sec);
3339 printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n",
3340 tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
3341 tm->tm_hour, tm->tm_min, tm->tm_sec, ns);