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 */
74 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
75 ** at the University of North Carolina at Chapel Hill. Later tweaked by
76 ** a couple of people on Usenet. Completely overhauled by Rich $alz
77 ** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
79 ** This grammar has 13 shift/reduce conflicts.
81 ** This code is in the public domain and has no copyright.
86 # ifdef FORCE_ALLOCA_H
91 /* Since the code of getdate.y is not included in the Emacs executable
92 itself, there is no need to #define static in this file. Even if
93 the code were included in the Emacs executable, it probably
94 wouldn't do any harm to #undef it here; this will only cause
95 problems if we try to write to a static variable, which I don't
96 think this code needs to do. */
105 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
106 # define IN_CTYPE_DOMAIN(c) 1
108 # define IN_CTYPE_DOMAIN(c) isascii(c)
111 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
112 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
113 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
114 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
116 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
117 - Its arg may be any int or unsigned int; it need not be an unsigned char.
118 - It's guaranteed to evaluate its argument exactly once.
119 - It's typically faster.
120 Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
121 only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
122 it's important to use the locale's definition of `digit' even when the
123 host does not conform to Posix. */
124 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
128 #if defined (STDC_HEADERS)
132 /* Some old versions of bison generate parsers that use bcopy.
133 That loses on systems that don't provide the function, so we have
134 to redefine it here. */
135 #if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
136 # define bcopy(from, to, len) memcpy ((to), (from), (len))
139 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
140 as well as gratuitiously global symbol names, so we can have multiple
141 yacc generated parsers in the same program. Note that these are only
142 the variables produced by yacc. If other parser generators (bison,
143 byacc, etc) produce additional global names that conflict at link time,
144 then those parser generators need to be fixed instead of adding those
145 names to this list. */
147 #define yymaxdepth gd_maxdepth
148 #define yyparse gd_parse
150 #define yyerror gd_error
151 #define yylval gd_lval
152 #define yychar gd_char
153 #define yydebug gd_debug
154 #define yypact gd_pact
161 #define yyexca gd_exca
162 #define yyerrflag gd_errflag
163 #define yynerrs gd_nerrs
167 #define yy_yys gd_yys
168 #define yystate gd_state
171 #define yy_yyv gd_yyv
173 #define yylloc gd_lloc
174 #define yyreds gd_reds /* With YYDEBUG defined */
175 #define yytoks gd_toks /* With YYDEBUG defined */
176 #define yylhs gd_yylhs
177 #define yylen gd_yylen
178 #define yydefred gd_yydefred
179 #define yydgoto gd_yydgoto
180 #define yysindex gd_yysindex
181 #define yyrindex gd_yyrindex
182 #define yygindex gd_yygindex
183 #define yytable gd_yytable
184 #define yycheck gd_yycheck
186 static int yylex (void);
187 static int yyerror (const char *s);
190 #define HOUR(x) ((x) * 60)
192 #define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
195 ** An entry in the lexical lookup table.
197 typedef struct _TABLE {
205 ** Meridian: am, pm, or 24-hour style.
207 typedef enum _MERIDIAN {
213 ** Global variables. We could get rid of most of these by using a good
214 ** union as the yacc stack. (This routine was originally written before
215 ** yacc had the %union construct.) Maybe someday; right now we only use
216 ** the %union very rarely.
218 static const char *yyInput;
219 static int yyDayOrdinal;
220 static int yyDayNumber;
221 static int yyHaveDate;
222 static int yyHaveDay;
223 static int yyHaveRel;
224 static int yyHaveTime;
225 static int yyHaveZone;
226 static int yyTimezone;
229 static int yyMinutes;
231 static int yySeconds;
233 static MERIDIAN yyMeridian;
235 static int yyRelHour;
236 static int yyRelMinutes;
237 static int yyRelMonth;
238 static int yyRelSeconds;
239 static int yyRelYear;
243 /* Line 189 of yacc.c */
244 #line 245 "getdate.c"
246 /* Enabling traces. */
251 /* Enabling verbose error messages. */
252 #ifdef YYERROR_VERBOSE
253 # undef YYERROR_VERBOSE
254 # define YYERROR_VERBOSE 1
256 # define YYERROR_VERBOSE 0
259 /* Enabling the token table. */
260 #ifndef YYTOKEN_TABLE
261 # define YYTOKEN_TABLE 0
268 /* Put the tokens into the symbol table, so that GDB and other debuggers
292 #define tDAY_UNIT 260
295 #define tHOUR_UNIT 263
297 #define tMERIDIAN 265
298 #define tMINUTE_UNIT 266
300 #define tMONTH_UNIT 268
301 #define tSEC_UNIT 269
304 #define tYEAR_UNIT 272
310 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
311 typedef union YYSTYPE
314 /* Line 214 of yacc.c */
315 #line 172 "getdate.y"
318 enum _MERIDIAN Meridian;
322 /* Line 214 of yacc.c */
323 #line 324 "getdate.c"
325 # define YYSTYPE_IS_TRIVIAL 1
326 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
327 # define YYSTYPE_IS_DECLARED 1
331 /* Copy the second part of user declarations. */
334 /* Line 264 of yacc.c */
335 #line 336 "getdate.c"
342 typedef YYTYPE_UINT8 yytype_uint8;
344 typedef unsigned char yytype_uint8;
348 typedef YYTYPE_INT8 yytype_int8;
349 #elif (defined __STDC__ || defined __C99__FUNC__ \
350 || defined __cplusplus || defined _MSC_VER)
351 typedef signed char yytype_int8;
353 typedef short int yytype_int8;
357 typedef YYTYPE_UINT16 yytype_uint16;
359 typedef unsigned short int yytype_uint16;
363 typedef YYTYPE_INT16 yytype_int16;
365 typedef short int yytype_int16;
369 # ifdef __SIZE_TYPE__
370 # define YYSIZE_T __SIZE_TYPE__
371 # elif defined size_t
372 # define YYSIZE_T size_t
373 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
374 || defined __cplusplus || defined _MSC_VER)
375 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
376 # define YYSIZE_T size_t
378 # define YYSIZE_T unsigned int
382 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
387 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
388 # define YY_(msgid) dgettext ("bison-runtime", msgid)
392 # define YY_(msgid) msgid
396 /* Suppress unused-variable warnings by "using" E. */
397 #if ! defined lint || defined __GNUC__
398 # define YYUSE(e) ((void) (e))
400 # define YYUSE(e) /* empty */
403 /* Identity function, used to suppress warnings about constant conditions. */
407 #if (defined __STDC__ || defined __C99__FUNC__ \
408 || defined __cplusplus || defined _MSC_VER)
421 #if ! defined yyoverflow || YYERROR_VERBOSE
423 /* The parser invokes alloca or malloc; define the necessary symbols. */
425 # ifdef YYSTACK_USE_ALLOCA
426 # if YYSTACK_USE_ALLOCA
428 # define YYSTACK_ALLOC __builtin_alloca
429 # elif defined __BUILTIN_VA_ARG_INCR
430 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
432 # define YYSTACK_ALLOC __alloca
433 # elif defined _MSC_VER
434 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
435 # define alloca _alloca
437 # define YYSTACK_ALLOC alloca
438 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
439 || defined __cplusplus || defined _MSC_VER)
440 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
449 # ifdef YYSTACK_ALLOC
450 /* Pacify GCC's `empty if-body' warning. */
451 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
452 # ifndef YYSTACK_ALLOC_MAXIMUM
453 /* The OS might guarantee only one guard page at the bottom of the stack,
454 and a page size can be as small as 4096 bytes. So we cannot safely
455 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
456 to allow for a few compiler-allocated temporary stack slots. */
457 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
460 # define YYSTACK_ALLOC YYMALLOC
461 # define YYSTACK_FREE YYFREE
462 # ifndef YYSTACK_ALLOC_MAXIMUM
463 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
465 # if (defined __cplusplus && ! defined _STDLIB_H \
466 && ! ((defined YYMALLOC || defined malloc) \
467 && (defined YYFREE || defined free)))
468 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
474 # define YYMALLOC malloc
475 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
476 || defined __cplusplus || defined _MSC_VER)
477 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
482 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
483 || defined __cplusplus || defined _MSC_VER)
484 void free (void *); /* INFRINGES ON USER NAME SPACE */
488 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
491 #if (! defined yyoverflow \
492 && (! defined __cplusplus \
493 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
495 /* A type that is properly aligned for any stack member. */
498 yytype_int16 yyss_alloc;
502 /* The size of the maximum gap between one aligned stack and the next. */
503 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
505 /* The size of an array large to enough to hold all stacks, each with
507 # define YYSTACK_BYTES(N) \
508 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
509 + YYSTACK_GAP_MAXIMUM)
511 /* Copy COUNT objects from FROM to TO. The source and destination do
514 # if defined __GNUC__ && 1 < __GNUC__
515 # define YYCOPY(To, From, Count) \
516 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
518 # define YYCOPY(To, From, Count) \
522 for (yyi = 0; yyi < (Count); yyi++) \
523 (To)[yyi] = (From)[yyi]; \
529 /* Relocate STACK from its old location to the new one. The
530 local variables YYSIZE and YYSTACKSIZE give the old and new number of
531 elements in the stack, and YYPTR gives the new location of the
532 stack. Advance YYPTR to a properly aligned location for the next
534 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
537 YYSIZE_T yynewbytes; \
538 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
539 Stack = &yyptr->Stack_alloc; \
540 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
541 yyptr += yynewbytes / sizeof (*yyptr); \
547 /* YYFINAL -- State number of the termination state. */
549 /* YYLAST -- Last index in YYTABLE. */
552 /* YYNTOKENS -- Number of terminals. */
554 /* YYNNTS -- Number of nonterminals. */
556 /* YYNRULES -- Number of rules. */
558 /* YYNRULES -- Number of states. */
561 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
563 #define YYMAXUTOK 273
565 #define YYTRANSLATE(YYX) \
566 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
568 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
569 static const yytype_uint8 yytranslate[] =
571 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575 2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
577 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
579 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
580 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584 2, 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, 2, 2, 2, 2, 2, 2,
589 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
590 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
597 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
602 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
604 static const yytype_uint8 yyprhs[] =
606 0, 0, 3, 4, 7, 9, 11, 13, 15, 17,
607 19, 22, 27, 32, 39, 46, 48, 50, 53, 55,
608 58, 61, 65, 71, 75, 79, 82, 87, 90, 94,
609 97, 99, 102, 105, 107, 110, 113, 115, 118, 121,
610 123, 126, 129, 131, 134, 137, 139, 142, 145, 147,
614 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
615 static const yytype_int8 yyrhs[] =
617 23, 0, -1, -1, 23, 24, -1, 25, -1, 26,
618 -1, 28, -1, 27, -1, 29, -1, 31, -1, 16,
619 10, -1, 16, 19, 16, 32, -1, 16, 19, 16,
620 15, -1, 16, 19, 16, 19, 16, 32, -1, 16,
621 19, 16, 19, 16, 15, -1, 18, -1, 6, -1,
622 18, 7, -1, 4, -1, 4, 20, -1, 16, 4,
623 -1, 16, 21, 16, -1, 16, 21, 16, 21, 16,
624 -1, 16, 15, 15, -1, 16, 12, 15, -1, 12,
625 16, -1, 12, 16, 20, 16, -1, 16, 12, -1,
626 16, 12, 16, -1, 30, 3, -1, 30, -1, 16,
627 17, -1, 15, 17, -1, 17, -1, 16, 13, -1,
628 15, 13, -1, 13, -1, 16, 5, -1, 15, 5,
629 -1, 5, -1, 16, 8, -1, 15, 8, -1, 8,
630 -1, 16, 11, -1, 15, 11, -1, 11, -1, 16,
631 14, -1, 15, 14, -1, 14, -1, 16, -1, -1,
635 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
636 static const yytype_uint16 yyrline[] =
638 0, 188, 188, 189, 192, 195, 198, 201, 204, 207,
639 210, 216, 222, 231, 237, 249, 252, 256, 261, 265,
640 269, 275, 279, 297, 303, 309, 313, 318, 322, 329,
641 337, 340, 343, 346, 349, 352, 355, 358, 361, 364,
642 367, 370, 373, 376, 379, 382, 385, 388, 391, 396,
647 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
648 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
649 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
650 static const char *const yytname[] =
652 "$end", "error", "$undefined", "tAGO", "tDAY", "tDAY_UNIT", "tDAYZONE",
653 "tDST", "tHOUR_UNIT", "tID", "tMERIDIAN", "tMINUTE_UNIT", "tMONTH",
654 "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tYEAR_UNIT",
655 "tZONE", "':'", "','", "'/'", "$accept", "spec", "item", "time", "zone",
656 "day", "date", "rel", "relunit", "number", "o_merid", 0
661 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
663 static const yytype_uint16 yytoknum[] =
665 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
666 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
671 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
672 static const yytype_uint8 yyr1[] =
674 0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
675 25, 25, 25, 25, 25, 26, 26, 26, 27, 27,
676 27, 28, 28, 28, 28, 28, 28, 28, 28, 29,
677 29, 30, 30, 30, 30, 30, 30, 30, 30, 30,
678 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
682 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
683 static const yytype_uint8 yyr2[] =
685 0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
686 2, 4, 4, 6, 6, 1, 1, 2, 1, 2,
687 2, 3, 5, 3, 3, 2, 4, 2, 3, 2,
688 1, 2, 2, 1, 2, 2, 1, 2, 2, 1,
689 2, 2, 1, 2, 2, 1, 2, 2, 1, 1,
693 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
694 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
695 means the default is an error. */
696 static const yytype_uint8 yydefact[] =
698 2, 0, 1, 18, 39, 16, 42, 45, 0, 36,
699 48, 0, 49, 33, 15, 3, 4, 5, 7, 6,
700 8, 30, 9, 19, 25, 38, 41, 44, 35, 47,
701 32, 20, 37, 40, 10, 43, 27, 34, 46, 0,
702 31, 0, 0, 17, 29, 0, 24, 28, 23, 50,
703 21, 26, 51, 12, 0, 11, 0, 50, 22, 14,
707 /* YYDEFGOTO[NTERM-NUM]. */
708 static const yytype_int8 yydefgoto[] =
710 -1, 1, 15, 16, 17, 18, 19, 20, 21, 22,
714 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
716 #define YYPACT_NINF -20
717 static const yytype_int8 yypact[] =
719 -20, 0, -20, -19, -20, -20, -20, -20, -13, -20,
720 -20, 30, 15, -20, 14, -20, -20, -20, -20, -20,
721 -20, 19, -20, -20, 4, -20, -20, -20, -20, -20,
722 -20, -20, -20, -20, -20, -20, -6, -20, -20, 16,
723 -20, 17, 23, -20, -20, 24, -20, -20, -20, 27,
724 28, -20, -20, -20, 29, -20, 32, -8, -20, -20,
728 /* YYPGOTO[NTERM-NUM]. */
729 static const yytype_int8 yypgoto[] =
731 -20, -20, -20, -20, -20, -20, -20, -20, -20, -20,
735 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
736 positive, shift that token. If negative, reduce the rule which
737 number is the opposite. If zero, do what YYDEFACT says.
738 If YYTABLE_NINF, syntax error. */
739 #define YYTABLE_NINF -1
740 static const yytype_uint8 yytable[] =
742 2, 23, 52, 24, 3, 4, 5, 59, 6, 46,
743 47, 7, 8, 9, 10, 11, 12, 13, 14, 31,
744 32, 43, 44, 33, 45, 34, 35, 36, 37, 38,
745 39, 48, 40, 49, 41, 25, 42, 52, 26, 50,
746 51, 27, 53, 28, 29, 57, 54, 30, 58, 56,
750 static const yytype_uint8 yycheck[] =
752 0, 20, 10, 16, 4, 5, 6, 15, 8, 15,
753 16, 11, 12, 13, 14, 15, 16, 17, 18, 4,
754 5, 7, 3, 8, 20, 10, 11, 12, 13, 14,
755 15, 15, 17, 16, 19, 5, 21, 10, 8, 16,
756 16, 11, 15, 13, 14, 16, 19, 17, 16, 21,
760 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
761 symbol of state STATE-NUM. */
762 static const yytype_uint8 yystos[] =
764 0, 23, 0, 4, 5, 6, 8, 11, 12, 13,
765 14, 15, 16, 17, 18, 24, 25, 26, 27, 28,
766 29, 30, 31, 20, 16, 5, 8, 11, 13, 14,
767 17, 4, 5, 8, 10, 11, 12, 13, 14, 15,
768 17, 19, 21, 7, 3, 20, 15, 16, 15, 16,
769 16, 16, 10, 15, 19, 32, 21, 16, 16, 15,
773 #define yyerrok (yyerrstatus = 0)
774 #define yyclearin (yychar = YYEMPTY)
778 #define YYACCEPT goto yyacceptlab
779 #define YYABORT goto yyabortlab
780 #define YYERROR goto yyerrorlab
783 /* Like YYERROR except do call yyerror. This remains here temporarily
784 to ease the transition to the new meaning of YYERROR, for GCC.
785 Once GCC version 2 has supplanted version 1, this can go. */
787 #define YYFAIL goto yyerrlab
789 #define YYRECOVERING() (!!yyerrstatus)
791 #define YYBACKUP(Token, Value) \
793 if (yychar == YYEMPTY && yylen == 1) \
797 yytoken = YYTRANSLATE (yychar); \
803 yyerror (YY_("syntax error: cannot back up")); \
810 #define YYERRCODE 256
813 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
814 If N is 0, then set CURRENT to the empty location which ends
815 the previous symbol: RHS[0] (always defined). */
817 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
818 #ifndef YYLLOC_DEFAULT
819 # define YYLLOC_DEFAULT(Current, Rhs, N) \
823 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
824 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
825 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
826 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
830 (Current).first_line = (Current).last_line = \
831 YYRHSLOC (Rhs, 0).last_line; \
832 (Current).first_column = (Current).last_column = \
833 YYRHSLOC (Rhs, 0).last_column; \
839 /* YY_LOCATION_PRINT -- Print the location on the stream.
840 This macro was not mandated originally: define only if we know
841 we won't break user code: when these are the locations we know. */
843 #ifndef YY_LOCATION_PRINT
844 # if YYLTYPE_IS_TRIVIAL
845 # define YY_LOCATION_PRINT(File, Loc) \
846 fprintf (File, "%d.%d-%d.%d", \
847 (Loc).first_line, (Loc).first_column, \
848 (Loc).last_line, (Loc).last_column)
850 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
855 /* YYLEX -- calling `yylex' with the right arguments. */
858 # define YYLEX yylex (YYLEX_PARAM)
860 # define YYLEX yylex ()
863 /* Enable debugging if requested. */
867 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
868 # define YYFPRINTF fprintf
871 # define YYDPRINTF(Args) \
877 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
881 YYFPRINTF (stderr, "%s ", Title); \
882 yy_symbol_print (stderr, \
884 YYFPRINTF (stderr, "\n"); \
889 /*--------------------------------.
890 | Print this symbol on YYOUTPUT. |
891 `--------------------------------*/
894 #if (defined __STDC__ || defined __C99__FUNC__ \
895 || defined __cplusplus || defined _MSC_VER)
897 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
900 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
903 YYSTYPE const * const yyvaluep;
909 if (yytype < YYNTOKENS)
910 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
922 /*--------------------------------.
923 | Print this symbol on YYOUTPUT. |
924 `--------------------------------*/
926 #if (defined __STDC__ || defined __C99__FUNC__ \
927 || defined __cplusplus || defined _MSC_VER)
929 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
932 yy_symbol_print (yyoutput, yytype, yyvaluep)
935 YYSTYPE const * const yyvaluep;
938 if (yytype < YYNTOKENS)
939 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
941 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
943 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
944 YYFPRINTF (yyoutput, ")");
947 /*------------------------------------------------------------------.
948 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
950 `------------------------------------------------------------------*/
952 #if (defined __STDC__ || defined __C99__FUNC__ \
953 || defined __cplusplus || defined _MSC_VER)
955 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
958 yy_stack_print (yybottom, yytop)
959 yytype_int16 *yybottom;
963 YYFPRINTF (stderr, "Stack now");
964 for (; yybottom <= yytop; yybottom++)
966 int yybot = *yybottom;
967 YYFPRINTF (stderr, " %d", yybot);
969 YYFPRINTF (stderr, "\n");
972 # define YY_STACK_PRINT(Bottom, Top) \
975 yy_stack_print ((Bottom), (Top)); \
979 /*------------------------------------------------.
980 | Report that the YYRULE is going to be reduced. |
981 `------------------------------------------------*/
983 #if (defined __STDC__ || defined __C99__FUNC__ \
984 || defined __cplusplus || defined _MSC_VER)
986 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
989 yy_reduce_print (yyvsp, yyrule)
994 int yynrhs = yyr2[yyrule];
996 unsigned long int yylno = yyrline[yyrule];
997 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
999 /* The symbols being reduced. */
1000 for (yyi = 0; yyi < yynrhs; yyi++)
1002 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1003 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1004 &(yyvsp[(yyi + 1) - (yynrhs)])
1006 YYFPRINTF (stderr, "\n");
1010 # define YY_REDUCE_PRINT(Rule) \
1013 yy_reduce_print (yyvsp, Rule); \
1016 /* Nonzero means print parse trace. It is left uninitialized so that
1017 multiple parsers can coexist. */
1019 #else /* !YYDEBUG */
1020 # define YYDPRINTF(Args)
1021 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1022 # define YY_STACK_PRINT(Bottom, Top)
1023 # define YY_REDUCE_PRINT(Rule)
1024 #endif /* !YYDEBUG */
1027 /* YYINITDEPTH -- initial size of the parser's stacks. */
1029 # define YYINITDEPTH 200
1032 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1033 if the built-in stack extension method is used).
1035 Do not make this value too large; the results are undefined if
1036 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1037 evaluated with infinite-precision integer arithmetic. */
1040 # define YYMAXDEPTH 10000
1048 # if defined __GLIBC__ && defined _STRING_H
1049 # define yystrlen strlen
1051 /* Return the length of YYSTR. */
1052 #if (defined __STDC__ || defined __C99__FUNC__ \
1053 || defined __cplusplus || defined _MSC_VER)
1055 yystrlen (const char *yystr)
1063 for (yylen = 0; yystr[yylen]; yylen++)
1071 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1072 # define yystpcpy stpcpy
1074 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1076 #if (defined __STDC__ || defined __C99__FUNC__ \
1077 || defined __cplusplus || defined _MSC_VER)
1079 yystpcpy (char *yydest, const char *yysrc)
1082 yystpcpy (yydest, yysrc)
1088 const char *yys = yysrc;
1090 while ((*yyd++ = *yys++) != '\0')
1099 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1100 quotes and backslashes, so that it's suitable for yyerror. The
1101 heuristic is that double-quoting is unnecessary unless the string
1102 contains an apostrophe, a comma, or backslash (other than
1103 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1104 null, do not copy; instead, return the length of what the result
1107 yytnamerr (char *yyres, const char *yystr)
1112 char const *yyp = yystr;
1119 goto do_not_strip_quotes;
1123 goto do_not_strip_quotes;
1136 do_not_strip_quotes: ;
1140 return yystrlen (yystr);
1142 return yystpcpy (yyres, yystr) - yyres;
1146 /* Copy into YYRESULT an error message about the unexpected token
1147 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1148 including the terminating null byte. If YYRESULT is null, do not
1149 copy anything; just return the number of bytes that would be
1150 copied. As a special case, return 0 if an ordinary "syntax error"
1151 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1152 size calculation. */
1154 yysyntax_error (char *yyresult, int yystate, int yychar)
1156 int yyn = yypact[yystate];
1158 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1162 int yytype = YYTRANSLATE (yychar);
1163 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1164 YYSIZE_T yysize = yysize0;
1166 int yysize_overflow = 0;
1167 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1168 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1172 /* This is so xgettext sees the translatable formats that are
1173 constructed on the fly. */
1174 YY_("syntax error, unexpected %s");
1175 YY_("syntax error, unexpected %s, expecting %s");
1176 YY_("syntax error, unexpected %s, expecting %s or %s");
1177 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1178 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1182 static char const yyunexpected[] = "syntax error, unexpected %s";
1183 static char const yyexpecting[] = ", expecting %s";
1184 static char const yyor[] = " or %s";
1185 char yyformat[sizeof yyunexpected
1186 + sizeof yyexpecting - 1
1187 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1188 * (sizeof yyor - 1))];
1189 char const *yyprefix = yyexpecting;
1191 /* Start YYX at -YYN if negative to avoid negative indexes in
1193 int yyxbegin = yyn < 0 ? -yyn : 0;
1195 /* Stay within bounds of both yycheck and yytname. */
1196 int yychecklim = YYLAST - yyn + 1;
1197 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1200 yyarg[0] = yytname[yytype];
1201 yyfmt = yystpcpy (yyformat, yyunexpected);
1203 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1204 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1206 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1210 yyformat[sizeof yyunexpected - 1] = '\0';
1213 yyarg[yycount++] = yytname[yyx];
1214 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1215 yysize_overflow |= (yysize1 < yysize);
1217 yyfmt = yystpcpy (yyfmt, yyprefix);
1221 yyf = YY_(yyformat);
1222 yysize1 = yysize + yystrlen (yyf);
1223 yysize_overflow |= (yysize1 < yysize);
1226 if (yysize_overflow)
1227 return YYSIZE_MAXIMUM;
1231 /* Avoid sprintf, as that infringes on the user's name space.
1232 Don't have undefined behavior even if the translation
1233 produced a string with the wrong number of "%s"s. */
1234 char *yyp = yyresult;
1236 while ((*yyp = *yyf) != '\0')
1238 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1240 yyp += yytnamerr (yyp, yyarg[yyi++]);
1253 #endif /* YYERROR_VERBOSE */
1256 /*-----------------------------------------------.
1257 | Release the memory associated to this symbol. |
1258 `-----------------------------------------------*/
1261 #if (defined __STDC__ || defined __C99__FUNC__ \
1262 || defined __cplusplus || defined _MSC_VER)
1264 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1267 yydestruct (yymsg, yytype, yyvaluep)
1277 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1287 /* Prevent warnings from -Wmissing-prototypes. */
1288 #ifdef YYPARSE_PARAM
1289 #if defined __STDC__ || defined __cplusplus
1290 int yyparse (void *YYPARSE_PARAM);
1294 #else /* ! YYPARSE_PARAM */
1295 #if defined __STDC__ || defined __cplusplus
1300 #endif /* ! YYPARSE_PARAM */
1303 /* The lookahead symbol. */
1306 /* The semantic value of the lookahead symbol. */
1309 /* Number of syntax errors so far. */
1314 /*-------------------------.
1315 | yyparse or yypush_parse. |
1316 `-------------------------*/
1318 #ifdef YYPARSE_PARAM
1319 #if (defined __STDC__ || defined __C99__FUNC__ \
1320 || defined __cplusplus || defined _MSC_VER)
1322 yyparse (void *YYPARSE_PARAM)
1325 yyparse (YYPARSE_PARAM)
1326 void *YYPARSE_PARAM;
1328 #else /* ! YYPARSE_PARAM */
1329 #if (defined __STDC__ || defined __C99__FUNC__ \
1330 || defined __cplusplus || defined _MSC_VER)
1343 /* Number of tokens to shift before error messages enabled. */
1346 /* The stacks and their tools:
1347 `yyss': related to states.
1348 `yyvs': related to semantic values.
1350 Refer to the stacks thru separate pointers, to allow yyoverflow
1351 to reallocate them elsewhere. */
1353 /* The state stack. */
1354 yytype_int16 yyssa[YYINITDEPTH];
1356 yytype_int16 *yyssp;
1358 /* The semantic value stack. */
1359 YYSTYPE yyvsa[YYINITDEPTH];
1363 YYSIZE_T yystacksize;
1367 /* Lookahead token as an internal (translated) token number. */
1369 /* The variables used to return semantic value and location from the
1374 /* Buffer for error messages, and its allocated size. */
1376 char *yymsg = yymsgbuf;
1377 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1380 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1382 /* The number of symbols on the RHS of the reduced rule.
1383 Keep to zero when no symbol should be popped. */
1389 yystacksize = YYINITDEPTH;
1391 YYDPRINTF ((stderr, "Starting parse\n"));
1396 yychar = YYEMPTY; /* Cause a token to be read. */
1398 /* Initialize stack pointers.
1399 Waste one element of value and location stack
1400 so that they stay on the same level as the state stack.
1401 The wasted elements are never initialized. */
1407 /*------------------------------------------------------------.
1408 | yynewstate -- Push a new state, which is found in yystate. |
1409 `------------------------------------------------------------*/
1411 /* In all cases, when you get here, the value and location stacks
1412 have just been pushed. So pushing a state here evens the stacks. */
1418 if (yyss + yystacksize - 1 <= yyssp)
1420 /* Get the current used size of the three stacks, in elements. */
1421 YYSIZE_T yysize = yyssp - yyss + 1;
1425 /* Give user a chance to reallocate the stack. Use copies of
1426 these so that the &'s don't force the real ones into
1428 YYSTYPE *yyvs1 = yyvs;
1429 yytype_int16 *yyss1 = yyss;
1431 /* Each stack pointer address is followed by the size of the
1432 data in use in that stack, in bytes. This used to be a
1433 conditional around just the two extra args, but that might
1434 be undefined if yyoverflow is a macro. */
1435 yyoverflow (YY_("memory exhausted"),
1436 &yyss1, yysize * sizeof (*yyssp),
1437 &yyvs1, yysize * sizeof (*yyvsp),
1443 #else /* no yyoverflow */
1444 # ifndef YYSTACK_RELOCATE
1445 goto yyexhaustedlab;
1447 /* Extend the stack our own way. */
1448 if (YYMAXDEPTH <= yystacksize)
1449 goto yyexhaustedlab;
1451 if (YYMAXDEPTH < yystacksize)
1452 yystacksize = YYMAXDEPTH;
1455 yytype_int16 *yyss1 = yyss;
1456 union yyalloc *yyptr =
1457 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1459 goto yyexhaustedlab;
1460 YYSTACK_RELOCATE (yyss_alloc, yyss);
1461 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1462 # undef YYSTACK_RELOCATE
1464 YYSTACK_FREE (yyss1);
1467 #endif /* no yyoverflow */
1469 yyssp = yyss + yysize - 1;
1470 yyvsp = yyvs + yysize - 1;
1472 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1473 (unsigned long int) yystacksize));
1475 if (yyss + yystacksize - 1 <= yyssp)
1479 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1481 if (yystate == YYFINAL)
1491 /* Do appropriate processing given the current state. Read a
1492 lookahead token if we need one and don't already have one. */
1494 /* First try to decide what to do without reference to lookahead token. */
1495 yyn = yypact[yystate];
1496 if (yyn == YYPACT_NINF)
1499 /* Not known => get a lookahead token if don't already have one. */
1501 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1502 if (yychar == YYEMPTY)
1504 YYDPRINTF ((stderr, "Reading a token: "));
1508 if (yychar <= YYEOF)
1510 yychar = yytoken = YYEOF;
1511 YYDPRINTF ((stderr, "Now at end of input.\n"));
1515 yytoken = YYTRANSLATE (yychar);
1516 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1519 /* If the proper action on seeing token YYTOKEN is to reduce or to
1520 detect an error, take that action. */
1522 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1527 if (yyn == 0 || yyn == YYTABLE_NINF)
1533 /* Count tokens shifted since error; after three, turn off error
1538 /* Shift the lookahead token. */
1539 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1541 /* Discard the shifted token. */
1550 /*-----------------------------------------------------------.
1551 | yydefault -- do the default action for the current state. |
1552 `-----------------------------------------------------------*/
1554 yyn = yydefact[yystate];
1560 /*-----------------------------.
1561 | yyreduce -- Do a reduction. |
1562 `-----------------------------*/
1564 /* yyn is the number of a rule to reduce with. */
1567 /* If YYLEN is nonzero, implement the default value of the action:
1570 Otherwise, the following line sets YYVAL to garbage.
1571 This behavior is undocumented and Bison
1572 users should not rely upon it. Assigning to YYVAL
1573 unconditionally makes the parser a bit smaller, and it avoids a
1574 GCC warning that YYVAL may be used uninitialized. */
1575 yyval = yyvsp[1-yylen];
1578 YY_REDUCE_PRINT (yyn);
1583 /* Line 1455 of yacc.c */
1584 #line 192 "getdate.y"
1592 /* Line 1455 of yacc.c */
1593 #line 195 "getdate.y"
1601 /* Line 1455 of yacc.c */
1602 #line 198 "getdate.y"
1610 /* Line 1455 of yacc.c */
1611 #line 201 "getdate.y"
1619 /* Line 1455 of yacc.c */
1620 #line 204 "getdate.y"
1628 /* Line 1455 of yacc.c */
1629 #line 210 "getdate.y"
1631 yyHour = (yyvsp[(1) - (2)].Number);
1634 yyMeridian = (yyvsp[(2) - (2)].Meridian);
1640 /* Line 1455 of yacc.c */
1641 #line 216 "getdate.y"
1643 yyHour = (yyvsp[(1) - (4)].Number);
1644 yyMinutes = (yyvsp[(3) - (4)].Number);
1646 yyMeridian = (yyvsp[(4) - (4)].Meridian);
1652 /* Line 1455 of yacc.c */
1653 #line 222 "getdate.y"
1655 yyHour = (yyvsp[(1) - (4)].Number);
1656 yyMinutes = (yyvsp[(3) - (4)].Number);
1659 yyTimezone = ((yyvsp[(4) - (4)].Number) < 0
1660 ? -(yyvsp[(4) - (4)].Number) % 100 + (-(yyvsp[(4) - (4)].Number) / 100) * 60
1661 : - ((yyvsp[(4) - (4)].Number) % 100 + ((yyvsp[(4) - (4)].Number) / 100) * 60));
1667 /* Line 1455 of yacc.c */
1668 #line 231 "getdate.y"
1670 yyHour = (yyvsp[(1) - (6)].Number);
1671 yyMinutes = (yyvsp[(3) - (6)].Number);
1672 yySeconds = (yyvsp[(5) - (6)].Number);
1673 yyMeridian = (yyvsp[(6) - (6)].Meridian);
1679 /* Line 1455 of yacc.c */
1680 #line 237 "getdate.y"
1682 yyHour = (yyvsp[(1) - (6)].Number);
1683 yyMinutes = (yyvsp[(3) - (6)].Number);
1684 yySeconds = (yyvsp[(5) - (6)].Number);
1687 yyTimezone = ((yyvsp[(6) - (6)].Number) < 0
1688 ? -(yyvsp[(6) - (6)].Number) % 100 + (-(yyvsp[(6) - (6)].Number) / 100) * 60
1689 : - ((yyvsp[(6) - (6)].Number) % 100 + ((yyvsp[(6) - (6)].Number) / 100) * 60));
1695 /* Line 1455 of yacc.c */
1696 #line 249 "getdate.y"
1698 yyTimezone = (yyvsp[(1) - (1)].Number);
1704 /* Line 1455 of yacc.c */
1705 #line 252 "getdate.y"
1707 yyTimezone = (yyvsp[(1) - (1)].Number) - 60;
1713 /* Line 1455 of yacc.c */
1714 #line 256 "getdate.y"
1716 yyTimezone = (yyvsp[(1) - (2)].Number) - 60;
1722 /* Line 1455 of yacc.c */
1723 #line 261 "getdate.y"
1726 yyDayNumber = (yyvsp[(1) - (1)].Number);
1732 /* Line 1455 of yacc.c */
1733 #line 265 "getdate.y"
1736 yyDayNumber = (yyvsp[(1) - (2)].Number);
1742 /* Line 1455 of yacc.c */
1743 #line 269 "getdate.y"
1745 yyDayOrdinal = (yyvsp[(1) - (2)].Number);
1746 yyDayNumber = (yyvsp[(2) - (2)].Number);
1752 /* Line 1455 of yacc.c */
1753 #line 275 "getdate.y"
1755 yyMonth = (yyvsp[(1) - (3)].Number);
1756 yyDay = (yyvsp[(3) - (3)].Number);
1762 /* Line 1455 of yacc.c */
1763 #line 279 "getdate.y"
1765 /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
1766 The goal in recognizing YYYY/MM/DD is solely to support legacy
1767 machine-generated dates like those in an RCS log listing. If
1768 you want portability, use the ISO 8601 format. */
1769 if ((yyvsp[(1) - (5)].Number) >= 1000)
1771 yyYear = (yyvsp[(1) - (5)].Number);
1772 yyMonth = (yyvsp[(3) - (5)].Number);
1773 yyDay = (yyvsp[(5) - (5)].Number);
1777 yyMonth = (yyvsp[(1) - (5)].Number);
1778 yyDay = (yyvsp[(3) - (5)].Number);
1779 yyYear = (yyvsp[(5) - (5)].Number);
1786 /* Line 1455 of yacc.c */
1787 #line 297 "getdate.y"
1789 /* ISO 8601 format. yyyy-mm-dd. */
1790 yyYear = (yyvsp[(1) - (3)].Number);
1791 yyMonth = -(yyvsp[(2) - (3)].Number);
1792 yyDay = -(yyvsp[(3) - (3)].Number);
1798 /* Line 1455 of yacc.c */
1799 #line 303 "getdate.y"
1801 /* e.g. 17-JUN-1992. */
1802 yyDay = (yyvsp[(1) - (3)].Number);
1803 yyMonth = (yyvsp[(2) - (3)].Number);
1804 yyYear = -(yyvsp[(3) - (3)].Number);
1810 /* Line 1455 of yacc.c */
1811 #line 309 "getdate.y"
1813 yyMonth = (yyvsp[(1) - (2)].Number);
1814 yyDay = (yyvsp[(2) - (2)].Number);
1820 /* Line 1455 of yacc.c */
1821 #line 313 "getdate.y"
1823 yyMonth = (yyvsp[(1) - (4)].Number);
1824 yyDay = (yyvsp[(2) - (4)].Number);
1825 yyYear = (yyvsp[(4) - (4)].Number);
1831 /* Line 1455 of yacc.c */
1832 #line 318 "getdate.y"
1834 yyMonth = (yyvsp[(2) - (2)].Number);
1835 yyDay = (yyvsp[(1) - (2)].Number);
1841 /* Line 1455 of yacc.c */
1842 #line 322 "getdate.y"
1844 yyMonth = (yyvsp[(2) - (3)].Number);
1845 yyDay = (yyvsp[(1) - (3)].Number);
1846 yyYear = (yyvsp[(3) - (3)].Number);
1852 /* Line 1455 of yacc.c */
1853 #line 329 "getdate.y"
1855 yyRelSeconds = -yyRelSeconds;
1856 yyRelMinutes = -yyRelMinutes;
1857 yyRelHour = -yyRelHour;
1858 yyRelDay = -yyRelDay;
1859 yyRelMonth = -yyRelMonth;
1860 yyRelYear = -yyRelYear;
1866 /* Line 1455 of yacc.c */
1867 #line 340 "getdate.y"
1869 yyRelYear += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1875 /* Line 1455 of yacc.c */
1876 #line 343 "getdate.y"
1878 yyRelYear += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1884 /* Line 1455 of yacc.c */
1885 #line 346 "getdate.y"
1893 /* Line 1455 of yacc.c */
1894 #line 349 "getdate.y"
1896 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1902 /* Line 1455 of yacc.c */
1903 #line 352 "getdate.y"
1905 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1911 /* Line 1455 of yacc.c */
1912 #line 355 "getdate.y"
1920 /* Line 1455 of yacc.c */
1921 #line 358 "getdate.y"
1923 yyRelDay += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1929 /* Line 1455 of yacc.c */
1930 #line 361 "getdate.y"
1932 yyRelDay += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1938 /* Line 1455 of yacc.c */
1939 #line 364 "getdate.y"
1947 /* Line 1455 of yacc.c */
1948 #line 367 "getdate.y"
1950 yyRelHour += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1956 /* Line 1455 of yacc.c */
1957 #line 370 "getdate.y"
1959 yyRelHour += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1965 /* Line 1455 of yacc.c */
1966 #line 373 "getdate.y"
1974 /* Line 1455 of yacc.c */
1975 #line 376 "getdate.y"
1977 yyRelMinutes += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1983 /* Line 1455 of yacc.c */
1984 #line 379 "getdate.y"
1986 yyRelMinutes += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1992 /* Line 1455 of yacc.c */
1993 #line 382 "getdate.y"
2001 /* Line 1455 of yacc.c */
2002 #line 385 "getdate.y"
2004 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
2010 /* Line 1455 of yacc.c */
2011 #line 388 "getdate.y"
2013 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
2019 /* Line 1455 of yacc.c */
2020 #line 391 "getdate.y"
2028 /* Line 1455 of yacc.c */
2029 #line 397 "getdate.y"
2031 if ((yyHaveTime != 0) && (yyHaveDate != 0) && (yyHaveRel == 0))
2032 yyYear = (yyvsp[(1) - (1)].Number);
2035 if ((yyvsp[(1) - (1)].Number)>10000)
2038 yyDay= ((yyvsp[(1) - (1)].Number))%100;
2039 yyMonth= ((yyvsp[(1) - (1)].Number)/100)%100;
2040 yyYear = (yyvsp[(1) - (1)].Number)/10000;
2045 if ((yyvsp[(1) - (1)].Number) < 100)
2047 yyHour = (yyvsp[(1) - (1)].Number);
2052 yyHour = (yyvsp[(1) - (1)].Number) / 100;
2053 yyMinutes = (yyvsp[(1) - (1)].Number) % 100;
2064 /* Line 1455 of yacc.c */
2065 #line 430 "getdate.y"
2067 (yyval.Meridian) = MER24;
2073 /* Line 1455 of yacc.c */
2074 #line 434 "getdate.y"
2076 (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
2082 /* Line 1455 of yacc.c */
2083 #line 2084 "getdate.c"
2086 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2090 YY_STACK_PRINT (yyss, yyssp);
2094 /* Now `shift' the result of the reduction. Determine what state
2095 that goes to, based on the state we popped back to and the rule
2096 number reduced by. */
2100 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2101 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2102 yystate = yytable[yystate];
2104 yystate = yydefgoto[yyn - YYNTOKENS];
2109 /*------------------------------------.
2110 | yyerrlab -- here on detecting error |
2111 `------------------------------------*/
2113 /* If not already recovering from an error, report this error. */
2117 #if ! YYERROR_VERBOSE
2118 yyerror (YY_("syntax error"));
2121 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2122 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2124 YYSIZE_T yyalloc = 2 * yysize;
2125 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2126 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2127 if (yymsg != yymsgbuf)
2128 YYSTACK_FREE (yymsg);
2129 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2131 yymsg_alloc = yyalloc;
2135 yymsg_alloc = sizeof yymsgbuf;
2139 if (0 < yysize && yysize <= yymsg_alloc)
2141 (void) yysyntax_error (yymsg, yystate, yychar);
2146 yyerror (YY_("syntax error"));
2148 goto yyexhaustedlab;
2156 if (yyerrstatus == 3)
2158 /* If just tried and failed to reuse lookahead token after an
2159 error, discard it. */
2161 if (yychar <= YYEOF)
2163 /* Return failure if at end of input. */
2164 if (yychar == YYEOF)
2169 yydestruct ("Error: discarding",
2175 /* Else will try to reuse lookahead token after shifting the error
2180 /*---------------------------------------------------.
2181 | yyerrorlab -- error raised explicitly by YYERROR. |
2182 `---------------------------------------------------*/
2185 /* Pacify compilers like GCC when the user code never invokes
2186 YYERROR and the label yyerrorlab therefore never appears in user
2188 if (/*CONSTCOND*/ 0)
2191 /* Do not reclaim the symbols of the rule which action triggered
2195 YY_STACK_PRINT (yyss, yyssp);
2200 /*-------------------------------------------------------------.
2201 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2202 `-------------------------------------------------------------*/
2204 yyerrstatus = 3; /* Each real token shifted decrements this. */
2208 yyn = yypact[yystate];
2209 if (yyn != YYPACT_NINF)
2212 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2220 /* Pop the current state because it cannot handle the error token. */
2225 yydestruct ("Error: popping",
2226 yystos[yystate], yyvsp);
2229 YY_STACK_PRINT (yyss, yyssp);
2235 /* Shift the error token. */
2236 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2242 /*-------------------------------------.
2243 | yyacceptlab -- YYACCEPT comes here. |
2244 `-------------------------------------*/
2249 /*-----------------------------------.
2250 | yyabortlab -- YYABORT comes here. |
2251 `-----------------------------------*/
2256 #if !defined(yyoverflow) || YYERROR_VERBOSE
2257 /*-------------------------------------------------.
2258 | yyexhaustedlab -- memory exhaustion comes here. |
2259 `-------------------------------------------------*/
2261 yyerror (YY_("memory exhausted"));
2267 if (yychar != YYEMPTY)
2268 yydestruct ("Cleanup: discarding lookahead",
2270 /* Do not reclaim the symbols of the rule which action triggered
2271 this YYABORT or YYACCEPT. */
2273 YY_STACK_PRINT (yyss, yyssp);
2274 while (yyssp != yyss)
2276 yydestruct ("Cleanup: popping",
2277 yystos[*yyssp], yyvsp);
2282 YYSTACK_FREE (yyss);
2285 if (yymsg != yymsgbuf)
2286 YYSTACK_FREE (yymsg);
2288 /* Make sure YYID is used. */
2289 return YYID (yyresult);
2294 /* Line 1675 of yacc.c */
2295 #line 439 "getdate.y"
2298 /* Month and day table. */
2299 static TABLE const MonthDayTable[] = {
2300 { "january", tMONTH, 1 },
2301 { "february", tMONTH, 2 },
2302 { "march", tMONTH, 3 },
2303 { "april", tMONTH, 4 },
2304 { "may", tMONTH, 5 },
2305 { "june", tMONTH, 6 },
2306 { "july", tMONTH, 7 },
2307 { "august", tMONTH, 8 },
2308 { "september", tMONTH, 9 },
2309 { "sept", tMONTH, 9 },
2310 { "october", tMONTH, 10 },
2311 { "november", tMONTH, 11 },
2312 { "december", tMONTH, 12 },
2313 { "sunday", tDAY, 0 },
2314 { "monday", tDAY, 1 },
2315 { "tuesday", tDAY, 2 },
2316 { "tues", tDAY, 2 },
2317 { "wednesday", tDAY, 3 },
2318 { "wednes", tDAY, 3 },
2319 { "thursday", tDAY, 4 },
2320 { "thur", tDAY, 4 },
2321 { "thurs", tDAY, 4 },
2322 { "friday", tDAY, 5 },
2323 { "saturday", tDAY, 6 },
2327 /* Time units table. */
2328 static TABLE const UnitsTable[] = {
2329 { "year", tYEAR_UNIT, 1 },
2330 { "month", tMONTH_UNIT, 1 },
2331 { "fortnight", tDAY_UNIT, 14 },
2332 { "week", tDAY_UNIT, 7 },
2333 { "day", tDAY_UNIT, 1 },
2334 { "hour", tHOUR_UNIT, 1 },
2335 { "minute", tMINUTE_UNIT, 1 },
2336 { "min", tMINUTE_UNIT, 1 },
2337 { "second", tSEC_UNIT, 1 },
2338 { "sec", tSEC_UNIT, 1 },
2342 /* Assorted relative-time words. */
2343 static TABLE const OtherTable[] = {
2344 { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
2345 { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
2346 { "today", tMINUTE_UNIT, 0 },
2347 { "now", tMINUTE_UNIT, 0 },
2348 { "last", tUNUMBER, -1 },
2349 { "this", tMINUTE_UNIT, 0 },
2350 { "next", tUNUMBER, 2 },
2351 { "first", tUNUMBER, 1 },
2352 /* { "second", tUNUMBER, 2 }, */
2353 { "third", tUNUMBER, 3 },
2354 { "fourth", tUNUMBER, 4 },
2355 { "fifth", tUNUMBER, 5 },
2356 { "sixth", tUNUMBER, 6 },
2357 { "seventh", tUNUMBER, 7 },
2358 { "eighth", tUNUMBER, 8 },
2359 { "ninth", tUNUMBER, 9 },
2360 { "tenth", tUNUMBER, 10 },
2361 { "eleventh", tUNUMBER, 11 },
2362 { "twelfth", tUNUMBER, 12 },
2367 /* The timezone table. */
2368 static TABLE const TimezoneTable[] = {
2369 { "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */
2370 { "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
2371 { "utc", tZONE, HOUR ( 0) },
2372 { "wet", tZONE, HOUR ( 0) }, /* Western European */
2373 { "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
2374 { "wat", tZONE, HOUR ( 1) }, /* West Africa */
2375 { "at", tZONE, HOUR ( 2) }, /* Azores */
2376 { "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
2377 { "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
2378 { "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
2379 { "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
2380 { "cst", tZONE, HOUR ( 6) }, /* Central Standard */
2381 { "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */
2382 { "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */
2383 { "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
2384 { "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */
2385 { "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
2386 { "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */
2387 { "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
2388 { "hst", tZONE, HOUR (10) }, /* Hawaii Standard */
2389 { "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
2390 { "cat", tZONE, HOUR (10) }, /* Central Alaska */
2391 { "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
2392 { "nt", tZONE, HOUR (11) }, /* Nome */
2393 { "idlw", tZONE, HOUR (12) }, /* International Date Line West */
2394 { "cet", tZONE, -HOUR (1) }, /* Central European */
2395 { "met", tZONE, -HOUR (1) }, /* Middle European */
2396 { "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */
2397 { "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
2398 { "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
2399 { "swt", tZONE, -HOUR (1) }, /* Swedish Winter */
2400 { "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */
2401 { "fwt", tZONE, -HOUR (1) }, /* French Winter */
2402 { "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
2403 { "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
2404 { "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
2405 { "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
2406 { "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
2407 { "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
2408 { "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
2409 { "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
2410 { "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
2411 { "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
2412 { "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
2413 { "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
2414 { "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
2415 { "nzt", tZONE, -HOUR (12) }, /* New Zealand */
2416 { "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
2417 { "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
2418 { "idle", tZONE, -HOUR (12) }, /* International Date Line East */
2422 /* Military timezone table. */
2423 static TABLE const MilitaryTable[] = {
2424 { "a", tZONE, HOUR ( 1) },
2425 { "b", tZONE, HOUR ( 2) },
2426 { "c", tZONE, HOUR ( 3) },
2427 { "d", tZONE, HOUR ( 4) },
2428 { "e", tZONE, HOUR ( 5) },
2429 { "f", tZONE, HOUR ( 6) },
2430 { "g", tZONE, HOUR ( 7) },
2431 { "h", tZONE, HOUR ( 8) },
2432 { "i", tZONE, HOUR ( 9) },
2433 { "k", tZONE, HOUR ( 10) },
2434 { "l", tZONE, HOUR ( 11) },
2435 { "m", tZONE, HOUR ( 12) },
2436 { "n", tZONE, HOUR (- 1) },
2437 { "o", tZONE, HOUR (- 2) },
2438 { "p", tZONE, HOUR (- 3) },
2439 { "q", tZONE, HOUR (- 4) },
2440 { "r", tZONE, HOUR (- 5) },
2441 { "s", tZONE, HOUR (- 6) },
2442 { "t", tZONE, HOUR (- 7) },
2443 { "u", tZONE, HOUR (- 8) },
2444 { "v", tZONE, HOUR (- 9) },
2445 { "w", tZONE, HOUR (-10) },
2446 { "x", tZONE, HOUR (-11) },
2447 { "y", tZONE, HOUR (-12) },
2448 { "z", tZONE, HOUR ( 0) },
2455 static int yyerror (unused const char *s)
2460 static int ToHour (int Hours, MERIDIAN Meridian)
2465 if (Hours < 0 || Hours > 23)
2469 if (Hours < 1 || Hours > 12)
2475 if (Hours < 1 || Hours > 12)
2486 static int ToYear (int Year)
2491 /* XPG4 suggests that years 00-68 map to 2000-2068, and
2492 years 69-99 map to 1969-1999. */
2495 else if (Year < 100)
2501 static int LookupWord (char *buff)
2505 register const TABLE *tp;
2509 /* Make it lowercase. */
2510 for (p = buff; '\0' != *p; p++)
2514 if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
2516 yylval.Meridian = MERam;
2519 if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
2521 yylval.Meridian = MERpm;
2525 /* See if we have an abbreviation for a month. */
2526 if (strlen (buff) == 3)
2528 else if (strlen (buff) == 4 && buff[3] == '.')
2536 for (tp = MonthDayTable; tp->name; tp++)
2540 if (strncmp (buff, tp->name, 3) == 0)
2542 yylval.Number = tp->value;
2546 else if (strcmp (buff, tp->name) == 0)
2548 yylval.Number = tp->value;
2553 for (tp = TimezoneTable; tp->name; tp++)
2554 if (strcmp (buff, tp->name) == 0)
2556 yylval.Number = tp->value;
2560 if (strcmp (buff, "dst") == 0)
2563 for (tp = UnitsTable; tp->name; tp++)
2564 if (strcmp (buff, tp->name) == 0)
2566 yylval.Number = tp->value;
2570 /* Strip off any plural and try the units table again. */
2571 i = strlen (buff) - 1;
2575 for (tp = UnitsTable; tp->name; tp++)
2576 if (strcmp (buff, tp->name) == 0)
2578 yylval.Number = tp->value;
2581 buff[i] = 's'; /* Put back for "this" in OtherTable. */
2584 for (tp = OtherTable; tp->name; tp++)
2585 if (strcmp (buff, tp->name) == 0)
2587 yylval.Number = tp->value;
2591 /* Military timezones. */
2592 if (buff[1] == '\0' && ISALPHA (*buff))
2594 for (tp = MilitaryTable; tp->name; tp++)
2595 if (strcmp (buff, tp->name) == 0)
2597 yylval.Number = tp->value;
2602 /* Drop out any periods and try the timezone table again. */
2603 for (i = 0, p = q = buff; '\0' != *q; q++)
2610 for (tp = TimezoneTable; NULL != tp->name; tp++)
2611 if (strcmp (buff, tp->name) == 0)
2613 yylval.Number = tp->value;
2631 while (ISSPACE (*yyInput))
2634 if (ISDIGIT (c = *yyInput) || c == '-' || c == '+')
2636 if (c == '-' || c == '+')
2638 sign = c == '-' ? -1 : 1;
2639 if (!ISDIGIT (*++yyInput))
2640 /* skip the '-' sign */
2645 for (yylval.Number = 0; ISDIGIT (c = *yyInput++);)
2646 yylval.Number = 10 * yylval.Number + c - '0';
2649 yylval.Number = -yylval.Number;
2650 return (0 != sign) ? tSNUMBER : tUNUMBER;
2654 for (p = buff; (c = *yyInput++, ISALPHA (c)) || c == '.';)
2655 if (p < &buff[sizeof buff - 1])
2659 return LookupWord (buff);
2678 #define TM_YEAR_ORIGIN 1900
2680 /* Yield A - B, measured in seconds. */
2681 static long difftm (struct tm *a, struct tm *b)
2683 int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
2684 int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
2686 /* difference in day of year */
2687 a->tm_yday - b->tm_yday
2688 /* + intervening leap days */
2689 + ((ay >> 2) - (by >> 2))
2690 - (ay / 100 - by / 100)
2691 + ((ay / 100 >> 2) - (by / 100 >> 2))
2692 /* + difference in years * 365 */
2693 + (long) (ay - by) * 365
2695 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
2696 + (a->tm_min - b->tm_min))
2697 + (a->tm_sec - b->tm_sec));
2700 time_t get_date (const char *p, const time_t *now)
2702 struct tm tm, tm0, *tmp;
2706 Start = now ? *now : time ((time_t *) NULL);
2707 tmp = localtime (&Start);
2708 yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
2709 yyMonth = tmp->tm_mon + 1;
2710 yyDay = tmp->tm_mday;
2711 yyHour = tmp->tm_hour;
2712 yyMinutes = tmp->tm_min;
2713 yySeconds = tmp->tm_sec;
2728 || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
2731 tm.tm_year = ToYear (yyYear) - TM_YEAR_ORIGIN + yyRelYear;
2732 tm.tm_mon = yyMonth - 1 + yyRelMonth;
2733 tm.tm_mday = yyDay + yyRelDay;
2734 if ((yyHaveTime != 0) ||
2735 ( (yyHaveRel != 0) && (yyHaveDate == 0) && (yyHaveDay == 0) ))
2737 tm.tm_hour = ToHour (yyHour, yyMeridian);
2740 tm.tm_min = yyMinutes;
2741 tm.tm_sec = yySeconds;
2745 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
2747 tm.tm_hour += yyRelHour;
2748 tm.tm_min += yyRelMinutes;
2749 tm.tm_sec += yyRelSeconds;
2753 Start = mktime (&tm);
2755 if (Start == (time_t) -1)
2758 /* Guard against falsely reporting errors near the time_t boundaries
2759 when parsing times in other time zones. For example, if the min
2760 time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
2761 of UTC, then the min localtime value is 1970-01-01 08:00:00; if
2762 we apply mktime to 1970-01-01 00:00:00 we will get an error, so
2763 we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
2764 zone by 24 hours to compensate. This algorithm assumes that
2765 there is no DST transition within a day of the time_t boundaries. */
2769 if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
2772 yyTimezone -= 24 * 60;
2777 yyTimezone += 24 * 60;
2779 Start = mktime (&tm);
2782 if (Start == (time_t) -1)
2786 if (yyHaveDay && !yyHaveDate)
2788 tm.tm_mday += ((yyDayNumber - tm.tm_wday + 7) % 7
2789 + 7 * (yyDayOrdinal - (0 < yyDayOrdinal)));
2790 Start = mktime (&tm);
2791 if (Start == (time_t) -1)
2797 long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
2798 if ((Start + delta < Start) != (delta < 0))
2799 return -1; /* time_t overflow */
2814 char buff[MAX_BUFF_LEN + 1];
2817 (void) printf ("Enter date, or blank line to exit.\n\t> ");
2818 (void) fflush (stdout);
2820 buff[MAX_BUFF_LEN] = 0;
2821 while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
2823 d = get_date (buff, (time_t *) NULL);
2825 (void) printf ("Bad format - couldn't convert.\n");
2827 (void) printf ("%s", ctime (&d));
2828 (void) printf ("\t> ");
2829 (void) fflush (stdout);
2834 #endif /* defined (TEST) */