s3:net_idmap_dump add missing braces
[Samba/gebeck_regimport.git] / source3 / modules / getdate.c
bloba27b75f7f1ec1870739a7e4ba36beccf1932f08f
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)
11 any later version.
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. */
47 #define YYBISON 1
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
55 /* Pure parsers. */
56 #define YYPURE 1
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
63 /* Tokens. */
64 #ifndef YYTOKENTYPE
65 # define YYTOKENTYPE
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
67 know about them. */
68 enum yytokentype {
69 tAGO = 258,
70 tDST = 259,
71 tDAY = 260,
72 tDAY_UNIT = 261,
73 tDAYZONE = 262,
74 tHOUR_UNIT = 263,
75 tLOCAL_ZONE = 264,
76 tMERIDIAN = 265,
77 tMINUTE_UNIT = 266,
78 tMONTH = 267,
79 tMONTH_UNIT = 268,
80 tSEC_UNIT = 269,
81 tYEAR_UNIT = 270,
82 tZONE = 271,
83 tSNUMBER = 272,
84 tUNUMBER = 273
86 #endif
87 /* Tokens. */
88 #define tAGO 258
89 #define tDST 259
90 #define tDAY 260
91 #define tDAY_UNIT 261
92 #define tDAYZONE 262
93 #define tHOUR_UNIT 263
94 #define tLOCAL_ZONE 264
95 #define tMERIDIAN 265
96 #define tMINUTE_UNIT 266
97 #define tMONTH 267
98 #define tMONTH_UNIT 268
99 #define tSEC_UNIT 269
100 #define tYEAR_UNIT 270
101 #define tZONE 271
102 #define tSNUMBER 272
103 #define tUNUMBER 273
108 /* Copy the first part of user declarations. */
109 #line 1 "getdate.y"
111 /* Parse a string into an internal time stamp.
112 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
114 This program is free software; you can redistribute it and/or modify
115 it under the terms of the GNU General Public License as published by
116 the Free Software Foundation; either version 2, or (at your option)
117 any later version.
119 This program is distributed in the hope that it will be useful,
120 but WITHOUT ANY WARRANTY; without even the implied warranty of
121 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
122 GNU General Public License for more details.
124 You should have received a copy of the GNU General Public License
125 along with this program; if not, see <http://www.gnu.org/licenses/>. */
127 /* Originally written by Steven M. Bellovin <smb@research.att.com> while
128 at the University of North Carolina at Chapel Hill. Later tweaked by
129 a couple of people on Usenet. Completely overhauled by Rich $alz
130 <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
132 Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do
133 the right thing about local DST. Unlike previous versions, this
134 version is reentrant. */
136 #ifdef HAVE_CONFIG_H
137 # include <config.h>
138 # ifdef HAVE_ALLOCA_H
139 # include <alloca.h>
140 # endif
141 #endif
143 /* Since the code of getdate.y is not included in the Emacs executable
144 itself, there is no need to #define static in this file. Even if
145 the code were included in the Emacs executable, it probably
146 wouldn't do any harm to #undef it here; this will only cause
147 problems if we try to write to a static variable, which I don't
148 think this code needs to do. */
149 #ifdef emacs
150 # undef static
151 #endif
153 #include <ctype.h>
154 #include <string.h>
156 #if HAVE_STDLIB_H
157 # include <stdlib.h> /* for `free'; used by Bison 1.27 */
158 #endif
160 #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
161 # define IN_CTYPE_DOMAIN(c) 1
162 #else
163 # define IN_CTYPE_DOMAIN(c) isascii (c)
164 #endif
166 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
167 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
168 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
169 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
171 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
172 - Its arg may be any int or unsigned int; it need not be an unsigned char.
173 - It's guaranteed to evaluate its argument exactly once.
174 - It's typically faster.
175 POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
176 ISDIGIT_LOCALE unless it's important to use the locale's definition
177 of `digit' even when the host does not conform to POSIX. */
178 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
180 #if STDC_HEADERS || HAVE_STRING_H
181 # include <string.h>
182 #endif
184 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
185 # define __attribute__(x)
186 #endif
188 #ifndef ATTRIBUTE_UNUSED
189 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
190 #endif
192 #define EPOCH_YEAR 1970
193 #define TM_YEAR_BASE 1900
195 #define HOUR(x) ((x) * 60)
197 /* An integer value, and the number of digits in its textual
198 representation. */
199 typedef struct
201 int value;
202 int digits;
203 } textint;
205 /* An entry in the lexical lookup table. */
206 typedef struct
208 char const *name;
209 int type;
210 int value;
211 } table;
213 /* Meridian: am, pm, or 24-hour style. */
214 enum { MERam, MERpm, MER24 };
216 /* Information passed to and from the parser. */
217 typedef struct
219 /* The input string remaining to be parsed. */
220 const char *input;
222 /* N, if this is the Nth Tuesday. */
223 int day_ordinal;
225 /* Day of week; Sunday is 0. */
226 int day_number;
228 /* tm_isdst flag for the local zone. */
229 int local_isdst;
231 /* Time zone, in minutes east of UTC. */
232 int time_zone;
234 /* Style used for time. */
235 int meridian;
237 /* Gregorian year, month, day, hour, minutes, and seconds. */
238 textint year;
239 int month;
240 int day;
241 int hour;
242 int minutes;
243 int seconds;
245 /* Relative year, month, day, hour, minutes, and seconds. */
246 int rel_year;
247 int rel_month;
248 int rel_day;
249 int rel_hour;
250 int rel_minutes;
251 int rel_seconds;
253 /* Counts of nonterminals of various flavors parsed so far. */
254 int dates_seen;
255 int days_seen;
256 int local_zones_seen;
257 int rels_seen;
258 int times_seen;
259 int zones_seen;
261 /* Table of local time zone abbrevations, terminated by a null entry. */
262 table local_time_zone_table[3];
263 } parser_control;
265 #define PC (* (parser_control *) parm)
266 #define YYLEX_PARAM parm
267 #define YYPARSE_PARAM parm
271 /* Enabling traces. */
272 #ifndef YYDEBUG
273 # define YYDEBUG 0
274 #endif
276 /* Enabling verbose error messages. */
277 #ifdef YYERROR_VERBOSE
278 # undef YYERROR_VERBOSE
279 # define YYERROR_VERBOSE 1
280 #else
281 # define YYERROR_VERBOSE 0
282 #endif
284 /* Enabling the token table. */
285 #ifndef YYTOKEN_TABLE
286 # define YYTOKEN_TABLE 0
287 #endif
289 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
290 typedef union YYSTYPE
291 #line 169 "getdate.y"
293 int intval;
294 textint textintval;
296 /* Line 187 of yacc.c. */
297 #line 298 "getdate.c"
298 YYSTYPE;
299 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
300 # define YYSTYPE_IS_DECLARED 1
301 # define YYSTYPE_IS_TRIVIAL 1
302 #endif
306 /* Copy the second part of user declarations. */
307 #line 174 "getdate.y"
310 static int yyerror(const char *);
311 static int yylex(YYSTYPE *, parser_control *);
315 /* Line 216 of yacc.c. */
316 #line 317 "getdate.c"
318 #ifdef short
319 # undef short
320 #endif
322 #ifdef YYTYPE_UINT8
323 typedef YYTYPE_UINT8 yytype_uint8;
324 #else
325 typedef unsigned char yytype_uint8;
326 #endif
328 #ifdef YYTYPE_INT8
329 typedef YYTYPE_INT8 yytype_int8;
330 #elif (defined __STDC__ || defined __C99__FUNC__ \
331 || defined __cplusplus || defined _MSC_VER)
332 typedef signed char yytype_int8;
333 #else
334 typedef short int yytype_int8;
335 #endif
337 #ifdef YYTYPE_UINT16
338 typedef YYTYPE_UINT16 yytype_uint16;
339 #else
340 typedef unsigned short int yytype_uint16;
341 #endif
343 #ifdef YYTYPE_INT16
344 typedef YYTYPE_INT16 yytype_int16;
345 #else
346 typedef short int yytype_int16;
347 #endif
349 #ifndef YYSIZE_T
350 # ifdef __SIZE_TYPE__
351 # define YYSIZE_T __SIZE_TYPE__
352 # elif defined size_t
353 # define YYSIZE_T size_t
354 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
355 || defined __cplusplus || defined _MSC_VER)
356 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
357 # define YYSIZE_T size_t
358 # else
359 # define YYSIZE_T unsigned int
360 # endif
361 #endif
363 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
365 #ifndef YY_
366 # if YYENABLE_NLS
367 # if ENABLE_NLS
368 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
369 # define YY_(msgid) dgettext ("bison-runtime", msgid)
370 # endif
371 # endif
372 # ifndef YY_
373 # define YY_(msgid) msgid
374 # endif
375 #endif
377 /* Suppress unused-variable warnings by "using" E. */
378 #if ! defined lint || defined __GNUC__
379 # define YYUSE(e) ((void) (e))
380 #else
381 # define YYUSE(e) /* empty */
382 #endif
384 /* Identity function, used to suppress warnings about constant conditions. */
385 #ifndef lint
386 # define YYID(n) (n)
387 #else
388 #if (defined __STDC__ || defined __C99__FUNC__ \
389 || defined __cplusplus || defined _MSC_VER)
390 static int
391 YYID (int i)
392 #else
393 static int
394 YYID (i)
395 int i;
396 #endif
398 return i;
400 #endif
402 #if ! defined yyoverflow || YYERROR_VERBOSE
404 /* The parser invokes alloca or malloc; define the necessary symbols. */
406 # ifdef YYSTACK_USE_ALLOCA
407 # if YYSTACK_USE_ALLOCA
408 # ifdef __GNUC__
409 # define YYSTACK_ALLOC __builtin_alloca
410 # elif defined __BUILTIN_VA_ARG_INCR
411 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
412 # elif defined _AIX
413 # define YYSTACK_ALLOC __alloca
414 # elif defined _MSC_VER
415 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
416 # define alloca _alloca
417 # else
418 # define YYSTACK_ALLOC alloca
419 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
420 || defined __cplusplus || defined _MSC_VER)
421 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
422 # ifndef _STDLIB_H
423 # define _STDLIB_H 1
424 # endif
425 # endif
426 # endif
427 # endif
428 # endif
430 # ifdef YYSTACK_ALLOC
431 /* Pacify GCC's `empty if-body' warning. */
432 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
433 # ifndef YYSTACK_ALLOC_MAXIMUM
434 /* The OS might guarantee only one guard page at the bottom of the stack,
435 and a page size can be as small as 4096 bytes. So we cannot safely
436 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
437 to allow for a few compiler-allocated temporary stack slots. */
438 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
439 # endif
440 # else
441 # define YYSTACK_ALLOC YYMALLOC
442 # define YYSTACK_FREE YYFREE
443 # ifndef YYSTACK_ALLOC_MAXIMUM
444 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
445 # endif
446 # if (defined __cplusplus && ! defined _STDLIB_H \
447 && ! ((defined YYMALLOC || defined malloc) \
448 && (defined YYFREE || defined free)))
449 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
450 # ifndef _STDLIB_H
451 # define _STDLIB_H 1
452 # endif
453 # endif
454 # ifndef YYMALLOC
455 # define YYMALLOC malloc
456 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
457 || defined __cplusplus || defined _MSC_VER)
458 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
459 # endif
460 # endif
461 # ifndef YYFREE
462 # define YYFREE free
463 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
464 || defined __cplusplus || defined _MSC_VER)
465 void free (void *); /* INFRINGES ON USER NAME SPACE */
466 # endif
467 # endif
468 # endif
469 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
472 #if (! defined yyoverflow \
473 && (! defined __cplusplus \
474 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
476 /* A type that is properly aligned for any stack member. */
477 union yyalloc
479 yytype_int16 yyss;
480 YYSTYPE yyvs;
483 /* The size of the maximum gap between one aligned stack and the next. */
484 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
486 /* The size of an array large to enough to hold all stacks, each with
487 N elements. */
488 # define YYSTACK_BYTES(N) \
489 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
490 + YYSTACK_GAP_MAXIMUM)
492 /* Copy COUNT objects from FROM to TO. The source and destination do
493 not overlap. */
494 # ifndef YYCOPY
495 # if defined __GNUC__ && 1 < __GNUC__
496 # define YYCOPY(To, From, Count) \
497 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
498 # else
499 # define YYCOPY(To, From, Count) \
500 do \
502 YYSIZE_T yyi; \
503 for (yyi = 0; yyi < (Count); yyi++) \
504 (To)[yyi] = (From)[yyi]; \
506 while (YYID (0))
507 # endif
508 # endif
510 /* Relocate STACK from its old location to the new one. The
511 local variables YYSIZE and YYSTACKSIZE give the old and new number of
512 elements in the stack, and YYPTR gives the new location of the
513 stack. Advance YYPTR to a properly aligned location for the next
514 stack. */
515 # define YYSTACK_RELOCATE(Stack) \
516 do \
518 YYSIZE_T yynewbytes; \
519 YYCOPY (&yyptr->Stack, Stack, yysize); \
520 Stack = &yyptr->Stack; \
521 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
522 yyptr += yynewbytes / sizeof (*yyptr); \
524 while (YYID (0))
526 #endif
528 /* YYFINAL -- State number of the termination state. */
529 #define YYFINAL 2
530 /* YYLAST -- Last index in YYTABLE. */
531 #define YYLAST 52
533 /* YYNTOKENS -- Number of terminals. */
534 #define YYNTOKENS 22
535 /* YYNNTS -- Number of nonterminals. */
536 #define YYNNTS 12
537 /* YYNRULES -- Number of rules. */
538 #define YYNRULES 54
539 /* YYNRULES -- Number of states. */
540 #define YYNSTATES 64
542 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
543 #define YYUNDEFTOK 2
544 #define YYMAXUTOK 273
546 #define YYTRANSLATE(YYX) \
547 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
549 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
550 static const yytype_uint8 yytranslate[] =
552 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 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, 2, 2, 2, 2, 2, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
578 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
579 15, 16, 17, 18
582 #if YYDEBUG
583 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
584 YYRHS. */
585 static const yytype_uint8 yyprhs[] =
587 0, 0, 3, 4, 7, 9, 11, 13, 15, 17,
588 19, 21, 24, 29, 34, 41, 48, 50, 53, 55,
589 57, 60, 62, 65, 68, 72, 78, 82, 86, 89,
590 94, 97, 101, 104, 106, 109, 112, 114, 117, 120,
591 122, 125, 128, 130, 133, 136, 138, 141, 144, 146,
592 149, 152, 154, 156, 157
595 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
596 static const yytype_int8 yyrhs[] =
598 23, 0, -1, -1, 23, 24, -1, 25, -1, 26,
599 -1, 27, -1, 29, -1, 28, -1, 30, -1, 32,
600 -1, 18, 10, -1, 18, 19, 18, 33, -1, 18,
601 19, 18, 17, -1, 18, 19, 18, 19, 18, 33,
602 -1, 18, 19, 18, 19, 18, 17, -1, 9, -1,
603 9, 4, -1, 16, -1, 7, -1, 16, 4, -1,
604 5, -1, 5, 20, -1, 18, 5, -1, 18, 21,
605 18, -1, 18, 21, 18, 21, 18, -1, 18, 17,
606 17, -1, 18, 12, 17, -1, 12, 18, -1, 12,
607 18, 20, 18, -1, 18, 12, -1, 18, 12, 18,
608 -1, 31, 3, -1, 31, -1, 18, 15, -1, 17,
609 15, -1, 15, -1, 18, 13, -1, 17, 13, -1,
610 13, -1, 18, 6, -1, 17, 6, -1, 6, -1,
611 18, 8, -1, 17, 8, -1, 8, -1, 18, 11,
612 -1, 17, 11, -1, 11, -1, 18, 14, -1, 17,
613 14, -1, 14, -1, 18, -1, -1, 10, -1
616 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
617 static const yytype_uint16 yyrline[] =
619 0, 192, 192, 194, 198, 200, 202, 204, 206, 208,
620 210, 214, 221, 228, 236, 243, 255, 257, 262, 264,
621 266, 271, 276, 281, 289, 294, 314, 321, 329, 334,
622 340, 345, 354, 363, 367, 369, 371, 373, 375, 377,
623 379, 381, 383, 385, 387, 389, 391, 393, 395, 397,
624 399, 401, 406, 443, 444
626 #endif
628 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
629 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
630 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
631 static const char *const yytname[] =
633 "$end", "error", "$undefined", "tAGO", "tDST", "tDAY", "tDAY_UNIT",
634 "tDAYZONE", "tHOUR_UNIT", "tLOCAL_ZONE", "tMERIDIAN", "tMINUTE_UNIT",
635 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tYEAR_UNIT", "tZONE", "tSNUMBER",
636 "tUNUMBER", "':'", "','", "'/'", "$accept", "spec", "item", "time",
637 "local_zone", "zone", "day", "date", "rel", "relunit", "number",
638 "o_merid", 0
640 #endif
642 # ifdef YYPRINT
643 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
644 token YYLEX-NUM. */
645 static const yytype_uint16 yytoknum[] =
647 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
648 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
649 44, 47
651 # endif
653 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
654 static const yytype_uint8 yyr1[] =
656 0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
657 24, 25, 25, 25, 25, 25, 26, 26, 27, 27,
658 27, 28, 28, 28, 29, 29, 29, 29, 29, 29,
659 29, 29, 30, 30, 31, 31, 31, 31, 31, 31,
660 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
661 31, 31, 32, 33, 33
664 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
665 static const yytype_uint8 yyr2[] =
667 0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
668 1, 2, 4, 4, 6, 6, 1, 2, 1, 1,
669 2, 1, 2, 2, 3, 5, 3, 3, 2, 4,
670 2, 3, 2, 1, 2, 2, 1, 2, 2, 1,
671 2, 2, 1, 2, 2, 1, 2, 2, 1, 2,
672 2, 1, 1, 0, 1
675 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
676 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
677 means the default is an error. */
678 static const yytype_uint8 yydefact[] =
680 2, 0, 1, 21, 42, 19, 45, 16, 48, 0,
681 39, 51, 36, 18, 0, 52, 3, 4, 5, 6,
682 8, 7, 9, 33, 10, 22, 17, 28, 20, 41,
683 44, 47, 38, 50, 35, 23, 40, 43, 11, 46,
684 30, 37, 49, 34, 0, 0, 0, 32, 0, 27,
685 31, 26, 53, 24, 29, 54, 13, 0, 12, 0,
686 53, 25, 15, 14
689 /* YYDEFGOTO[NTERM-NUM]. */
690 static const yytype_int8 yydefgoto[] =
692 -1, 1, 16, 17, 18, 19, 20, 21, 22, 23,
693 24, 58
696 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
697 STATE-NUM. */
698 #define YYPACT_NINF -17
699 static const yytype_int8 yypact[] =
701 -17, 0, -17, 1, -17, -17, -17, 19, -17, -14,
702 -17, -17, -17, 32, 26, 14, -17, -17, -17, -17,
703 -17, -17, -17, 27, -17, -17, -17, 22, -17, -17,
704 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
705 -16, -17, -17, -17, 29, 25, 30, -17, 31, -17,
706 -17, -17, 28, 23, -17, -17, -17, 33, -17, 34,
707 -7, -17, -17, -17
710 /* YYPGOTO[NTERM-NUM]. */
711 static const yytype_int8 yypgoto[] =
713 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
714 -17, -10
717 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
718 positive, shift that token. If negative, reduce the rule which
719 number is the opposite. If zero, do what YYDEFACT says.
720 If YYTABLE_NINF, syntax error. */
721 #define YYTABLE_NINF -1
722 static const yytype_uint8 yytable[] =
724 2, 49, 50, 55, 27, 3, 4, 5, 6, 7,
725 62, 8, 9, 10, 11, 12, 13, 14, 15, 35,
726 36, 25, 37, 26, 38, 39, 40, 41, 42, 43,
727 47, 44, 29, 45, 30, 46, 28, 31, 55, 32,
728 33, 34, 48, 52, 59, 56, 51, 57, 53, 54,
729 63, 60, 61
732 static const yytype_uint8 yycheck[] =
734 0, 17, 18, 10, 18, 5, 6, 7, 8, 9,
735 17, 11, 12, 13, 14, 15, 16, 17, 18, 5,
736 6, 20, 8, 4, 10, 11, 12, 13, 14, 15,
737 3, 17, 6, 19, 8, 21, 4, 11, 10, 13,
738 14, 15, 20, 18, 21, 17, 17, 19, 18, 18,
739 60, 18, 18
742 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
743 symbol of state STATE-NUM. */
744 static const yytype_uint8 yystos[] =
746 0, 23, 0, 5, 6, 7, 8, 9, 11, 12,
747 13, 14, 15, 16, 17, 18, 24, 25, 26, 27,
748 28, 29, 30, 31, 32, 20, 4, 18, 4, 6,
749 8, 11, 13, 14, 15, 5, 6, 8, 10, 11,
750 12, 13, 14, 15, 17, 19, 21, 3, 20, 17,
751 18, 17, 18, 18, 18, 10, 17, 19, 33, 21,
752 18, 18, 17, 33
755 #define yyerrok (yyerrstatus = 0)
756 #define yyclearin (yychar = YYEMPTY)
757 #define YYEMPTY (-2)
758 #define YYEOF 0
760 #define YYACCEPT goto yyacceptlab
761 #define YYABORT goto yyabortlab
762 #define YYERROR goto yyerrorlab
765 /* Like YYERROR except do call yyerror. This remains here temporarily
766 to ease the transition to the new meaning of YYERROR, for GCC.
767 Once GCC version 2 has supplanted version 1, this can go. */
769 #define YYFAIL goto yyerrlab
771 #define YYRECOVERING() (!!yyerrstatus)
773 #define YYBACKUP(Token, Value) \
774 do \
775 if (yychar == YYEMPTY && yylen == 1) \
777 yychar = (Token); \
778 yylval = (Value); \
779 yytoken = YYTRANSLATE (yychar); \
780 YYPOPSTACK (1); \
781 goto yybackup; \
783 else \
785 yyerror (YY_("syntax error: cannot back up")); \
786 YYERROR; \
788 while (YYID (0))
791 #define YYTERROR 1
792 #define YYERRCODE 256
795 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
796 If N is 0, then set CURRENT to the empty location which ends
797 the previous symbol: RHS[0] (always defined). */
799 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
800 #ifndef YYLLOC_DEFAULT
801 # define YYLLOC_DEFAULT(Current, Rhs, N) \
802 do \
803 if (YYID (N)) \
805 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
806 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
807 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
808 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
810 else \
812 (Current).first_line = (Current).last_line = \
813 YYRHSLOC (Rhs, 0).last_line; \
814 (Current).first_column = (Current).last_column = \
815 YYRHSLOC (Rhs, 0).last_column; \
817 while (YYID (0))
818 #endif
821 /* YY_LOCATION_PRINT -- Print the location on the stream.
822 This macro was not mandated originally: define only if we know
823 we won't break user code: when these are the locations we know. */
825 #ifndef YY_LOCATION_PRINT
826 # if YYLTYPE_IS_TRIVIAL
827 # define YY_LOCATION_PRINT(File, Loc) \
828 fprintf (File, "%d.%d-%d.%d", \
829 (Loc).first_line, (Loc).first_column, \
830 (Loc).last_line, (Loc).last_column)
831 # else
832 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
833 # endif
834 #endif
837 /* YYLEX -- calling `yylex' with the right arguments. */
839 #ifdef YYLEX_PARAM
840 # define YYLEX yylex (&yylval, YYLEX_PARAM)
841 #else
842 # define YYLEX yylex (&yylval)
843 #endif
845 /* Enable debugging if requested. */
846 #if YYDEBUG
848 # ifndef YYFPRINTF
849 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
850 # define YYFPRINTF fprintf
851 # endif
853 # define YYDPRINTF(Args) \
854 do { \
855 if (yydebug) \
856 YYFPRINTF Args; \
857 } while (YYID (0))
859 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
860 do { \
861 if (yydebug) \
863 YYFPRINTF (stderr, "%s ", Title); \
864 yy_symbol_print (stderr, \
865 Type, Value); \
866 YYFPRINTF (stderr, "\n"); \
868 } while (YYID (0))
871 /*--------------------------------.
872 | Print this symbol on YYOUTPUT. |
873 `--------------------------------*/
875 /*ARGSUSED*/
876 #if (defined __STDC__ || defined __C99__FUNC__ \
877 || defined __cplusplus || defined _MSC_VER)
878 static void
879 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
880 #else
881 static void
882 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
883 FILE *yyoutput;
884 int yytype;
885 YYSTYPE const * const yyvaluep;
886 #endif
888 if (!yyvaluep)
889 return;
890 # ifdef YYPRINT
891 if (yytype < YYNTOKENS)
892 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
893 # else
894 YYUSE (yyoutput);
895 # endif
896 switch (yytype)
898 default:
899 break;
904 /*--------------------------------.
905 | Print this symbol on YYOUTPUT. |
906 `--------------------------------*/
908 #if (defined __STDC__ || defined __C99__FUNC__ \
909 || defined __cplusplus || defined _MSC_VER)
910 static void
911 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
912 #else
913 static void
914 yy_symbol_print (yyoutput, yytype, yyvaluep)
915 FILE *yyoutput;
916 int yytype;
917 YYSTYPE const * const yyvaluep;
918 #endif
920 if (yytype < YYNTOKENS)
921 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
922 else
923 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
925 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
926 YYFPRINTF (yyoutput, ")");
929 /*------------------------------------------------------------------.
930 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
931 | TOP (included). |
932 `------------------------------------------------------------------*/
934 #if (defined __STDC__ || defined __C99__FUNC__ \
935 || defined __cplusplus || defined _MSC_VER)
936 static void
937 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
938 #else
939 static void
940 yy_stack_print (bottom, top)
941 yytype_int16 *bottom;
942 yytype_int16 *top;
943 #endif
945 YYFPRINTF (stderr, "Stack now");
946 for (; bottom <= top; ++bottom)
947 YYFPRINTF (stderr, " %d", *bottom);
948 YYFPRINTF (stderr, "\n");
951 # define YY_STACK_PRINT(Bottom, Top) \
952 do { \
953 if (yydebug) \
954 yy_stack_print ((Bottom), (Top)); \
955 } while (YYID (0))
958 /*------------------------------------------------.
959 | Report that the YYRULE is going to be reduced. |
960 `------------------------------------------------*/
962 #if (defined __STDC__ || defined __C99__FUNC__ \
963 || defined __cplusplus || defined _MSC_VER)
964 static void
965 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
966 #else
967 static void
968 yy_reduce_print (yyvsp, yyrule)
969 YYSTYPE *yyvsp;
970 int yyrule;
971 #endif
973 int yynrhs = yyr2[yyrule];
974 int yyi;
975 unsigned long int yylno = yyrline[yyrule];
976 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
977 yyrule - 1, yylno);
978 /* The symbols being reduced. */
979 for (yyi = 0; yyi < yynrhs; yyi++)
981 fprintf (stderr, " $%d = ", yyi + 1);
982 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
983 &(yyvsp[(yyi + 1) - (yynrhs)])
985 fprintf (stderr, "\n");
989 # define YY_REDUCE_PRINT(Rule) \
990 do { \
991 if (yydebug) \
992 yy_reduce_print (yyvsp, Rule); \
993 } while (YYID (0))
995 /* Nonzero means print parse trace. It is left uninitialized so that
996 multiple parsers can coexist. */
997 int yydebug;
998 #else /* !YYDEBUG */
999 # define YYDPRINTF(Args)
1000 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1001 # define YY_STACK_PRINT(Bottom, Top)
1002 # define YY_REDUCE_PRINT(Rule)
1003 #endif /* !YYDEBUG */
1006 /* YYINITDEPTH -- initial size of the parser's stacks. */
1007 #ifndef YYINITDEPTH
1008 # define YYINITDEPTH 200
1009 #endif
1011 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1012 if the built-in stack extension method is used).
1014 Do not make this value too large; the results are undefined if
1015 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1016 evaluated with infinite-precision integer arithmetic. */
1018 #ifndef YYMAXDEPTH
1019 # define YYMAXDEPTH 10000
1020 #endif
1024 #if YYERROR_VERBOSE
1026 # ifndef yystrlen
1027 # if defined __GLIBC__ && defined _STRING_H
1028 # define yystrlen strlen
1029 # else
1030 /* Return the length of YYSTR. */
1031 #if (defined __STDC__ || defined __C99__FUNC__ \
1032 || defined __cplusplus || defined _MSC_VER)
1033 static YYSIZE_T
1034 yystrlen (const char *yystr)
1035 #else
1036 static YYSIZE_T
1037 yystrlen (yystr)
1038 const char *yystr;
1039 #endif
1041 YYSIZE_T yylen;
1042 for (yylen = 0; yystr[yylen]; yylen++)
1043 continue;
1044 return yylen;
1046 # endif
1047 # endif
1049 # ifndef yystpcpy
1050 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1051 # define yystpcpy stpcpy
1052 # else
1053 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1054 YYDEST. */
1055 #if (defined __STDC__ || defined __C99__FUNC__ \
1056 || defined __cplusplus || defined _MSC_VER)
1057 static char *
1058 yystpcpy (char *yydest, const char *yysrc)
1059 #else
1060 static char *
1061 yystpcpy (yydest, yysrc)
1062 char *yydest;
1063 const char *yysrc;
1064 #endif
1066 char *yyd = yydest;
1067 const char *yys = yysrc;
1069 while ((*yyd++ = *yys++) != '\0')
1070 continue;
1072 return yyd - 1;
1074 # endif
1075 # endif
1077 # ifndef yytnamerr
1078 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1079 quotes and backslashes, so that it's suitable for yyerror. The
1080 heuristic is that double-quoting is unnecessary unless the string
1081 contains an apostrophe, a comma, or backslash (other than
1082 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1083 null, do not copy; instead, return the length of what the result
1084 would have been. */
1085 static YYSIZE_T
1086 yytnamerr (char *yyres, const char *yystr)
1088 if (*yystr == '"')
1090 YYSIZE_T yyn = 0;
1091 char const *yyp = yystr;
1093 for (;;)
1094 switch (*++yyp)
1096 case '\'':
1097 case ',':
1098 goto do_not_strip_quotes;
1100 case '\\':
1101 if (*++yyp != '\\')
1102 goto do_not_strip_quotes;
1103 /* Fall through. */
1104 default:
1105 if (yyres)
1106 yyres[yyn] = *yyp;
1107 yyn++;
1108 break;
1110 case '"':
1111 if (yyres)
1112 yyres[yyn] = '\0';
1113 return yyn;
1115 do_not_strip_quotes: ;
1118 if (! yyres)
1119 return yystrlen (yystr);
1121 return yystpcpy (yyres, yystr) - yyres;
1123 # endif
1125 /* Copy into YYRESULT an error message about the unexpected token
1126 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1127 including the terminating null byte. If YYRESULT is null, do not
1128 copy anything; just return the number of bytes that would be
1129 copied. As a special case, return 0 if an ordinary "syntax error"
1130 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1131 size calculation. */
1132 static YYSIZE_T
1133 yysyntax_error (char *yyresult, int yystate, int yychar)
1135 int yyn = yypact[yystate];
1137 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1138 return 0;
1139 else
1141 int yytype = YYTRANSLATE (yychar);
1142 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1143 YYSIZE_T yysize = yysize0;
1144 YYSIZE_T yysize1;
1145 int yysize_overflow = 0;
1146 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1147 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1148 int yyx;
1150 # if 0
1151 /* This is so xgettext sees the translatable formats that are
1152 constructed on the fly. */
1153 YY_("syntax error, unexpected %s");
1154 YY_("syntax error, unexpected %s, expecting %s");
1155 YY_("syntax error, unexpected %s, expecting %s or %s");
1156 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1157 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1158 # endif
1159 char *yyfmt;
1160 char const *yyf;
1161 static char const yyunexpected[] = "syntax error, unexpected %s";
1162 static char const yyexpecting[] = ", expecting %s";
1163 static char const yyor[] = " or %s";
1164 char yyformat[sizeof yyunexpected
1165 + sizeof yyexpecting - 1
1166 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1167 * (sizeof yyor - 1))];
1168 char const *yyprefix = yyexpecting;
1170 /* Start YYX at -YYN if negative to avoid negative indexes in
1171 YYCHECK. */
1172 int yyxbegin = yyn < 0 ? -yyn : 0;
1174 /* Stay within bounds of both yycheck and yytname. */
1175 int yychecklim = YYLAST - yyn + 1;
1176 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1177 int yycount = 1;
1179 yyarg[0] = yytname[yytype];
1180 yyfmt = yystpcpy (yyformat, yyunexpected);
1182 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1183 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1185 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1187 yycount = 1;
1188 yysize = yysize0;
1189 yyformat[sizeof yyunexpected - 1] = '\0';
1190 break;
1192 yyarg[yycount++] = yytname[yyx];
1193 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1194 yysize_overflow |= (yysize1 < yysize);
1195 yysize = yysize1;
1196 yyfmt = yystpcpy (yyfmt, yyprefix);
1197 yyprefix = yyor;
1200 yyf = YY_(yyformat);
1201 yysize1 = yysize + yystrlen (yyf);
1202 yysize_overflow |= (yysize1 < yysize);
1203 yysize = yysize1;
1205 if (yysize_overflow)
1206 return YYSIZE_MAXIMUM;
1208 if (yyresult)
1210 /* Avoid sprintf, as that infringes on the user's name space.
1211 Don't have undefined behavior even if the translation
1212 produced a string with the wrong number of "%s"s. */
1213 char *yyp = yyresult;
1214 int yyi = 0;
1215 while ((*yyp = *yyf) != '\0')
1217 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1219 yyp += yytnamerr (yyp, yyarg[yyi++]);
1220 yyf += 2;
1222 else
1224 yyp++;
1225 yyf++;
1229 return yysize;
1232 #endif /* YYERROR_VERBOSE */
1235 /*-----------------------------------------------.
1236 | Release the memory associated to this symbol. |
1237 `-----------------------------------------------*/
1239 /*ARGSUSED*/
1240 #if (defined __STDC__ || defined __C99__FUNC__ \
1241 || defined __cplusplus || defined _MSC_VER)
1242 static void
1243 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1244 #else
1245 static void
1246 yydestruct (yymsg, yytype, yyvaluep)
1247 const char *yymsg;
1248 int yytype;
1249 YYSTYPE *yyvaluep;
1250 #endif
1252 YYUSE (yyvaluep);
1254 if (!yymsg)
1255 yymsg = "Deleting";
1256 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1258 switch (yytype)
1261 default:
1262 break;
1267 /* Prevent warnings from -Wmissing-prototypes. */
1269 #ifdef YYPARSE_PARAM
1270 #if defined __STDC__ || defined __cplusplus
1271 int yyparse (void *YYPARSE_PARAM);
1272 #else
1273 int yyparse ();
1274 #endif
1275 #else /* ! YYPARSE_PARAM */
1276 #if defined __STDC__ || defined __cplusplus
1277 int yyparse (void);
1278 #else
1279 int yyparse ();
1280 #endif
1281 #endif /* ! YYPARSE_PARAM */
1288 /*----------.
1289 | yyparse. |
1290 `----------*/
1292 #ifdef YYPARSE_PARAM
1293 #if (defined __STDC__ || defined __C99__FUNC__ \
1294 || defined __cplusplus || defined _MSC_VER)
1296 yyparse (void *YYPARSE_PARAM)
1297 #else
1299 yyparse (YYPARSE_PARAM)
1300 void *YYPARSE_PARAM;
1301 #endif
1302 #else /* ! YYPARSE_PARAM */
1303 #if (defined __STDC__ || defined __C99__FUNC__ \
1304 || defined __cplusplus || defined _MSC_VER)
1306 yyparse (void)
1307 #else
1309 yyparse ()
1311 #endif
1312 #endif
1314 /* The look-ahead symbol. */
1315 int yychar;
1317 /* The semantic value of the look-ahead symbol. */
1318 YYSTYPE yylval;
1320 /* Number of syntax errors so far. */
1321 int yynerrs;
1323 int yystate;
1324 int yyn;
1325 int yyresult;
1326 /* Number of tokens to shift before error messages enabled. */
1327 int yyerrstatus;
1328 /* Look-ahead token as an internal (translated) token number. */
1329 int yytoken = 0;
1330 #if YYERROR_VERBOSE
1331 /* Buffer for error messages, and its allocated size. */
1332 char yymsgbuf[128];
1333 char *yymsg = yymsgbuf;
1334 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1335 #endif
1337 /* Three stacks and their tools:
1338 `yyss': related to states,
1339 `yyvs': related to semantic values,
1340 `yyls': related to locations.
1342 Refer to the stacks thru separate pointers, to allow yyoverflow
1343 to reallocate them elsewhere. */
1345 /* The state stack. */
1346 yytype_int16 yyssa[YYINITDEPTH];
1347 yytype_int16 *yyss = yyssa;
1348 yytype_int16 *yyssp;
1350 /* The semantic value stack. */
1351 YYSTYPE yyvsa[YYINITDEPTH];
1352 YYSTYPE *yyvs = yyvsa;
1353 YYSTYPE *yyvsp;
1357 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1359 YYSIZE_T yystacksize = YYINITDEPTH;
1361 /* The variables used to return semantic value and location from the
1362 action routines. */
1363 YYSTYPE yyval;
1366 /* The number of symbols on the RHS of the reduced rule.
1367 Keep to zero when no symbol should be popped. */
1368 int yylen = 0;
1370 YYDPRINTF ((stderr, "Starting parse\n"));
1372 yystate = 0;
1373 yyerrstatus = 0;
1374 yynerrs = 0;
1375 yychar = YYEMPTY; /* Cause a token to be read. */
1377 /* Initialize stack pointers.
1378 Waste one element of value and location stack
1379 so that they stay on the same level as the state stack.
1380 The wasted elements are never initialized. */
1382 yyssp = yyss;
1383 yyvsp = yyvs;
1385 goto yysetstate;
1387 /*------------------------------------------------------------.
1388 | yynewstate -- Push a new state, which is found in yystate. |
1389 `------------------------------------------------------------*/
1390 yynewstate:
1391 /* In all cases, when you get here, the value and location stacks
1392 have just been pushed. So pushing a state here evens the stacks. */
1393 yyssp++;
1395 yysetstate:
1396 *yyssp = yystate;
1398 if (yyss + yystacksize - 1 <= yyssp)
1400 /* Get the current used size of the three stacks, in elements. */
1401 YYSIZE_T yysize = yyssp - yyss + 1;
1403 #ifdef yyoverflow
1405 /* Give user a chance to reallocate the stack. Use copies of
1406 these so that the &'s don't force the real ones into
1407 memory. */
1408 YYSTYPE *yyvs1 = yyvs;
1409 yytype_int16 *yyss1 = yyss;
1412 /* Each stack pointer address is followed by the size of the
1413 data in use in that stack, in bytes. This used to be a
1414 conditional around just the two extra args, but that might
1415 be undefined if yyoverflow is a macro. */
1416 yyoverflow (YY_("memory exhausted"),
1417 &yyss1, yysize * sizeof (*yyssp),
1418 &yyvs1, yysize * sizeof (*yyvsp),
1420 &yystacksize);
1422 yyss = yyss1;
1423 yyvs = yyvs1;
1425 #else /* no yyoverflow */
1426 # ifndef YYSTACK_RELOCATE
1427 goto yyexhaustedlab;
1428 # else
1429 /* Extend the stack our own way. */
1430 if (YYMAXDEPTH <= yystacksize)
1431 goto yyexhaustedlab;
1432 yystacksize *= 2;
1433 if (YYMAXDEPTH < yystacksize)
1434 yystacksize = YYMAXDEPTH;
1437 yytype_int16 *yyss1 = yyss;
1438 union yyalloc *yyptr =
1439 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1440 if (! yyptr)
1441 goto yyexhaustedlab;
1442 YYSTACK_RELOCATE (yyss);
1443 YYSTACK_RELOCATE (yyvs);
1445 # undef YYSTACK_RELOCATE
1446 if (yyss1 != yyssa)
1447 YYSTACK_FREE (yyss1);
1449 # endif
1450 #endif /* no yyoverflow */
1452 yyssp = yyss + yysize - 1;
1453 yyvsp = yyvs + yysize - 1;
1456 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1457 (unsigned long int) yystacksize));
1459 if (yyss + yystacksize - 1 <= yyssp)
1460 YYABORT;
1463 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1465 goto yybackup;
1467 /*-----------.
1468 | yybackup. |
1469 `-----------*/
1470 yybackup:
1472 /* Do appropriate processing given the current state. Read a
1473 look-ahead token if we need one and don't already have one. */
1475 /* First try to decide what to do without reference to look-ahead token. */
1476 yyn = yypact[yystate];
1477 if (yyn == YYPACT_NINF)
1478 goto yydefault;
1480 /* Not known => get a look-ahead token if don't already have one. */
1482 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1483 if (yychar == YYEMPTY)
1485 YYDPRINTF ((stderr, "Reading a token: "));
1486 yychar = YYLEX;
1489 if (yychar <= YYEOF)
1491 yychar = yytoken = YYEOF;
1492 YYDPRINTF ((stderr, "Now at end of input.\n"));
1494 else
1496 yytoken = YYTRANSLATE (yychar);
1497 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1500 /* If the proper action on seeing token YYTOKEN is to reduce or to
1501 detect an error, take that action. */
1502 yyn += yytoken;
1503 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1504 goto yydefault;
1505 yyn = yytable[yyn];
1506 if (yyn <= 0)
1508 if (yyn == 0 || yyn == YYTABLE_NINF)
1509 goto yyerrlab;
1510 yyn = -yyn;
1511 goto yyreduce;
1514 if (yyn == YYFINAL)
1515 YYACCEPT;
1517 /* Count tokens shifted since error; after three, turn off error
1518 status. */
1519 if (yyerrstatus)
1520 yyerrstatus--;
1522 /* Shift the look-ahead token. */
1523 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1525 /* Discard the shifted token unless it is eof. */
1526 if (yychar != YYEOF)
1527 yychar = YYEMPTY;
1529 yystate = yyn;
1530 *++yyvsp = yylval;
1532 goto yynewstate;
1535 /*-----------------------------------------------------------.
1536 | yydefault -- do the default action for the current state. |
1537 `-----------------------------------------------------------*/
1538 yydefault:
1539 yyn = yydefact[yystate];
1540 if (yyn == 0)
1541 goto yyerrlab;
1542 goto yyreduce;
1545 /*-----------------------------.
1546 | yyreduce -- Do a reduction. |
1547 `-----------------------------*/
1548 yyreduce:
1549 /* yyn is the number of a rule to reduce with. */
1550 yylen = yyr2[yyn];
1552 /* If YYLEN is nonzero, implement the default value of the action:
1553 `$$ = $1'.
1555 Otherwise, the following line sets YYVAL to garbage.
1556 This behavior is undocumented and Bison
1557 users should not rely upon it. Assigning to YYVAL
1558 unconditionally makes the parser a bit smaller, and it avoids a
1559 GCC warning that YYVAL may be used uninitialized. */
1560 yyval = yyvsp[1-yylen];
1563 YY_REDUCE_PRINT (yyn);
1564 switch (yyn)
1566 case 4:
1567 #line 199 "getdate.y"
1568 { PC.times_seen++; ;}
1569 break;
1571 case 5:
1572 #line 201 "getdate.y"
1573 { PC.local_zones_seen++; ;}
1574 break;
1576 case 6:
1577 #line 203 "getdate.y"
1578 { PC.zones_seen++; ;}
1579 break;
1581 case 7:
1582 #line 205 "getdate.y"
1583 { PC.dates_seen++; ;}
1584 break;
1586 case 8:
1587 #line 207 "getdate.y"
1588 { PC.days_seen++; ;}
1589 break;
1591 case 9:
1592 #line 209 "getdate.y"
1593 { PC.rels_seen++; ;}
1594 break;
1596 case 11:
1597 #line 215 "getdate.y"
1599 PC.hour = (yyvsp[(1) - (2)].textintval).value;
1600 PC.minutes = 0;
1601 PC.seconds = 0;
1602 PC.meridian = (yyvsp[(2) - (2)].intval);
1604 break;
1606 case 12:
1607 #line 222 "getdate.y"
1609 PC.hour = (yyvsp[(1) - (4)].textintval).value;
1610 PC.minutes = (yyvsp[(3) - (4)].textintval).value;
1611 PC.seconds = 0;
1612 PC.meridian = (yyvsp[(4) - (4)].intval);
1614 break;
1616 case 13:
1617 #line 229 "getdate.y"
1619 PC.hour = (yyvsp[(1) - (4)].textintval).value;
1620 PC.minutes = (yyvsp[(3) - (4)].textintval).value;
1621 PC.meridian = MER24;
1622 PC.zones_seen++;
1623 PC.time_zone = (yyvsp[(4) - (4)].textintval).value % 100 + ((yyvsp[(4) - (4)].textintval).value / 100) * 60;
1625 break;
1627 case 14:
1628 #line 237 "getdate.y"
1630 PC.hour = (yyvsp[(1) - (6)].textintval).value;
1631 PC.minutes = (yyvsp[(3) - (6)].textintval).value;
1632 PC.seconds = (yyvsp[(5) - (6)].textintval).value;
1633 PC.meridian = (yyvsp[(6) - (6)].intval);
1635 break;
1637 case 15:
1638 #line 244 "getdate.y"
1640 PC.hour = (yyvsp[(1) - (6)].textintval).value;
1641 PC.minutes = (yyvsp[(3) - (6)].textintval).value;
1642 PC.seconds = (yyvsp[(5) - (6)].textintval).value;
1643 PC.meridian = MER24;
1644 PC.zones_seen++;
1645 PC.time_zone = (yyvsp[(6) - (6)].textintval).value % 100 + ((yyvsp[(6) - (6)].textintval).value / 100) * 60;
1647 break;
1649 case 16:
1650 #line 256 "getdate.y"
1651 { PC.local_isdst = (yyvsp[(1) - (1)].intval); ;}
1652 break;
1654 case 17:
1655 #line 258 "getdate.y"
1656 { PC.local_isdst = (yyvsp[(1) - (2)].intval) < 0 ? 1 : (yyvsp[(1) - (2)].intval) + 1; ;}
1657 break;
1659 case 18:
1660 #line 263 "getdate.y"
1661 { PC.time_zone = (yyvsp[(1) - (1)].intval); ;}
1662 break;
1664 case 19:
1665 #line 265 "getdate.y"
1666 { PC.time_zone = (yyvsp[(1) - (1)].intval) + 60; ;}
1667 break;
1669 case 20:
1670 #line 267 "getdate.y"
1671 { PC.time_zone = (yyvsp[(1) - (2)].intval) + 60; ;}
1672 break;
1674 case 21:
1675 #line 272 "getdate.y"
1677 PC.day_ordinal = 1;
1678 PC.day_number = (yyvsp[(1) - (1)].intval);
1680 break;
1682 case 22:
1683 #line 277 "getdate.y"
1685 PC.day_ordinal = 1;
1686 PC.day_number = (yyvsp[(1) - (2)].intval);
1688 break;
1690 case 23:
1691 #line 282 "getdate.y"
1693 PC.day_ordinal = (yyvsp[(1) - (2)].textintval).value;
1694 PC.day_number = (yyvsp[(2) - (2)].intval);
1696 break;
1698 case 24:
1699 #line 290 "getdate.y"
1701 PC.month = (yyvsp[(1) - (3)].textintval).value;
1702 PC.day = (yyvsp[(3) - (3)].textintval).value;
1704 break;
1706 case 25:
1707 #line 295 "getdate.y"
1709 /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
1710 otherwise as MM/DD/YY.
1711 The goal in recognizing YYYY/MM/DD is solely to support legacy
1712 machine-generated dates like those in an RCS log listing. If
1713 you want portability, use the ISO 8601 format. */
1714 if (4 <= (yyvsp[(1) - (5)].textintval).digits)
1716 PC.year = (yyvsp[(1) - (5)].textintval);
1717 PC.month = (yyvsp[(3) - (5)].textintval).value;
1718 PC.day = (yyvsp[(5) - (5)].textintval).value;
1720 else
1722 PC.month = (yyvsp[(1) - (5)].textintval).value;
1723 PC.day = (yyvsp[(3) - (5)].textintval).value;
1724 PC.year = (yyvsp[(5) - (5)].textintval);
1727 break;
1729 case 26:
1730 #line 315 "getdate.y"
1732 /* ISO 8601 format. YYYY-MM-DD. */
1733 PC.year = (yyvsp[(1) - (3)].textintval);
1734 PC.month = -(yyvsp[(2) - (3)].textintval).value;
1735 PC.day = -(yyvsp[(3) - (3)].textintval).value;
1737 break;
1739 case 27:
1740 #line 322 "getdate.y"
1742 /* e.g. 17-JUN-1992. */
1743 PC.day = (yyvsp[(1) - (3)].textintval).value;
1744 PC.month = (yyvsp[(2) - (3)].intval);
1745 PC.year.value = -(yyvsp[(3) - (3)].textintval).value;
1746 PC.year.digits = (yyvsp[(3) - (3)].textintval).digits;
1748 break;
1750 case 28:
1751 #line 330 "getdate.y"
1753 PC.month = (yyvsp[(1) - (2)].intval);
1754 PC.day = (yyvsp[(2) - (2)].textintval).value;
1756 break;
1758 case 29:
1759 #line 335 "getdate.y"
1761 PC.month = (yyvsp[(1) - (4)].intval);
1762 PC.day = (yyvsp[(2) - (4)].textintval).value;
1763 PC.year = (yyvsp[(4) - (4)].textintval);
1765 break;
1767 case 30:
1768 #line 341 "getdate.y"
1770 PC.day = (yyvsp[(1) - (2)].textintval).value;
1771 PC.month = (yyvsp[(2) - (2)].intval);
1773 break;
1775 case 31:
1776 #line 346 "getdate.y"
1778 PC.day = (yyvsp[(1) - (3)].textintval).value;
1779 PC.month = (yyvsp[(2) - (3)].intval);
1780 PC.year = (yyvsp[(3) - (3)].textintval);
1782 break;
1784 case 32:
1785 #line 355 "getdate.y"
1787 PC.rel_seconds = -PC.rel_seconds;
1788 PC.rel_minutes = -PC.rel_minutes;
1789 PC.rel_hour = -PC.rel_hour;
1790 PC.rel_day = -PC.rel_day;
1791 PC.rel_month = -PC.rel_month;
1792 PC.rel_year = -PC.rel_year;
1794 break;
1796 case 34:
1797 #line 368 "getdate.y"
1798 { PC.rel_year += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1799 break;
1801 case 35:
1802 #line 370 "getdate.y"
1803 { PC.rel_year += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1804 break;
1806 case 36:
1807 #line 372 "getdate.y"
1808 { PC.rel_year += (yyvsp[(1) - (1)].intval); ;}
1809 break;
1811 case 37:
1812 #line 374 "getdate.y"
1813 { PC.rel_month += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1814 break;
1816 case 38:
1817 #line 376 "getdate.y"
1818 { PC.rel_month += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1819 break;
1821 case 39:
1822 #line 378 "getdate.y"
1823 { PC.rel_month += (yyvsp[(1) - (1)].intval); ;}
1824 break;
1826 case 40:
1827 #line 380 "getdate.y"
1828 { PC.rel_day += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1829 break;
1831 case 41:
1832 #line 382 "getdate.y"
1833 { PC.rel_day += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1834 break;
1836 case 42:
1837 #line 384 "getdate.y"
1838 { PC.rel_day += (yyvsp[(1) - (1)].intval); ;}
1839 break;
1841 case 43:
1842 #line 386 "getdate.y"
1843 { PC.rel_hour += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1844 break;
1846 case 44:
1847 #line 388 "getdate.y"
1848 { PC.rel_hour += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1849 break;
1851 case 45:
1852 #line 390 "getdate.y"
1853 { PC.rel_hour += (yyvsp[(1) - (1)].intval); ;}
1854 break;
1856 case 46:
1857 #line 392 "getdate.y"
1858 { PC.rel_minutes += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1859 break;
1861 case 47:
1862 #line 394 "getdate.y"
1863 { PC.rel_minutes += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1864 break;
1866 case 48:
1867 #line 396 "getdate.y"
1868 { PC.rel_minutes += (yyvsp[(1) - (1)].intval); ;}
1869 break;
1871 case 49:
1872 #line 398 "getdate.y"
1873 { PC.rel_seconds += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1874 break;
1876 case 50:
1877 #line 400 "getdate.y"
1878 { PC.rel_seconds += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
1879 break;
1881 case 51:
1882 #line 402 "getdate.y"
1883 { PC.rel_seconds += (yyvsp[(1) - (1)].intval); ;}
1884 break;
1886 case 52:
1887 #line 407 "getdate.y"
1889 if (PC.dates_seen
1890 && ! PC.rels_seen && (PC.times_seen || 2 < (yyvsp[(1) - (1)].textintval).digits))
1891 PC.year = (yyvsp[(1) - (1)].textintval);
1892 else
1894 if (4 < (yyvsp[(1) - (1)].textintval).digits)
1896 PC.dates_seen++;
1897 PC.day = (yyvsp[(1) - (1)].textintval).value % 100;
1898 PC.month = ((yyvsp[(1) - (1)].textintval).value / 100) % 100;
1899 PC.year.value = (yyvsp[(1) - (1)].textintval).value / 10000;
1900 PC.year.digits = (yyvsp[(1) - (1)].textintval).digits - 4;
1902 else
1904 PC.times_seen++;
1905 if ((yyvsp[(1) - (1)].textintval).digits <= 2)
1907 PC.hour = (yyvsp[(1) - (1)].textintval).value;
1908 PC.minutes = 0;
1910 else
1912 PC.hour = (yyvsp[(1) - (1)].textintval).value / 100;
1913 PC.minutes = (yyvsp[(1) - (1)].textintval).value % 100;
1915 PC.seconds = 0;
1916 PC.meridian = MER24;
1920 break;
1922 case 53:
1923 #line 443 "getdate.y"
1924 { (yyval.intval) = MER24; ;}
1925 break;
1927 case 54:
1928 #line 445 "getdate.y"
1929 { (yyval.intval) = (yyvsp[(1) - (1)].intval); ;}
1930 break;
1933 /* Line 1267 of yacc.c. */
1934 #line 1935 "getdate.c"
1935 default: break;
1937 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1939 YYPOPSTACK (yylen);
1940 yylen = 0;
1941 YY_STACK_PRINT (yyss, yyssp);
1943 *++yyvsp = yyval;
1946 /* Now `shift' the result of the reduction. Determine what state
1947 that goes to, based on the state we popped back to and the rule
1948 number reduced by. */
1950 yyn = yyr1[yyn];
1952 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1953 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1954 yystate = yytable[yystate];
1955 else
1956 yystate = yydefgoto[yyn - YYNTOKENS];
1958 goto yynewstate;
1961 /*------------------------------------.
1962 | yyerrlab -- here on detecting error |
1963 `------------------------------------*/
1964 yyerrlab:
1965 /* If not already recovering from an error, report this error. */
1966 if (!yyerrstatus)
1968 ++yynerrs;
1969 #if ! YYERROR_VERBOSE
1970 yyerror (YY_("syntax error"));
1971 #else
1973 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1974 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1976 YYSIZE_T yyalloc = 2 * yysize;
1977 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1978 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1979 if (yymsg != yymsgbuf)
1980 YYSTACK_FREE (yymsg);
1981 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1982 if (yymsg)
1983 yymsg_alloc = yyalloc;
1984 else
1986 yymsg = yymsgbuf;
1987 yymsg_alloc = sizeof yymsgbuf;
1991 if (0 < yysize && yysize <= yymsg_alloc)
1993 (void) yysyntax_error (yymsg, yystate, yychar);
1994 yyerror (yymsg);
1996 else
1998 yyerror (YY_("syntax error"));
1999 if (yysize != 0)
2000 goto yyexhaustedlab;
2003 #endif
2008 if (yyerrstatus == 3)
2010 /* If just tried and failed to reuse look-ahead token after an
2011 error, discard it. */
2013 if (yychar <= YYEOF)
2015 /* Return failure if at end of input. */
2016 if (yychar == YYEOF)
2017 YYABORT;
2019 else
2021 yydestruct ("Error: discarding",
2022 yytoken, &yylval);
2023 yychar = YYEMPTY;
2027 /* Else will try to reuse look-ahead token after shifting the error
2028 token. */
2029 goto yyerrlab1;
2032 /*---------------------------------------------------.
2033 | yyerrorlab -- error raised explicitly by YYERROR. |
2034 `---------------------------------------------------*/
2035 yyerrorlab:
2037 /* Pacify compilers like GCC when the user code never invokes
2038 YYERROR and the label yyerrorlab therefore never appears in user
2039 code. */
2040 if (/*CONSTCOND*/ 0)
2041 goto yyerrorlab;
2043 /* Do not reclaim the symbols of the rule which action triggered
2044 this YYERROR. */
2045 YYPOPSTACK (yylen);
2046 yylen = 0;
2047 YY_STACK_PRINT (yyss, yyssp);
2048 yystate = *yyssp;
2049 goto yyerrlab1;
2052 /*-------------------------------------------------------------.
2053 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2054 `-------------------------------------------------------------*/
2055 yyerrlab1:
2056 yyerrstatus = 3; /* Each real token shifted decrements this. */
2058 for (;;)
2060 yyn = yypact[yystate];
2061 if (yyn != YYPACT_NINF)
2063 yyn += YYTERROR;
2064 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2066 yyn = yytable[yyn];
2067 if (0 < yyn)
2068 break;
2072 /* Pop the current state because it cannot handle the error token. */
2073 if (yyssp == yyss)
2074 YYABORT;
2077 yydestruct ("Error: popping",
2078 yystos[yystate], yyvsp);
2079 YYPOPSTACK (1);
2080 yystate = *yyssp;
2081 YY_STACK_PRINT (yyss, yyssp);
2084 if (yyn == YYFINAL)
2085 YYACCEPT;
2087 *++yyvsp = yylval;
2090 /* Shift the error token. */
2091 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2093 yystate = yyn;
2094 goto yynewstate;
2097 /*-------------------------------------.
2098 | yyacceptlab -- YYACCEPT comes here. |
2099 `-------------------------------------*/
2100 yyacceptlab:
2101 yyresult = 0;
2102 goto yyreturn;
2104 /*-----------------------------------.
2105 | yyabortlab -- YYABORT comes here. |
2106 `-----------------------------------*/
2107 yyabortlab:
2108 yyresult = 1;
2109 goto yyreturn;
2111 #ifndef yyoverflow
2112 /*-------------------------------------------------.
2113 | yyexhaustedlab -- memory exhaustion comes here. |
2114 `-------------------------------------------------*/
2115 yyexhaustedlab:
2116 yyerror (YY_("memory exhausted"));
2117 yyresult = 2;
2118 /* Fall through. */
2119 #endif
2121 yyreturn:
2122 if (yychar != YYEOF && yychar != YYEMPTY)
2123 yydestruct ("Cleanup: discarding lookahead",
2124 yytoken, &yylval);
2125 /* Do not reclaim the symbols of the rule which action triggered
2126 this YYABORT or YYACCEPT. */
2127 YYPOPSTACK (yylen);
2128 YY_STACK_PRINT (yyss, yyssp);
2129 while (yyssp != yyss)
2131 yydestruct ("Cleanup: popping",
2132 yystos[*yyssp], yyvsp);
2133 YYPOPSTACK (1);
2135 #ifndef yyoverflow
2136 if (yyss != yyssa)
2137 YYSTACK_FREE (yyss);
2138 #endif
2139 #if YYERROR_VERBOSE
2140 if (yymsg != yymsgbuf)
2141 YYSTACK_FREE (yymsg);
2142 #endif
2143 /* Make sure YYID is used. */
2144 return YYID (yyresult);
2148 #line 448 "getdate.y"
2151 /* Include this file down here because bison inserts code above which
2152 may define-away `const'. We want the prototype for get_date to have
2153 the same signature as the function definition. */
2154 #include "modules/getdate.h"
2156 #ifndef gmtime
2157 struct tm *gmtime (const time_t *);
2158 #endif
2159 #ifndef localtime
2160 struct tm *localtime (const time_t *);
2161 #endif
2162 #ifndef mktime
2163 time_t mktime (struct tm *);
2164 #endif
2166 static table const meridian_table[] =
2168 { "AM", tMERIDIAN, MERam },
2169 { "A.M.", tMERIDIAN, MERam },
2170 { "PM", tMERIDIAN, MERpm },
2171 { "P.M.", tMERIDIAN, MERpm },
2172 { 0, 0, 0 }
2175 static table const dst_table[] =
2177 { "DST", tDST, 0 }
2180 static table const month_and_day_table[] =
2182 { "JANUARY", tMONTH, 1 },
2183 { "FEBRUARY", tMONTH, 2 },
2184 { "MARCH", tMONTH, 3 },
2185 { "APRIL", tMONTH, 4 },
2186 { "MAY", tMONTH, 5 },
2187 { "JUNE", tMONTH, 6 },
2188 { "JULY", tMONTH, 7 },
2189 { "AUGUST", tMONTH, 8 },
2190 { "SEPTEMBER",tMONTH, 9 },
2191 { "SEPT", tMONTH, 9 },
2192 { "OCTOBER", tMONTH, 10 },
2193 { "NOVEMBER", tMONTH, 11 },
2194 { "DECEMBER", tMONTH, 12 },
2195 { "SUNDAY", tDAY, 0 },
2196 { "MONDAY", tDAY, 1 },
2197 { "TUESDAY", tDAY, 2 },
2198 { "TUES", tDAY, 2 },
2199 { "WEDNESDAY",tDAY, 3 },
2200 { "WEDNES", tDAY, 3 },
2201 { "THURSDAY", tDAY, 4 },
2202 { "THUR", tDAY, 4 },
2203 { "THURS", tDAY, 4 },
2204 { "FRIDAY", tDAY, 5 },
2205 { "SATURDAY", tDAY, 6 },
2206 { 0, 0, 0 }
2209 static table const time_units_table[] =
2211 { "YEAR", tYEAR_UNIT, 1 },
2212 { "MONTH", tMONTH_UNIT, 1 },
2213 { "FORTNIGHT",tDAY_UNIT, 14 },
2214 { "WEEK", tDAY_UNIT, 7 },
2215 { "DAY", tDAY_UNIT, 1 },
2216 { "HOUR", tHOUR_UNIT, 1 },
2217 { "MINUTE", tMINUTE_UNIT, 1 },
2218 { "MIN", tMINUTE_UNIT, 1 },
2219 { "SECOND", tSEC_UNIT, 1 },
2220 { "SEC", tSEC_UNIT, 1 },
2221 { 0, 0, 0 }
2224 /* Assorted relative-time words. */
2225 static table const relative_time_table[] =
2227 { "TOMORROW", tMINUTE_UNIT, 24 * 60 },
2228 { "YESTERDAY",tMINUTE_UNIT, - (24 * 60) },
2229 { "TODAY", tMINUTE_UNIT, 0 },
2230 { "NOW", tMINUTE_UNIT, 0 },
2231 { "LAST", tUNUMBER, -1 },
2232 { "THIS", tUNUMBER, 0 },
2233 { "NEXT", tUNUMBER, 1 },
2234 { "FIRST", tUNUMBER, 1 },
2235 /*{ "SECOND", tUNUMBER, 2 }, */
2236 { "THIRD", tUNUMBER, 3 },
2237 { "FOURTH", tUNUMBER, 4 },
2238 { "FIFTH", tUNUMBER, 5 },
2239 { "SIXTH", tUNUMBER, 6 },
2240 { "SEVENTH", tUNUMBER, 7 },
2241 { "EIGHTH", tUNUMBER, 8 },
2242 { "NINTH", tUNUMBER, 9 },
2243 { "TENTH", tUNUMBER, 10 },
2244 { "ELEVENTH", tUNUMBER, 11 },
2245 { "TWELFTH", tUNUMBER, 12 },
2246 { "AGO", tAGO, 1 },
2247 { 0, 0, 0 }
2250 /* The time zone table. This table is necessarily incomplete, as time
2251 zone abbreviations are ambiguous; e.g. Australians interpret "EST"
2252 as Eastern time in Australia, not as US Eastern Standard Time.
2253 You cannot rely on getdate to handle arbitrary time zone
2254 abbreviations; use numeric abbreviations like `-0500' instead. */
2255 static table const time_zone_table[] =
2257 { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */
2258 { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
2259 { "UTC", tZONE, HOUR ( 0) },
2260 { "WET", tZONE, HOUR ( 0) }, /* Western European */
2261 { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */
2262 { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */
2263 { "ART", tZONE, -HOUR ( 3) }, /* Argentina */
2264 { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */
2265 { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */
2266 { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */
2267 { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */
2268 { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */
2269 { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */
2270 { "CLT", tZONE, -HOUR ( 4) }, /* Chile */
2271 { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */
2272 { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */
2273 { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */
2274 { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */
2275 { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */
2276 { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */
2277 { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */
2278 { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */
2279 { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */
2280 { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */
2281 { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */
2282 { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */
2283 { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */
2284 { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */
2285 { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */
2286 { "WAT", tZONE, HOUR ( 1) }, /* West Africa */
2287 { "CET", tZONE, HOUR ( 1) }, /* Central European */
2288 { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */
2289 { "MET", tZONE, HOUR ( 1) }, /* Middle European */
2290 { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */
2291 { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */
2292 { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */
2293 { "EET", tZONE, HOUR ( 2) }, /* Eastern European */
2294 { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */
2295 { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */
2296 { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */
2297 { "EAT", tZONE, HOUR ( 3) }, /* East Africa */
2298 { "MSK", tZONE, HOUR ( 3) }, /* Moscow */
2299 { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */
2300 { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */
2301 { "SGT", tZONE, HOUR ( 8) }, /* Singapore */
2302 { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */
2303 { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */
2304 { "GST", tZONE, HOUR (10) }, /* Guam Standard */
2305 { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */
2306 { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */
2307 { 0, 0, 0 }
2310 /* Military time zone table. */
2311 static table const military_table[] =
2313 { "A", tZONE, -HOUR ( 1) },
2314 { "B", tZONE, -HOUR ( 2) },
2315 { "C", tZONE, -HOUR ( 3) },
2316 { "D", tZONE, -HOUR ( 4) },
2317 { "E", tZONE, -HOUR ( 5) },
2318 { "F", tZONE, -HOUR ( 6) },
2319 { "G", tZONE, -HOUR ( 7) },
2320 { "H", tZONE, -HOUR ( 8) },
2321 { "I", tZONE, -HOUR ( 9) },
2322 { "K", tZONE, -HOUR (10) },
2323 { "L", tZONE, -HOUR (11) },
2324 { "M", tZONE, -HOUR (12) },
2325 { "N", tZONE, HOUR ( 1) },
2326 { "O", tZONE, HOUR ( 2) },
2327 { "P", tZONE, HOUR ( 3) },
2328 { "Q", tZONE, HOUR ( 4) },
2329 { "R", tZONE, HOUR ( 5) },
2330 { "S", tZONE, HOUR ( 6) },
2331 { "T", tZONE, HOUR ( 7) },
2332 { "U", tZONE, HOUR ( 8) },
2333 { "V", tZONE, HOUR ( 9) },
2334 { "W", tZONE, HOUR (10) },
2335 { "X", tZONE, HOUR (11) },
2336 { "Y", tZONE, HOUR (12) },
2337 { "Z", tZONE, HOUR ( 0) },
2338 { 0, 0, 0 }
2343 static int
2344 to_hour (int hours, int meridian)
2346 switch (meridian)
2348 case MER24:
2349 return 0 <= hours && hours < 24 ? hours : -1;
2350 case MERam:
2351 return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
2352 case MERpm:
2353 return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
2354 default:
2355 abort ();
2357 /* NOTREACHED */
2358 return 0;
2361 static int
2362 to_year (textint textyear)
2364 int year = textyear.value;
2366 if (year < 0)
2367 year = -year;
2369 /* XPG4 suggests that years 00-68 map to 2000-2068, and
2370 years 69-99 map to 1969-1999. */
2371 if (textyear.digits == 2)
2372 year += year < 69 ? 2000 : 1900;
2374 return year;
2377 static table const *
2378 lookup_zone (parser_control const *pc, char const *name)
2380 table const *tp;
2382 /* Try local zone abbreviations first; they're more likely to be right. */
2383 for (tp = pc->local_time_zone_table; tp->name; tp++)
2384 if (strcmp (name, tp->name) == 0)
2385 return tp;
2387 for (tp = time_zone_table; tp->name; tp++)
2388 if (strcmp (name, tp->name) == 0)
2389 return tp;
2391 return 0;
2394 #if ! HAVE_TM_GMTOFF
2395 /* Yield the difference between *A and *B,
2396 measured in seconds, ignoring leap seconds.
2397 The body of this function is taken directly from the GNU C Library;
2398 see src/strftime.c. */
2399 static int
2400 tm_diff (struct tm const *a, struct tm const *b)
2402 /* Compute intervening leap days correctly even if year is negative.
2403 Take care to avoid int overflow in leap day calculations,
2404 but it's OK to assume that A and B are close to each other. */
2405 int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
2406 int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
2407 int a100 = a4 / 25 - (a4 % 25 < 0);
2408 int b100 = b4 / 25 - (b4 % 25 < 0);
2409 int a400 = a100 >> 2;
2410 int b400 = b100 >> 2;
2411 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
2412 int years = a->tm_year - b->tm_year;
2413 int days = (365 * years + intervening_leap_days
2414 + (a->tm_yday - b->tm_yday));
2415 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
2416 + (a->tm_min - b->tm_min))
2417 + (a->tm_sec - b->tm_sec));
2419 #endif /* ! HAVE_TM_GMTOFF */
2421 static table const *
2422 lookup_word (parser_control const *pc, char *word)
2424 char *p;
2425 char *q;
2426 size_t wordlen;
2427 table const *tp;
2428 int i;
2429 int abbrev;
2431 /* Make it uppercase. */
2432 for (p = word; *p; p++)
2433 if (ISLOWER ((unsigned char) *p))
2434 *p = toupper ((unsigned char) *p);
2436 for (tp = meridian_table; tp->name; tp++)
2437 if (strcmp (word, tp->name) == 0)
2438 return tp;
2440 /* See if we have an abbreviation for a month. */
2441 wordlen = strlen (word);
2442 abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.');
2444 for (tp = month_and_day_table; tp->name; tp++)
2445 if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0)
2446 return tp;
2448 if ((tp = lookup_zone (pc, word)))
2449 return tp;
2451 if (strcmp (word, dst_table[0].name) == 0)
2452 return dst_table;
2454 for (tp = time_units_table; tp->name; tp++)
2455 if (strcmp (word, tp->name) == 0)
2456 return tp;
2458 /* Strip off any plural and try the units table again. */
2459 if (word[wordlen - 1] == 'S')
2461 word[wordlen - 1] = '\0';
2462 for (tp = time_units_table; tp->name; tp++)
2463 if (strcmp (word, tp->name) == 0)
2464 return tp;
2465 word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */
2468 for (tp = relative_time_table; tp->name; tp++)
2469 if (strcmp (word, tp->name) == 0)
2470 return tp;
2472 /* Military time zones. */
2473 if (wordlen == 1)
2474 for (tp = military_table; tp->name; tp++)
2475 if (word[0] == tp->name[0])
2476 return tp;
2478 /* Drop out any periods and try the time zone table again. */
2479 for (i = 0, p = q = word; (*p = *q); q++)
2480 if (*q == '.')
2481 i = 1;
2482 else
2483 p++;
2484 if (i && (tp = lookup_zone (pc, word)))
2485 return tp;
2487 return 0;
2490 static int
2491 yylex (YYSTYPE *lvalp, parser_control *pc)
2493 unsigned char c;
2494 int count;
2496 for (;;)
2498 while (c = *pc->input, ISSPACE (c))
2499 pc->input++;
2501 if (ISDIGIT (c) || c == '-' || c == '+')
2503 char const *p;
2504 int sign;
2505 int value;
2506 if (c == '-' || c == '+')
2508 sign = c == '-' ? -1 : 1;
2509 c = *++pc->input;
2510 if (! ISDIGIT (c))
2511 /* skip the '-' sign */
2512 continue;
2514 else
2515 sign = 0;
2516 p = pc->input;
2517 value = 0;
2520 value = 10 * value + c - '0';
2521 c = *++p;
2523 while (ISDIGIT (c));
2524 lvalp->textintval.value = sign < 0 ? -value : value;
2525 lvalp->textintval.digits = p - pc->input;
2526 pc->input = p;
2527 return sign ? tSNUMBER : tUNUMBER;
2530 if (ISALPHA (c))
2532 char buff[20];
2533 char *p = buff;
2534 table const *tp;
2538 if (p < buff + sizeof buff - 1)
2539 *p++ = c;
2540 c = *++pc->input;
2542 while (ISALPHA (c) || c == '.');
2544 *p = '\0';
2545 tp = lookup_word (pc, buff);
2546 if (! tp)
2547 return '?';
2548 lvalp->intval = tp->value;
2549 return tp->type;
2552 if (c != '(')
2553 return *pc->input++;
2554 count = 0;
2557 c = *pc->input++;
2558 if (c == '\0')
2559 return c;
2560 if (c == '(')
2561 count++;
2562 else if (c == ')')
2563 count--;
2565 while (count > 0);
2569 /* Do nothing if the parser reports an error. */
2570 static int
2571 yyerror (const char *s ATTRIBUTE_UNUSED)
2573 return 0;
2576 /* Parse a date/time string P. Return the corresponding time_t value,
2577 or (time_t) -1 if there is an error. P can be an incomplete or
2578 relative time specification; if so, use *NOW as the basis for the
2579 returned time. */
2580 time_t
2581 get_date (const char *p, const time_t *now)
2583 time_t Start = now ? *now : time (0);
2584 struct tm *tmp = localtime (&Start);
2585 struct tm tm;
2586 struct tm tm0;
2587 parser_control pc;
2589 if (! tmp)
2590 return -1;
2592 pc.input = p;
2593 pc.year.value = tmp->tm_year + TM_YEAR_BASE;
2594 pc.year.digits = 4;
2595 pc.month = tmp->tm_mon + 1;
2596 pc.day = tmp->tm_mday;
2597 pc.hour = tmp->tm_hour;
2598 pc.minutes = tmp->tm_min;
2599 pc.seconds = tmp->tm_sec;
2600 tm.tm_isdst = tmp->tm_isdst;
2602 pc.meridian = MER24;
2603 pc.rel_seconds = 0;
2604 pc.rel_minutes = 0;
2605 pc.rel_hour = 0;
2606 pc.rel_day = 0;
2607 pc.rel_month = 0;
2608 pc.rel_year = 0;
2609 pc.dates_seen = 0;
2610 pc.days_seen = 0;
2611 pc.rels_seen = 0;
2612 pc.times_seen = 0;
2613 pc.local_zones_seen = 0;
2614 pc.zones_seen = 0;
2616 #if HAVE_STRUCT_TM_TM_ZONE
2617 pc.local_time_zone_table[0].name = tmp->tm_zone;
2618 pc.local_time_zone_table[0].type = tLOCAL_ZONE;
2619 pc.local_time_zone_table[0].value = tmp->tm_isdst;
2620 pc.local_time_zone_table[1].name = 0;
2622 /* Probe the names used in the next three calendar quarters, looking
2623 for a tm_isdst different from the one we already have. */
2625 int quarter;
2626 for (quarter = 1; quarter <= 3; quarter++)
2628 time_t probe = Start + quarter * (90 * 24 * 60 * 60);
2629 struct tm *probe_tm = localtime (&probe);
2630 if (probe_tm && probe_tm->tm_zone
2631 && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
2634 pc.local_time_zone_table[1].name = probe_tm->tm_zone;
2635 pc.local_time_zone_table[1].type = tLOCAL_ZONE;
2636 pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
2637 pc.local_time_zone_table[2].name = 0;
2639 break;
2643 #else
2644 #if HAVE_TZNAME
2646 # ifndef tzname
2647 extern char *tzname[];
2648 # endif
2649 int i;
2650 for (i = 0; i < 2; i++)
2652 pc.local_time_zone_table[i].name = tzname[i];
2653 pc.local_time_zone_table[i].type = tLOCAL_ZONE;
2654 pc.local_time_zone_table[i].value = i;
2656 pc.local_time_zone_table[i].name = 0;
2658 #else
2659 pc.local_time_zone_table[0].name = 0;
2660 #endif
2661 #endif
2663 if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
2664 && ! strcmp (pc.local_time_zone_table[0].name,
2665 pc.local_time_zone_table[1].name))
2667 /* This locale uses the same abbrevation for standard and
2668 daylight times. So if we see that abbreviation, we don't
2669 know whether it's daylight time. */
2670 pc.local_time_zone_table[0].value = -1;
2671 pc.local_time_zone_table[1].name = 0;
2674 if (yyparse (&pc) != 0
2675 || 1 < pc.times_seen || 1 < pc.dates_seen || 1 < pc.days_seen
2676 || 1 < (pc.local_zones_seen + pc.zones_seen)
2677 || (pc.local_zones_seen && 1 < pc.local_isdst))
2678 return -1;
2680 tm.tm_year = to_year (pc.year) - TM_YEAR_BASE + pc.rel_year;
2681 tm.tm_mon = pc.month - 1 + pc.rel_month;
2682 tm.tm_mday = pc.day + pc.rel_day;
2683 if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
2685 tm.tm_hour = to_hour (pc.hour, pc.meridian);
2686 if (tm.tm_hour < 0)
2687 return -1;
2688 tm.tm_min = pc.minutes;
2689 tm.tm_sec = pc.seconds;
2691 else
2693 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
2696 /* Let mktime deduce tm_isdst if we have an absolute time stamp,
2697 or if the relative time stamp mentions days, months, or years. */
2698 if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day
2699 | pc.rel_month | pc.rel_year)
2700 tm.tm_isdst = -1;
2702 /* But if the input explicitly specifies local time with or without
2703 DST, give mktime that information. */
2704 if (pc.local_zones_seen)
2705 tm.tm_isdst = pc.local_isdst;
2707 tm0 = tm;
2709 Start = mktime (&tm);
2711 if (Start == (time_t) -1)
2714 /* Guard against falsely reporting errors near the time_t boundaries
2715 when parsing times in other time zones. For example, if the min
2716 time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
2717 of UTC, then the min localtime value is 1970-01-01 08:00:00; if
2718 we apply mktime to 1970-01-01 00:00:00 we will get an error, so
2719 we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
2720 zone by 24 hours to compensate. This algorithm assumes that
2721 there is no DST transition within a day of the time_t boundaries. */
2722 if (pc.zones_seen)
2724 tm = tm0;
2725 if (tm.tm_year <= EPOCH_YEAR - TM_YEAR_BASE)
2727 tm.tm_mday++;
2728 pc.time_zone += 24 * 60;
2730 else
2732 tm.tm_mday--;
2733 pc.time_zone -= 24 * 60;
2735 Start = mktime (&tm);
2738 if (Start == (time_t) -1)
2739 return Start;
2742 if (pc.days_seen && ! pc.dates_seen)
2744 tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
2745 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
2746 tm.tm_isdst = -1;
2747 Start = mktime (&tm);
2748 if (Start == (time_t) -1)
2749 return Start;
2752 if (pc.zones_seen)
2754 int delta = pc.time_zone * 60;
2755 #ifdef HAVE_TM_GMTOFF
2756 delta -= tm.tm_gmtoff;
2757 #else
2758 struct tm *gmt = gmtime (&Start);
2759 if (! gmt)
2760 return -1;
2761 delta -= tm_diff (&tm, gmt);
2762 #endif
2763 if ((Start < Start - delta) != (delta < 0))
2764 return -1; /* time_t overflow */
2765 Start -= delta;
2768 /* Add relative hours, minutes, and seconds. Ignore leap seconds;
2769 i.e. "+ 10 minutes" means 600 seconds, even if one of them is a
2770 leap second. Typically this is not what the user wants, but it's
2771 too hard to do it the other way, because the time zone indicator
2772 must be applied before relative times, and if mktime is applied
2773 again the time zone will be lost. */
2775 time_t t0 = Start;
2776 long d1 = 60 * 60 * (long) pc.rel_hour;
2777 time_t t1 = t0 + d1;
2778 long d2 = 60 * (long) pc.rel_minutes;
2779 time_t t2 = t1 + d2;
2780 int d3 = pc.rel_seconds;
2781 time_t t3 = t2 + d3;
2782 if ((d1 / (60 * 60) ^ pc.rel_hour)
2783 | (d2 / 60 ^ pc.rel_minutes)
2784 | ((t0 + d1 < t0) ^ (d1 < 0))
2785 | ((t1 + d2 < t1) ^ (d2 < 0))
2786 | ((t2 + d3 < t2) ^ (d3 < 0)))
2787 return -1;
2788 Start = t3;
2791 return Start;
2794 #if TEST
2796 #include <stdio.h>
2799 main (int ac, char **av)
2801 char buff[BUFSIZ];
2802 time_t d;
2804 printf ("Enter date, or blank line to exit.\n\t> ");
2805 fflush (stdout);
2807 buff[BUFSIZ - 1] = 0;
2808 while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
2810 d = get_date (buff, 0);
2811 if (d == (time_t) -1)
2812 printf ("Bad format - couldn't convert.\n");
2813 else
2814 printf ("%s", ctime (&d));
2815 printf ("\t> ");
2816 fflush (stdout);
2818 return 0;
2820 #endif /* defined TEST */