1 /* A Bison parser, made by GNU Bison 3.0.4. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "3.0.4"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
65 #line 1 "source3/modules/getdate.y" /* yacc.c:339 */
67 /* Parse a string into an internal time stamp.
68 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
70 This program is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 2, or (at your option)
75 This program is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 GNU General Public License for more details.
80 You should have received a copy of the GNU General Public License
81 along with this program; if not, see <http://www.gnu.org/licenses/>. */
83 /* Originally written by Steven M. Bellovin <smb@research.att.com> while
84 at the University of North Carolina at Chapel Hill. Later tweaked by
85 a couple of people on Usenet. Completely overhauled by Rich $alz
86 <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
88 Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do
89 the right thing about local DST. Unlike previous versions, this
90 version is reentrant. */
99 /* Since the code of getdate.y is not included in the Emacs executable
100 itself, there is no need to #define static in this file. Even if
101 the code were included in the Emacs executable, it probably
102 wouldn't do any harm to #undef it here; this will only cause
103 problems if we try to write to a static variable, which I don't
104 think this code needs to do. */
113 # include <stdlib.h> /* for `free'; used by Bison 1.27 */
116 #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
117 # define IN_CTYPE_DOMAIN(c) 1
119 # define IN_CTYPE_DOMAIN(c) isascii (c)
122 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
123 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
124 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
125 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
127 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
128 - Its arg may be any int or unsigned int; it need not be an unsigned char.
129 - It's guaranteed to evaluate its argument exactly once.
130 - It's typically faster.
131 POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
132 ISDIGIT_LOCALE unless it's important to use the locale's definition
133 of `digit' even when the host does not conform to POSIX. */
134 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
136 #if STDC_HEADERS || HAVE_STRING_H
140 #ifndef HAVE___ATTRIBUTE__
141 # define __attribute__(x)
144 #ifndef ATTRIBUTE_UNUSED
145 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
148 #define EPOCH_YEAR 1970
149 #define TM_YEAR_BASE 1900
151 #define HOUR(x) ((x) * 60)
153 /* An integer value, and the number of digits in its textual
161 /* An entry in the lexical lookup table. */
169 /* Meridian: am, pm, or 24-hour style. */
170 enum { MERam
, MERpm
, MER24
};
172 /* Information passed to and from the parser. */
173 struct parser_control
175 /* The input string remaining to be parsed. */
178 /* N, if this is the Nth Tuesday. */
181 /* Day of week; Sunday is 0. */
184 /* tm_isdst flag for the local zone. */
187 /* Time zone, in minutes east of UTC. */
190 /* Style used for time. */
193 /* Gregorian year, month, day, hour, minutes, and seconds. */
201 /* Relative year, month, day, hour, minutes, and seconds. */
209 /* Counts of nonterminals of various flavors parsed so far. */
212 int local_zones_seen
;
217 /* Table of local time zone abbrevations, terminated by a null entry. */
218 table local_time_zone_table
[3];
222 #line 223 "source3/modules/getdate.c" /* yacc.c:339 */
225 # if defined __cplusplus && 201103L <= __cplusplus
226 # define YY_NULLPTR nullptr
228 # define YY_NULLPTR 0
232 /* Enabling verbose error messages. */
233 #ifdef YYERROR_VERBOSE
234 # undef YYERROR_VERBOSE
235 # define YYERROR_VERBOSE 1
237 # define YYERROR_VERBOSE 0
274 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
278 #line 168 "source3/modules/getdate.y" /* yacc.c:355 */
283 #line 284 "source3/modules/getdate.c" /* yacc.c:355 */
286 typedef union YYSTYPE YYSTYPE
;
287 # define YYSTYPE_IS_TRIVIAL 1
288 # define YYSTYPE_IS_DECLARED 1
293 int yyparse (struct parser_control
*pc
);
297 /* Copy the second part of user declarations. */
298 #line 173 "source3/modules/getdate.y" /* yacc.c:358 */
301 static int yyerror(struct parser_control
*, const char *);
302 static int yylex(YYSTYPE
*, struct parser_control
*);
305 #line 306 "source3/modules/getdate.c" /* yacc.c:358 */
312 typedef YYTYPE_UINT8 yytype_uint8
;
314 typedef unsigned char yytype_uint8
;
318 typedef YYTYPE_INT8 yytype_int8
;
320 typedef signed char yytype_int8
;
324 typedef YYTYPE_UINT16 yytype_uint16
;
326 typedef unsigned short int yytype_uint16
;
330 typedef YYTYPE_INT16 yytype_int16
;
332 typedef short int yytype_int16
;
336 # ifdef __SIZE_TYPE__
337 # define YYSIZE_T __SIZE_TYPE__
338 # elif defined size_t
339 # define YYSIZE_T size_t
340 # elif ! defined YYSIZE_T
341 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
342 # define YYSIZE_T size_t
344 # define YYSIZE_T unsigned int
348 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
351 # if defined YYENABLE_NLS && YYENABLE_NLS
353 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
354 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
358 # define YY_(Msgid) Msgid
363 # if (defined __GNUC__ \
364 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
365 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
366 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
368 # define YY_ATTRIBUTE(Spec) /* empty */
372 #ifndef YY_ATTRIBUTE_PURE
373 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
376 #ifndef YY_ATTRIBUTE_UNUSED
377 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
380 #if !defined _Noreturn \
381 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
382 # if defined _MSC_VER && 1200 <= _MSC_VER
383 # define _Noreturn __declspec (noreturn)
385 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
389 /* Suppress unused-variable warnings by "using" E. */
390 #if ! defined lint || defined __GNUC__
391 # define YYUSE(E) ((void) (E))
393 # define YYUSE(E) /* empty */
396 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
397 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
398 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
399 _Pragma ("GCC diagnostic push") \
400 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
401 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
402 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
403 _Pragma ("GCC diagnostic pop")
405 # define YY_INITIAL_VALUE(Value) Value
407 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
408 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
409 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
411 #ifndef YY_INITIAL_VALUE
412 # define YY_INITIAL_VALUE(Value) /* Nothing. */
416 #if ! defined yyoverflow || YYERROR_VERBOSE
418 /* The parser invokes alloca or malloc; define the necessary symbols. */
420 # ifdef YYSTACK_USE_ALLOCA
421 # if YYSTACK_USE_ALLOCA
423 # define YYSTACK_ALLOC __builtin_alloca
424 # elif defined __BUILTIN_VA_ARG_INCR
425 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
427 # define YYSTACK_ALLOC __alloca
428 # elif defined _MSC_VER
429 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
430 # define alloca _alloca
432 # define YYSTACK_ALLOC alloca
433 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
434 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
435 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
436 # ifndef EXIT_SUCCESS
437 # define EXIT_SUCCESS 0
444 # ifdef YYSTACK_ALLOC
445 /* Pacify GCC's 'empty if-body' warning. */
446 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
447 # ifndef YYSTACK_ALLOC_MAXIMUM
448 /* The OS might guarantee only one guard page at the bottom of the stack,
449 and a page size can be as small as 4096 bytes. So we cannot safely
450 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
451 to allow for a few compiler-allocated temporary stack slots. */
452 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
455 # define YYSTACK_ALLOC YYMALLOC
456 # define YYSTACK_FREE YYFREE
457 # ifndef YYSTACK_ALLOC_MAXIMUM
458 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
460 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
461 && ! ((defined YYMALLOC || defined malloc) \
462 && (defined YYFREE || defined free)))
463 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
464 # ifndef EXIT_SUCCESS
465 # define EXIT_SUCCESS 0
469 # define YYMALLOC malloc
470 # if ! defined malloc && ! defined EXIT_SUCCESS
471 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
476 # if ! defined free && ! defined EXIT_SUCCESS
477 void free (void *); /* INFRINGES ON USER NAME SPACE */
481 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
484 #if (! defined yyoverflow \
485 && (! defined __cplusplus \
486 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
488 /* A type that is properly aligned for any stack member. */
491 yytype_int16 yyss_alloc
;
495 /* The size of the maximum gap between one aligned stack and the next. */
496 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
498 /* The size of an array large to enough to hold all stacks, each with
500 # define YYSTACK_BYTES(N) \
501 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
502 + YYSTACK_GAP_MAXIMUM)
504 # define YYCOPY_NEEDED 1
506 /* Relocate STACK from its old location to the new one. The
507 local variables YYSIZE and YYSTACKSIZE give the old and new number of
508 elements in the stack, and YYPTR gives the new location of the
509 stack. Advance YYPTR to a properly aligned location for the next
511 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
514 YYSIZE_T yynewbytes; \
515 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
516 Stack = &yyptr->Stack_alloc; \
517 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
518 yyptr += yynewbytes / sizeof (*yyptr); \
524 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
525 /* Copy COUNT objects from SRC to DST. The source and destination do
528 # if defined __GNUC__ && 1 < __GNUC__
529 # define YYCOPY(Dst, Src, Count) \
530 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
532 # define YYCOPY(Dst, Src, Count) \
536 for (yyi = 0; yyi < (Count); yyi++) \
537 (Dst)[yyi] = (Src)[yyi]; \
542 #endif /* !YYCOPY_NEEDED */
544 /* YYFINAL -- State number of the termination state. */
546 /* YYLAST -- Last index in YYTABLE. */
549 /* YYNTOKENS -- Number of terminals. */
551 /* YYNNTS -- Number of nonterminals. */
553 /* YYNRULES -- Number of rules. */
555 /* YYNSTATES -- Number of states. */
558 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
559 by yylex, with out-of-bounds checking. */
561 #define YYMAXUTOK 273
563 #define YYTRANSLATE(YYX) \
564 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
566 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
567 as returned by yylex, without out-of-bounds checking. */
568 static const yytype_uint8 yytranslate
[] =
570 0, 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, 20, 2, 2, 21, 2, 2,
575 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
596 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
601 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
602 static const yytype_uint16 yyrline
[] =
604 0, 191, 191, 193, 197, 199, 201, 203, 205, 207,
605 209, 213, 220, 227, 235, 242, 254, 256, 261, 263,
606 265, 270, 275, 280, 288, 293, 313, 320, 328, 333,
607 339, 344, 353, 362, 366, 368, 370, 372, 374, 376,
608 378, 380, 382, 384, 386, 388, 390, 392, 394, 396,
609 398, 400, 405, 442, 443
613 #if YYDEBUG || YYERROR_VERBOSE || 0
614 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
615 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
616 static const char *const yytname
[] =
618 "$end", "error", "$undefined", "tAGO", "tDST", "tDAY", "tDAY_UNIT",
619 "tDAYZONE", "tHOUR_UNIT", "tLOCAL_ZONE", "tMERIDIAN", "tMINUTE_UNIT",
620 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tYEAR_UNIT", "tZONE", "tSNUMBER",
621 "tUNUMBER", "':'", "','", "'/'", "$accept", "spec", "item", "time",
622 "local_zone", "zone", "day", "date", "rel", "relunit", "number",
623 "o_merid", YY_NULLPTR
628 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
629 (internal) symbol number NUM (which must be that of a token). */
630 static const yytype_uint16 yytoknum
[] =
632 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
633 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
638 #define YYPACT_NINF -17
640 #define yypact_value_is_default(Yystate) \
641 (!!((Yystate) == (-17)))
643 #define YYTABLE_NINF -1
645 #define yytable_value_is_error(Yytable_value) \
648 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
650 static const yytype_int8 yypact
[] =
652 -17, 0, -17, 1, -17, -17, -17, 19, -17, -14,
653 -17, -17, -17, 32, 26, 14, -17, -17, -17, -17,
654 -17, -17, -17, 27, -17, -17, -17, 22, -17, -17,
655 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
656 -16, -17, -17, -17, 29, 25, 30, -17, 31, -17,
657 -17, -17, 28, 23, -17, -17, -17, 33, -17, 34,
661 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
662 Performed when YYTABLE does not specify something else to do. Zero
663 means the default is an error. */
664 static const yytype_uint8 yydefact
[] =
666 2, 0, 1, 21, 42, 19, 45, 16, 48, 0,
667 39, 51, 36, 18, 0, 52, 3, 4, 5, 6,
668 8, 7, 9, 33, 10, 22, 17, 28, 20, 41,
669 44, 47, 38, 50, 35, 23, 40, 43, 11, 46,
670 30, 37, 49, 34, 0, 0, 0, 32, 0, 27,
671 31, 26, 53, 24, 29, 54, 13, 0, 12, 0,
675 /* YYPGOTO[NTERM-NUM]. */
676 static const yytype_int8 yypgoto
[] =
678 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
682 /* YYDEFGOTO[NTERM-NUM]. */
683 static const yytype_int8 yydefgoto
[] =
685 -1, 1, 16, 17, 18, 19, 20, 21, 22, 23,
689 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
690 positive, shift that token. If negative, reduce the rule whose
691 number is the opposite. If YYTABLE_NINF, syntax error. */
692 static const yytype_uint8 yytable
[] =
694 2, 49, 50, 55, 27, 3, 4, 5, 6, 7,
695 62, 8, 9, 10, 11, 12, 13, 14, 15, 35,
696 36, 25, 37, 26, 38, 39, 40, 41, 42, 43,
697 47, 44, 29, 45, 30, 46, 28, 31, 55, 32,
698 33, 34, 48, 52, 59, 56, 51, 57, 53, 54,
702 static const yytype_uint8 yycheck
[] =
704 0, 17, 18, 10, 18, 5, 6, 7, 8, 9,
705 17, 11, 12, 13, 14, 15, 16, 17, 18, 5,
706 6, 20, 8, 4, 10, 11, 12, 13, 14, 15,
707 3, 17, 6, 19, 8, 21, 4, 11, 10, 13,
708 14, 15, 20, 18, 21, 17, 17, 19, 18, 18,
712 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
713 symbol of state STATE-NUM. */
714 static const yytype_uint8 yystos
[] =
716 0, 23, 0, 5, 6, 7, 8, 9, 11, 12,
717 13, 14, 15, 16, 17, 18, 24, 25, 26, 27,
718 28, 29, 30, 31, 32, 20, 4, 18, 4, 6,
719 8, 11, 13, 14, 15, 5, 6, 8, 10, 11,
720 12, 13, 14, 15, 17, 19, 21, 3, 20, 17,
721 18, 17, 18, 18, 18, 10, 17, 19, 33, 21,
725 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
726 static const yytype_uint8 yyr1
[] =
728 0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
729 24, 25, 25, 25, 25, 25, 26, 26, 27, 27,
730 27, 28, 28, 28, 29, 29, 29, 29, 29, 29,
731 29, 29, 30, 30, 31, 31, 31, 31, 31, 31,
732 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
736 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
737 static const yytype_uint8 yyr2
[] =
739 0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
740 1, 2, 4, 4, 6, 6, 1, 2, 1, 1,
741 2, 1, 2, 2, 3, 5, 3, 3, 2, 4,
742 2, 3, 2, 1, 2, 2, 1, 2, 2, 1,
743 2, 2, 1, 2, 2, 1, 2, 2, 1, 2,
748 #define yyerrok (yyerrstatus = 0)
749 #define yyclearin (yychar = YYEMPTY)
753 #define YYACCEPT goto yyacceptlab
754 #define YYABORT goto yyabortlab
755 #define YYERROR goto yyerrorlab
758 #define YYRECOVERING() (!!yyerrstatus)
760 #define YYBACKUP(Token, Value) \
762 if (yychar == YYEMPTY) \
766 YYPOPSTACK (yylen); \
772 yyerror (pc, YY_("syntax error: cannot back up")); \
777 /* Error token number */
779 #define YYERRCODE 256
783 /* Enable debugging if requested. */
787 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
788 # define YYFPRINTF fprintf
791 # define YYDPRINTF(Args) \
797 /* This macro is provided for backward compatibility. */
798 #ifndef YY_LOCATION_PRINT
799 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
803 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
807 YYFPRINTF (stderr, "%s ", Title); \
808 yy_symbol_print (stderr, \
810 YYFPRINTF (stderr, "\n"); \
815 /*----------------------------------------.
816 | Print this symbol's value on YYOUTPUT. |
817 `----------------------------------------*/
820 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct parser_control
*pc
)
822 FILE *yyo
= yyoutput
;
828 if (yytype
< YYNTOKENS
)
829 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
835 /*--------------------------------.
836 | Print this symbol on YYOUTPUT. |
837 `--------------------------------*/
840 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct parser_control
*pc
)
842 YYFPRINTF (yyoutput
, "%s %s (",
843 yytype
< YYNTOKENS
? "token" : "nterm", yytname
[yytype
]);
845 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, pc
);
846 YYFPRINTF (yyoutput
, ")");
849 /*------------------------------------------------------------------.
850 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
852 `------------------------------------------------------------------*/
855 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
857 YYFPRINTF (stderr
, "Stack now");
858 for (; yybottom
<= yytop
; yybottom
++)
860 int yybot
= *yybottom
;
861 YYFPRINTF (stderr
, " %d", yybot
);
863 YYFPRINTF (stderr
, "\n");
866 # define YY_STACK_PRINT(Bottom, Top) \
869 yy_stack_print ((Bottom), (Top)); \
873 /*------------------------------------------------.
874 | Report that the YYRULE is going to be reduced. |
875 `------------------------------------------------*/
878 yy_reduce_print (yytype_int16
*yyssp
, YYSTYPE
*yyvsp
, int yyrule
, struct parser_control
*pc
)
880 unsigned long int yylno
= yyrline
[yyrule
];
881 int yynrhs
= yyr2
[yyrule
];
883 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
885 /* The symbols being reduced. */
886 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
888 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
889 yy_symbol_print (stderr
,
890 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
891 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
893 YYFPRINTF (stderr
, "\n");
897 # define YY_REDUCE_PRINT(Rule) \
900 yy_reduce_print (yyssp, yyvsp, Rule, pc); \
903 /* Nonzero means print parse trace. It is left uninitialized so that
904 multiple parsers can coexist. */
907 # define YYDPRINTF(Args)
908 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
909 # define YY_STACK_PRINT(Bottom, Top)
910 # define YY_REDUCE_PRINT(Rule)
911 #endif /* !YYDEBUG */
914 /* YYINITDEPTH -- initial size of the parser's stacks. */
916 # define YYINITDEPTH 200
919 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
920 if the built-in stack extension method is used).
922 Do not make this value too large; the results are undefined if
923 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
924 evaluated with infinite-precision integer arithmetic. */
927 # define YYMAXDEPTH 10000
934 # if defined __GLIBC__ && defined _STRING_H
935 # define yystrlen strlen
937 /* Return the length of YYSTR. */
939 yystrlen (const char *yystr
)
942 for (yylen
= 0; yystr
[yylen
]; yylen
++)
950 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
951 # define yystpcpy stpcpy
953 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
956 yystpcpy (char *yydest
, const char *yysrc
)
959 const char *yys
= yysrc
;
961 while ((*yyd
++ = *yys
++) != '\0')
970 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
971 quotes and backslashes, so that it's suitable for yyerror. The
972 heuristic is that double-quoting is unnecessary unless the string
973 contains an apostrophe, a comma, or backslash (other than
974 backslash-backslash). YYSTR is taken from yytname. If YYRES is
975 null, do not copy; instead, return the length of what the result
978 yytnamerr (char *yyres
, const char *yystr
)
983 char const *yyp
= yystr
;
990 goto do_not_strip_quotes
;
994 goto do_not_strip_quotes
;
1007 do_not_strip_quotes
: ;
1011 return yystrlen (yystr
);
1013 return yystpcpy (yyres
, yystr
) - yyres
;
1017 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1018 about the unexpected token YYTOKEN for the state stack whose top is
1021 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1022 not large enough to hold the message. In that case, also set
1023 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1024 required number of bytes is too large to store. */
1026 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1027 yytype_int16
*yyssp
, int yytoken
)
1029 YYSIZE_T yysize0
= yytnamerr (YY_NULLPTR
, yytname
[yytoken
]);
1030 YYSIZE_T yysize
= yysize0
;
1031 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1032 /* Internationalized format string. */
1033 const char *yyformat
= YY_NULLPTR
;
1034 /* Arguments of yyformat. */
1035 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1036 /* Number of reported tokens (one for the "unexpected", one per
1040 /* There are many possibilities here to consider:
1041 - If this state is a consistent state with a default action, then
1042 the only way this function was invoked is if the default action
1043 is an error action. In that case, don't check for expected
1044 tokens because there are none.
1045 - The only way there can be no lookahead present (in yychar) is if
1046 this state is a consistent state with a default action. Thus,
1047 detecting the absence of a lookahead is sufficient to determine
1048 that there is no unexpected or expected token to report. In that
1049 case, just report a simple "syntax error".
1050 - Don't assume there isn't a lookahead just because this state is a
1051 consistent state with a default action. There might have been a
1052 previous inconsistent state, consistent state with a non-default
1053 action, or user semantic action that manipulated yychar.
1054 - Of course, the expected token list depends on states to have
1055 correct lookahead information, and it depends on the parser not
1056 to perform extra reductions after fetching a lookahead from the
1057 scanner and before detecting a syntax error. Thus, state merging
1058 (from LALR or IELR) and default reductions corrupt the expected
1059 token list. However, the list is correct for canonical LR with
1060 one exception: it will still contain any token that will not be
1061 accepted due to an error action in a later state.
1063 if (yytoken
!= YYEMPTY
)
1065 int yyn
= yypact
[*yyssp
];
1066 yyarg
[yycount
++] = yytname
[yytoken
];
1067 if (!yypact_value_is_default (yyn
))
1069 /* Start YYX at -YYN if negative to avoid negative indexes in
1070 YYCHECK. In other words, skip the first -YYN actions for
1071 this state because they are default actions. */
1072 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1073 /* Stay within bounds of both yycheck and yytname. */
1074 int yychecklim
= YYLAST
- yyn
+ 1;
1075 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1078 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1079 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1080 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1082 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1088 yyarg
[yycount
++] = yytname
[yyx
];
1090 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULLPTR
, yytname
[yyx
]);
1091 if (! (yysize
<= yysize1
1092 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1102 # define YYCASE_(N, S) \
1106 YYCASE_(0, YY_("syntax error"));
1107 YYCASE_(1, YY_("syntax error, unexpected %s"));
1108 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1109 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1110 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1111 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1116 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
1117 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1122 if (*yymsg_alloc
< yysize
)
1124 *yymsg_alloc
= 2 * yysize
;
1125 if (! (yysize
<= *yymsg_alloc
1126 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1127 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1131 /* Avoid sprintf, as that infringes on the user's name space.
1132 Don't have undefined behavior even if the translation
1133 produced a string with the wrong number of "%s"s. */
1137 while ((*yyp
= *yyformat
) != '\0')
1138 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1140 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1151 #endif /* YYERROR_VERBOSE */
1153 /*-----------------------------------------------.
1154 | Release the memory associated to this symbol. |
1155 `-----------------------------------------------*/
1158 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, struct parser_control
*pc
)
1164 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1166 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1168 YY_IGNORE_MAYBE_UNINITIALIZED_END
1179 yyparse (struct parser_control
*pc
)
1181 /* The lookahead symbol. */
1185 /* The semantic value of the lookahead symbol. */
1186 /* Default value used for initialization, for pacifying older GCCs
1187 or non-GCC compilers. */
1188 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
1189 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);
1191 /* Number of syntax errors so far. */
1195 /* Number of tokens to shift before error messages enabled. */
1198 /* The stacks and their tools:
1199 'yyss': related to states.
1200 'yyvs': related to semantic values.
1202 Refer to the stacks through separate pointers, to allow yyoverflow
1203 to reallocate them elsewhere. */
1205 /* The state stack. */
1206 yytype_int16 yyssa
[YYINITDEPTH
];
1208 yytype_int16
*yyssp
;
1210 /* The semantic value stack. */
1211 YYSTYPE yyvsa
[YYINITDEPTH
];
1215 YYSIZE_T yystacksize
;
1219 /* Lookahead token as an internal (translated) token number. */
1221 /* The variables used to return semantic value and location from the
1226 /* Buffer for error messages, and its allocated size. */
1228 char *yymsg
= yymsgbuf
;
1229 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1232 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1234 /* The number of symbols on the RHS of the reduced rule.
1235 Keep to zero when no symbol should be popped. */
1238 yyssp
= yyss
= yyssa
;
1239 yyvsp
= yyvs
= yyvsa
;
1240 yystacksize
= YYINITDEPTH
;
1242 YYDPRINTF ((stderr
, "Starting parse\n"));
1247 yychar
= YYEMPTY
; /* Cause a token to be read. */
1250 /*------------------------------------------------------------.
1251 | yynewstate -- Push a new state, which is found in yystate. |
1252 `------------------------------------------------------------*/
1254 /* In all cases, when you get here, the value and location stacks
1255 have just been pushed. So pushing a state here evens the stacks. */
1261 if (yyss
+ yystacksize
- 1 <= yyssp
)
1263 /* Get the current used size of the three stacks, in elements. */
1264 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1268 /* Give user a chance to reallocate the stack. Use copies of
1269 these so that the &'s don't force the real ones into
1271 YYSTYPE
*yyvs1
= yyvs
;
1272 yytype_int16
*yyss1
= yyss
;
1274 /* Each stack pointer address is followed by the size of the
1275 data in use in that stack, in bytes. This used to be a
1276 conditional around just the two extra args, but that might
1277 be undefined if yyoverflow is a macro. */
1278 yyoverflow (YY_("memory exhausted"),
1279 &yyss1
, yysize
* sizeof (*yyssp
),
1280 &yyvs1
, yysize
* sizeof (*yyvsp
),
1286 #else /* no yyoverflow */
1287 # ifndef YYSTACK_RELOCATE
1288 goto yyexhaustedlab
;
1290 /* Extend the stack our own way. */
1291 if (YYMAXDEPTH
<= yystacksize
)
1292 goto yyexhaustedlab
;
1294 if (YYMAXDEPTH
< yystacksize
)
1295 yystacksize
= YYMAXDEPTH
;
1298 yytype_int16
*yyss1
= yyss
;
1299 union yyalloc
*yyptr
=
1300 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1302 goto yyexhaustedlab
;
1303 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1304 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1305 # undef YYSTACK_RELOCATE
1307 YYSTACK_FREE (yyss1
);
1310 #endif /* no yyoverflow */
1312 yyssp
= yyss
+ yysize
- 1;
1313 yyvsp
= yyvs
+ yysize
- 1;
1315 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1316 (unsigned long int) yystacksize
));
1318 if (yyss
+ yystacksize
- 1 <= yyssp
)
1322 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1324 if (yystate
== YYFINAL
)
1334 /* Do appropriate processing given the current state. Read a
1335 lookahead token if we need one and don't already have one. */
1337 /* First try to decide what to do without reference to lookahead token. */
1338 yyn
= yypact
[yystate
];
1339 if (yypact_value_is_default (yyn
))
1342 /* Not known => get a lookahead token if don't already have one. */
1344 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1345 if (yychar
== YYEMPTY
)
1347 YYDPRINTF ((stderr
, "Reading a token: "));
1348 yychar
= yylex (&yylval
, pc
);
1351 if (yychar
<= YYEOF
)
1353 yychar
= yytoken
= YYEOF
;
1354 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1358 yytoken
= YYTRANSLATE (yychar
);
1359 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1362 /* If the proper action on seeing token YYTOKEN is to reduce or to
1363 detect an error, take that action. */
1365 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1370 if (yytable_value_is_error (yyn
))
1376 /* Count tokens shifted since error; after three, turn off error
1381 /* Shift the lookahead token. */
1382 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1384 /* Discard the shifted token. */
1388 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1390 YY_IGNORE_MAYBE_UNINITIALIZED_END
1395 /*-----------------------------------------------------------.
1396 | yydefault -- do the default action for the current state. |
1397 `-----------------------------------------------------------*/
1399 yyn
= yydefact
[yystate
];
1405 /*-----------------------------.
1406 | yyreduce -- Do a reduction. |
1407 `-----------------------------*/
1409 /* yyn is the number of a rule to reduce with. */
1412 /* If YYLEN is nonzero, implement the default value of the action:
1415 Otherwise, the following line sets YYVAL to garbage.
1416 This behavior is undocumented and Bison
1417 users should not rely upon it. Assigning to YYVAL
1418 unconditionally makes the parser a bit smaller, and it avoids a
1419 GCC warning that YYVAL may be used uninitialized. */
1420 yyval
= yyvsp
[1-yylen
];
1423 YY_REDUCE_PRINT (yyn
);
1427 #line 198 "source3/modules/getdate.y" /* yacc.c:1646 */
1428 { pc
->times_seen
++; }
1429 #line 1430 "source3/modules/getdate.c" /* yacc.c:1646 */
1433 #line 200 "source3/modules/getdate.y" /* yacc.c:1646 */
1434 { pc
->local_zones_seen
++; }
1435 #line 1436 "source3/modules/getdate.c" /* yacc.c:1646 */
1439 #line 202 "source3/modules/getdate.y" /* yacc.c:1646 */
1440 { pc
->zones_seen
++; }
1441 #line 1442 "source3/modules/getdate.c" /* yacc.c:1646 */
1445 #line 204 "source3/modules/getdate.y" /* yacc.c:1646 */
1446 { pc
->dates_seen
++; }
1447 #line 1448 "source3/modules/getdate.c" /* yacc.c:1646 */
1451 #line 206 "source3/modules/getdate.y" /* yacc.c:1646 */
1452 { pc
->days_seen
++; }
1453 #line 1454 "source3/modules/getdate.c" /* yacc.c:1646 */
1457 #line 208 "source3/modules/getdate.y" /* yacc.c:1646 */
1458 { pc
->rels_seen
++; }
1459 #line 1460 "source3/modules/getdate.c" /* yacc.c:1646 */
1463 #line 214 "source3/modules/getdate.y" /* yacc.c:1646 */
1465 pc
->hour
= (yyvsp
[-1].textintval
).value
;
1468 pc
->meridian
= (yyvsp
[0].intval
);
1470 #line 1471 "source3/modules/getdate.c" /* yacc.c:1646 */
1474 #line 221 "source3/modules/getdate.y" /* yacc.c:1646 */
1476 pc
->hour
= (yyvsp
[-3].textintval
).value
;
1477 pc
->minutes
= (yyvsp
[-1].textintval
).value
;
1479 pc
->meridian
= (yyvsp
[0].intval
);
1481 #line 1482 "source3/modules/getdate.c" /* yacc.c:1646 */
1485 #line 228 "source3/modules/getdate.y" /* yacc.c:1646 */
1487 pc
->hour
= (yyvsp
[-3].textintval
).value
;
1488 pc
->minutes
= (yyvsp
[-1].textintval
).value
;
1489 pc
->meridian
= MER24
;
1491 pc
->time_zone
= (yyvsp
[0].textintval
).value
% 100 + ((yyvsp
[0].textintval
).value
/ 100) * 60;
1493 #line 1494 "source3/modules/getdate.c" /* yacc.c:1646 */
1497 #line 236 "source3/modules/getdate.y" /* yacc.c:1646 */
1499 pc
->hour
= (yyvsp
[-5].textintval
).value
;
1500 pc
->minutes
= (yyvsp
[-3].textintval
).value
;
1501 pc
->seconds
= (yyvsp
[-1].textintval
).value
;
1502 pc
->meridian
= (yyvsp
[0].intval
);
1504 #line 1505 "source3/modules/getdate.c" /* yacc.c:1646 */
1508 #line 243 "source3/modules/getdate.y" /* yacc.c:1646 */
1510 pc
->hour
= (yyvsp
[-5].textintval
).value
;
1511 pc
->minutes
= (yyvsp
[-3].textintval
).value
;
1512 pc
->seconds
= (yyvsp
[-1].textintval
).value
;
1513 pc
->meridian
= MER24
;
1515 pc
->time_zone
= (yyvsp
[0].textintval
).value
% 100 + ((yyvsp
[0].textintval
).value
/ 100) * 60;
1517 #line 1518 "source3/modules/getdate.c" /* yacc.c:1646 */
1521 #line 255 "source3/modules/getdate.y" /* yacc.c:1646 */
1522 { pc
->local_isdst
= (yyvsp
[0].intval
); }
1523 #line 1524 "source3/modules/getdate.c" /* yacc.c:1646 */
1527 #line 257 "source3/modules/getdate.y" /* yacc.c:1646 */
1528 { pc
->local_isdst
= (yyvsp
[-1].intval
) < 0 ? 1 : (yyvsp
[-1].intval
) + 1; }
1529 #line 1530 "source3/modules/getdate.c" /* yacc.c:1646 */
1533 #line 262 "source3/modules/getdate.y" /* yacc.c:1646 */
1534 { pc
->time_zone
= (yyvsp
[0].intval
); }
1535 #line 1536 "source3/modules/getdate.c" /* yacc.c:1646 */
1539 #line 264 "source3/modules/getdate.y" /* yacc.c:1646 */
1540 { pc
->time_zone
= (yyvsp
[0].intval
) + 60; }
1541 #line 1542 "source3/modules/getdate.c" /* yacc.c:1646 */
1545 #line 266 "source3/modules/getdate.y" /* yacc.c:1646 */
1546 { pc
->time_zone
= (yyvsp
[-1].intval
) + 60; }
1547 #line 1548 "source3/modules/getdate.c" /* yacc.c:1646 */
1551 #line 271 "source3/modules/getdate.y" /* yacc.c:1646 */
1553 pc
->day_ordinal
= 1;
1554 pc
->day_number
= (yyvsp
[0].intval
);
1556 #line 1557 "source3/modules/getdate.c" /* yacc.c:1646 */
1560 #line 276 "source3/modules/getdate.y" /* yacc.c:1646 */
1562 pc
->day_ordinal
= 1;
1563 pc
->day_number
= (yyvsp
[-1].intval
);
1565 #line 1566 "source3/modules/getdate.c" /* yacc.c:1646 */
1569 #line 281 "source3/modules/getdate.y" /* yacc.c:1646 */
1571 pc
->day_ordinal
= (yyvsp
[-1].textintval
).value
;
1572 pc
->day_number
= (yyvsp
[0].intval
);
1574 #line 1575 "source3/modules/getdate.c" /* yacc.c:1646 */
1578 #line 289 "source3/modules/getdate.y" /* yacc.c:1646 */
1580 pc
->month
= (yyvsp
[-2].textintval
).value
;
1581 pc
->day
= (yyvsp
[0].textintval
).value
;
1583 #line 1584 "source3/modules/getdate.c" /* yacc.c:1646 */
1587 #line 294 "source3/modules/getdate.y" /* yacc.c:1646 */
1589 /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
1590 otherwise as MM/DD/YY.
1591 The goal in recognizing YYYY/MM/DD is solely to support legacy
1592 machine-generated dates like those in an RCS log listing. If
1593 you want portability, use the ISO 8601 format. */
1594 if (4 <= (yyvsp
[-4].textintval
).digits
)
1596 pc
->year
= (yyvsp
[-4].textintval
);
1597 pc
->month
= (yyvsp
[-2].textintval
).value
;
1598 pc
->day
= (yyvsp
[0].textintval
).value
;
1602 pc
->month
= (yyvsp
[-4].textintval
).value
;
1603 pc
->day
= (yyvsp
[-2].textintval
).value
;
1604 pc
->year
= (yyvsp
[0].textintval
);
1607 #line 1608 "source3/modules/getdate.c" /* yacc.c:1646 */
1611 #line 314 "source3/modules/getdate.y" /* yacc.c:1646 */
1613 /* ISO 8601 format. YYYY-MM-DD. */
1614 pc
->year
= (yyvsp
[-2].textintval
);
1615 pc
->month
= -(yyvsp
[-1].textintval
).value
;
1616 pc
->day
= -(yyvsp
[0].textintval
).value
;
1618 #line 1619 "source3/modules/getdate.c" /* yacc.c:1646 */
1622 #line 321 "source3/modules/getdate.y" /* yacc.c:1646 */
1624 /* e.g. 17-JUN-1992. */
1625 pc
->day
= (yyvsp
[-2].textintval
).value
;
1626 pc
->month
= (yyvsp
[-1].intval
);
1627 pc
->year
.value
= -(yyvsp
[0].textintval
).value
;
1628 pc
->year
.digits
= (yyvsp
[0].textintval
).digits
;
1630 #line 1631 "source3/modules/getdate.c" /* yacc.c:1646 */
1634 #line 329 "source3/modules/getdate.y" /* yacc.c:1646 */
1636 pc
->month
= (yyvsp
[-1].intval
);
1637 pc
->day
= (yyvsp
[0].textintval
).value
;
1639 #line 1640 "source3/modules/getdate.c" /* yacc.c:1646 */
1643 #line 334 "source3/modules/getdate.y" /* yacc.c:1646 */
1645 pc
->month
= (yyvsp
[-3].intval
);
1646 pc
->day
= (yyvsp
[-2].textintval
).value
;
1647 pc
->year
= (yyvsp
[0].textintval
);
1649 #line 1650 "source3/modules/getdate.c" /* yacc.c:1646 */
1653 #line 340 "source3/modules/getdate.y" /* yacc.c:1646 */
1655 pc
->day
= (yyvsp
[-1].textintval
).value
;
1656 pc
->month
= (yyvsp
[0].intval
);
1658 #line 1659 "source3/modules/getdate.c" /* yacc.c:1646 */
1662 #line 345 "source3/modules/getdate.y" /* yacc.c:1646 */
1664 pc
->day
= (yyvsp
[-2].textintval
).value
;
1665 pc
->month
= (yyvsp
[-1].intval
);
1666 pc
->year
= (yyvsp
[0].textintval
);
1668 #line 1669 "source3/modules/getdate.c" /* yacc.c:1646 */
1672 #line 354 "source3/modules/getdate.y" /* yacc.c:1646 */
1674 pc
->rel_seconds
= -pc
->rel_seconds
;
1675 pc
->rel_minutes
= -pc
->rel_minutes
;
1676 pc
->rel_hour
= -pc
->rel_hour
;
1677 pc
->rel_day
= -pc
->rel_day
;
1678 pc
->rel_month
= -pc
->rel_month
;
1679 pc
->rel_year
= -pc
->rel_year
;
1681 #line 1682 "source3/modules/getdate.c" /* yacc.c:1646 */
1685 #line 367 "source3/modules/getdate.y" /* yacc.c:1646 */
1686 { pc
->rel_year
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1687 #line 1688 "source3/modules/getdate.c" /* yacc.c:1646 */
1691 #line 369 "source3/modules/getdate.y" /* yacc.c:1646 */
1692 { pc
->rel_year
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1693 #line 1694 "source3/modules/getdate.c" /* yacc.c:1646 */
1697 #line 371 "source3/modules/getdate.y" /* yacc.c:1646 */
1698 { pc
->rel_year
+= (yyvsp
[0].intval
); }
1699 #line 1700 "source3/modules/getdate.c" /* yacc.c:1646 */
1703 #line 373 "source3/modules/getdate.y" /* yacc.c:1646 */
1704 { pc
->rel_month
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1705 #line 1706 "source3/modules/getdate.c" /* yacc.c:1646 */
1709 #line 375 "source3/modules/getdate.y" /* yacc.c:1646 */
1710 { pc
->rel_month
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1711 #line 1712 "source3/modules/getdate.c" /* yacc.c:1646 */
1715 #line 377 "source3/modules/getdate.y" /* yacc.c:1646 */
1716 { pc
->rel_month
+= (yyvsp
[0].intval
); }
1717 #line 1718 "source3/modules/getdate.c" /* yacc.c:1646 */
1721 #line 379 "source3/modules/getdate.y" /* yacc.c:1646 */
1722 { pc
->rel_day
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1723 #line 1724 "source3/modules/getdate.c" /* yacc.c:1646 */
1727 #line 381 "source3/modules/getdate.y" /* yacc.c:1646 */
1728 { pc
->rel_day
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1729 #line 1730 "source3/modules/getdate.c" /* yacc.c:1646 */
1733 #line 383 "source3/modules/getdate.y" /* yacc.c:1646 */
1734 { pc
->rel_day
+= (yyvsp
[0].intval
); }
1735 #line 1736 "source3/modules/getdate.c" /* yacc.c:1646 */
1739 #line 385 "source3/modules/getdate.y" /* yacc.c:1646 */
1740 { pc
->rel_hour
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1741 #line 1742 "source3/modules/getdate.c" /* yacc.c:1646 */
1745 #line 387 "source3/modules/getdate.y" /* yacc.c:1646 */
1746 { pc
->rel_hour
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1747 #line 1748 "source3/modules/getdate.c" /* yacc.c:1646 */
1751 #line 389 "source3/modules/getdate.y" /* yacc.c:1646 */
1752 { pc
->rel_hour
+= (yyvsp
[0].intval
); }
1753 #line 1754 "source3/modules/getdate.c" /* yacc.c:1646 */
1757 #line 391 "source3/modules/getdate.y" /* yacc.c:1646 */
1758 { pc
->rel_minutes
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1759 #line 1760 "source3/modules/getdate.c" /* yacc.c:1646 */
1763 #line 393 "source3/modules/getdate.y" /* yacc.c:1646 */
1764 { pc
->rel_minutes
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1765 #line 1766 "source3/modules/getdate.c" /* yacc.c:1646 */
1769 #line 395 "source3/modules/getdate.y" /* yacc.c:1646 */
1770 { pc
->rel_minutes
+= (yyvsp
[0].intval
); }
1771 #line 1772 "source3/modules/getdate.c" /* yacc.c:1646 */
1775 #line 397 "source3/modules/getdate.y" /* yacc.c:1646 */
1776 { pc
->rel_seconds
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1777 #line 1778 "source3/modules/getdate.c" /* yacc.c:1646 */
1781 #line 399 "source3/modules/getdate.y" /* yacc.c:1646 */
1782 { pc
->rel_seconds
+= (yyvsp
[-1].textintval
).value
* (yyvsp
[0].intval
); }
1783 #line 1784 "source3/modules/getdate.c" /* yacc.c:1646 */
1787 #line 401 "source3/modules/getdate.y" /* yacc.c:1646 */
1788 { pc
->rel_seconds
+= (yyvsp
[0].intval
); }
1789 #line 1790 "source3/modules/getdate.c" /* yacc.c:1646 */
1793 #line 406 "source3/modules/getdate.y" /* yacc.c:1646 */
1796 && ! pc
->rels_seen
&& (pc
->times_seen
|| 2 < (yyvsp
[0].textintval
).digits
))
1797 pc
->year
= (yyvsp
[0].textintval
);
1800 if (4 < (yyvsp
[0].textintval
).digits
)
1803 pc
->day
= (yyvsp
[0].textintval
).value
% 100;
1804 pc
->month
= ((yyvsp
[0].textintval
).value
/ 100) % 100;
1805 pc
->year
.value
= (yyvsp
[0].textintval
).value
/ 10000;
1806 pc
->year
.digits
= (yyvsp
[0].textintval
).digits
- 4;
1811 if ((yyvsp
[0].textintval
).digits
<= 2)
1813 pc
->hour
= (yyvsp
[0].textintval
).value
;
1818 pc
->hour
= (yyvsp
[0].textintval
).value
/ 100;
1819 pc
->minutes
= (yyvsp
[0].textintval
).value
% 100;
1822 pc
->meridian
= MER24
;
1826 #line 1827 "source3/modules/getdate.c" /* yacc.c:1646 */
1830 #line 442 "source3/modules/getdate.y" /* yacc.c:1646 */
1831 { (yyval
.intval
) = MER24
; }
1832 #line 1833 "source3/modules/getdate.c" /* yacc.c:1646 */
1836 #line 444 "source3/modules/getdate.y" /* yacc.c:1646 */
1837 { (yyval
.intval
) = (yyvsp
[0].intval
); }
1838 #line 1839 "source3/modules/getdate.c" /* yacc.c:1646 */
1842 #line 1843 "source3/modules/getdate.c" /* yacc.c:1646 */
1845 /* User semantic actions sometimes alter yychar, and that requires
1846 that yytoken be updated with the new translation. We take the
1847 approach of translating immediately before every use of yytoken.
1848 One alternative is translating here after every semantic action,
1849 but that translation would be missed if the semantic action invokes
1850 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1851 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1852 incorrect destructor might then be invoked immediately. In the
1853 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1854 to an incorrect destructor call or verbose syntax error message
1855 before the lookahead is translated. */
1856 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1860 YY_STACK_PRINT (yyss
, yyssp
);
1864 /* Now 'shift' the result of the reduction. Determine what state
1865 that goes to, based on the state we popped back to and the rule
1866 number reduced by. */
1870 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1871 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1872 yystate
= yytable
[yystate
];
1874 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1879 /*--------------------------------------.
1880 | yyerrlab -- here on detecting error. |
1881 `--------------------------------------*/
1883 /* Make sure we have latest lookahead translation. See comments at
1884 user semantic actions for why this is necessary. */
1885 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1887 /* If not already recovering from an error, report this error. */
1891 #if ! YYERROR_VERBOSE
1892 yyerror (pc
, YY_("syntax error"));
1894 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1897 char const *yymsgp
= YY_("syntax error");
1898 int yysyntax_error_status
;
1899 yysyntax_error_status
= YYSYNTAX_ERROR
;
1900 if (yysyntax_error_status
== 0)
1902 else if (yysyntax_error_status
== 1)
1904 if (yymsg
!= yymsgbuf
)
1905 YYSTACK_FREE (yymsg
);
1906 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1910 yymsg_alloc
= sizeof yymsgbuf
;
1911 yysyntax_error_status
= 2;
1915 yysyntax_error_status
= YYSYNTAX_ERROR
;
1919 yyerror (pc
, yymsgp
);
1920 if (yysyntax_error_status
== 2)
1921 goto yyexhaustedlab
;
1923 # undef YYSYNTAX_ERROR
1929 if (yyerrstatus
== 3)
1931 /* If just tried and failed to reuse lookahead token after an
1932 error, discard it. */
1934 if (yychar
<= YYEOF
)
1936 /* Return failure if at end of input. */
1937 if (yychar
== YYEOF
)
1942 yydestruct ("Error: discarding",
1943 yytoken
, &yylval
, pc
);
1948 /* Else will try to reuse lookahead token after shifting the error
1953 /*---------------------------------------------------.
1954 | yyerrorlab -- error raised explicitly by YYERROR. |
1955 `---------------------------------------------------*/
1958 /* Pacify compilers like GCC when the user code never invokes
1959 YYERROR and the label yyerrorlab therefore never appears in user
1961 if (/*CONSTCOND*/ 0)
1964 /* Do not reclaim the symbols of the rule whose action triggered
1968 YY_STACK_PRINT (yyss
, yyssp
);
1973 /*-------------------------------------------------------------.
1974 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1975 `-------------------------------------------------------------*/
1977 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1981 yyn
= yypact
[yystate
];
1982 if (!yypact_value_is_default (yyn
))
1985 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1993 /* Pop the current state because it cannot handle the error token. */
1998 yydestruct ("Error: popping",
1999 yystos
[yystate
], yyvsp
, pc
);
2002 YY_STACK_PRINT (yyss
, yyssp
);
2005 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2007 YY_IGNORE_MAYBE_UNINITIALIZED_END
2010 /* Shift the error token. */
2011 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2017 /*-------------------------------------.
2018 | yyacceptlab -- YYACCEPT comes here. |
2019 `-------------------------------------*/
2024 /*-----------------------------------.
2025 | yyabortlab -- YYABORT comes here. |
2026 `-----------------------------------*/
2031 #if !defined yyoverflow || YYERROR_VERBOSE
2032 /*-------------------------------------------------.
2033 | yyexhaustedlab -- memory exhaustion comes here. |
2034 `-------------------------------------------------*/
2036 yyerror (pc
, YY_("memory exhausted"));
2042 if (yychar
!= YYEMPTY
)
2044 /* Make sure we have latest lookahead translation. See comments at
2045 user semantic actions for why this is necessary. */
2046 yytoken
= YYTRANSLATE (yychar
);
2047 yydestruct ("Cleanup: discarding lookahead",
2048 yytoken
, &yylval
, pc
);
2050 /* Do not reclaim the symbols of the rule whose action triggered
2051 this YYABORT or YYACCEPT. */
2053 YY_STACK_PRINT (yyss
, yyssp
);
2054 while (yyssp
!= yyss
)
2056 yydestruct ("Cleanup: popping",
2057 yystos
[*yyssp
], yyvsp
, pc
);
2062 YYSTACK_FREE (yyss
);
2065 if (yymsg
!= yymsgbuf
)
2066 YYSTACK_FREE (yymsg
);
2070 #line 447 "source3/modules/getdate.y" /* yacc.c:1906 */
2073 /* Include this file down here because bison inserts code above which
2074 may define-away `const'. We want the prototype for get_date to have
2075 the same signature as the function definition. */
2076 #include "modules/getdate.h"
2079 struct tm
*gmtime (const time_t *);
2082 struct tm
*localtime (const time_t *);
2085 time_t mktime (struct tm
*);
2088 static table
const meridian_table
[] =
2090 { "AM", tMERIDIAN
, MERam
},
2091 { "A.M.", tMERIDIAN
, MERam
},
2092 { "PM", tMERIDIAN
, MERpm
},
2093 { "P.M.", tMERIDIAN
, MERpm
},
2097 static table
const dst_table
[] =
2102 static table
const month_and_day_table
[] =
2104 { "JANUARY", tMONTH
, 1 },
2105 { "FEBRUARY", tMONTH
, 2 },
2106 { "MARCH", tMONTH
, 3 },
2107 { "APRIL", tMONTH
, 4 },
2108 { "MAY", tMONTH
, 5 },
2109 { "JUNE", tMONTH
, 6 },
2110 { "JULY", tMONTH
, 7 },
2111 { "AUGUST", tMONTH
, 8 },
2112 { "SEPTEMBER",tMONTH
, 9 },
2113 { "SEPT", tMONTH
, 9 },
2114 { "OCTOBER", tMONTH
, 10 },
2115 { "NOVEMBER", tMONTH
, 11 },
2116 { "DECEMBER", tMONTH
, 12 },
2117 { "SUNDAY", tDAY
, 0 },
2118 { "MONDAY", tDAY
, 1 },
2119 { "TUESDAY", tDAY
, 2 },
2120 { "TUES", tDAY
, 2 },
2121 { "WEDNESDAY",tDAY
, 3 },
2122 { "WEDNES", tDAY
, 3 },
2123 { "THURSDAY", tDAY
, 4 },
2124 { "THUR", tDAY
, 4 },
2125 { "THURS", tDAY
, 4 },
2126 { "FRIDAY", tDAY
, 5 },
2127 { "SATURDAY", tDAY
, 6 },
2131 static table
const time_units_table
[] =
2133 { "YEAR", tYEAR_UNIT
, 1 },
2134 { "MONTH", tMONTH_UNIT
, 1 },
2135 { "FORTNIGHT",tDAY_UNIT
, 14 },
2136 { "WEEK", tDAY_UNIT
, 7 },
2137 { "DAY", tDAY_UNIT
, 1 },
2138 { "HOUR", tHOUR_UNIT
, 1 },
2139 { "MINUTE", tMINUTE_UNIT
, 1 },
2140 { "MIN", tMINUTE_UNIT
, 1 },
2141 { "SECOND", tSEC_UNIT
, 1 },
2142 { "SEC", tSEC_UNIT
, 1 },
2146 /* Assorted relative-time words. */
2147 static table
const relative_time_table
[] =
2149 { "TOMORROW", tMINUTE_UNIT
, 24 * 60 },
2150 { "YESTERDAY",tMINUTE_UNIT
, - (24 * 60) },
2151 { "TODAY", tMINUTE_UNIT
, 0 },
2152 { "NOW", tMINUTE_UNIT
, 0 },
2153 { "LAST", tUNUMBER
, -1 },
2154 { "THIS", tUNUMBER
, 0 },
2155 { "NEXT", tUNUMBER
, 1 },
2156 { "FIRST", tUNUMBER
, 1 },
2157 /*{ "SECOND", tUNUMBER, 2 }, */
2158 { "THIRD", tUNUMBER
, 3 },
2159 { "FOURTH", tUNUMBER
, 4 },
2160 { "FIFTH", tUNUMBER
, 5 },
2161 { "SIXTH", tUNUMBER
, 6 },
2162 { "SEVENTH", tUNUMBER
, 7 },
2163 { "EIGHTH", tUNUMBER
, 8 },
2164 { "NINTH", tUNUMBER
, 9 },
2165 { "TENTH", tUNUMBER
, 10 },
2166 { "ELEVENTH", tUNUMBER
, 11 },
2167 { "TWELFTH", tUNUMBER
, 12 },
2172 /* The time zone table. This table is necessarily incomplete, as time
2173 zone abbreviations are ambiguous; e.g. Australians interpret "EST"
2174 as Eastern time in Australia, not as US Eastern Standard Time.
2175 You cannot rely on getdate to handle arbitrary time zone
2176 abbreviations; use numeric abbreviations like `-0500' instead. */
2177 static table
const time_zone_table
[] =
2179 { "GMT", tZONE
, HOUR ( 0) }, /* Greenwich Mean */
2180 { "UT", tZONE
, HOUR ( 0) }, /* Universal (Coordinated) */
2181 { "UTC", tZONE
, HOUR ( 0) },
2182 { "WET", tZONE
, HOUR ( 0) }, /* Western European */
2183 { "WEST", tDAYZONE
, HOUR ( 0) }, /* Western European Summer */
2184 { "BST", tDAYZONE
, HOUR ( 0) }, /* British Summer */
2185 { "ART", tZONE
, -HOUR ( 3) }, /* Argentina */
2186 { "BRT", tZONE
, -HOUR ( 3) }, /* Brazil */
2187 { "BRST", tDAYZONE
, -HOUR ( 3) }, /* Brazil Summer */
2188 { "NST", tZONE
, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */
2189 { "NDT", tDAYZONE
,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */
2190 { "AST", tZONE
, -HOUR ( 4) }, /* Atlantic Standard */
2191 { "ADT", tDAYZONE
, -HOUR ( 4) }, /* Atlantic Daylight */
2192 { "CLT", tZONE
, -HOUR ( 4) }, /* Chile */
2193 { "CLST", tDAYZONE
, -HOUR ( 4) }, /* Chile Summer */
2194 { "EST", tZONE
, -HOUR ( 5) }, /* Eastern Standard */
2195 { "EDT", tDAYZONE
, -HOUR ( 5) }, /* Eastern Daylight */
2196 { "CST", tZONE
, -HOUR ( 6) }, /* Central Standard */
2197 { "CDT", tDAYZONE
, -HOUR ( 6) }, /* Central Daylight */
2198 { "MST", tZONE
, -HOUR ( 7) }, /* Mountain Standard */
2199 { "MDT", tDAYZONE
, -HOUR ( 7) }, /* Mountain Daylight */
2200 { "PST", tZONE
, -HOUR ( 8) }, /* Pacific Standard */
2201 { "PDT", tDAYZONE
, -HOUR ( 8) }, /* Pacific Daylight */
2202 { "AKST", tZONE
, -HOUR ( 9) }, /* Alaska Standard */
2203 { "AKDT", tDAYZONE
, -HOUR ( 9) }, /* Alaska Daylight */
2204 { "HST", tZONE
, -HOUR (10) }, /* Hawaii Standard */
2205 { "HAST", tZONE
, -HOUR (10) }, /* Hawaii-Aleutian Standard */
2206 { "HADT", tDAYZONE
, -HOUR (10) }, /* Hawaii-Aleutian Daylight */
2207 { "SST", tZONE
, -HOUR (12) }, /* Samoa Standard */
2208 { "WAT", tZONE
, HOUR ( 1) }, /* West Africa */
2209 { "CET", tZONE
, HOUR ( 1) }, /* Central European */
2210 { "CEST", tDAYZONE
, HOUR ( 1) }, /* Central European Summer */
2211 { "MET", tZONE
, HOUR ( 1) }, /* Middle European */
2212 { "MEZ", tZONE
, HOUR ( 1) }, /* Middle European */
2213 { "MEST", tDAYZONE
, HOUR ( 1) }, /* Middle European Summer */
2214 { "MESZ", tDAYZONE
, HOUR ( 1) }, /* Middle European Summer */
2215 { "EET", tZONE
, HOUR ( 2) }, /* Eastern European */
2216 { "EEST", tDAYZONE
, HOUR ( 2) }, /* Eastern European Summer */
2217 { "CAT", tZONE
, HOUR ( 2) }, /* Central Africa */
2218 { "SAST", tZONE
, HOUR ( 2) }, /* South Africa Standard */
2219 { "EAT", tZONE
, HOUR ( 3) }, /* East Africa */
2220 { "MSK", tZONE
, HOUR ( 3) }, /* Moscow */
2221 { "MSD", tDAYZONE
, HOUR ( 3) }, /* Moscow Daylight */
2222 { "IST", tZONE
, (HOUR ( 5) + 30) }, /* India Standard */
2223 { "SGT", tZONE
, HOUR ( 8) }, /* Singapore */
2224 { "KST", tZONE
, HOUR ( 9) }, /* Korea Standard */
2225 { "JST", tZONE
, HOUR ( 9) }, /* Japan Standard */
2226 { "GST", tZONE
, HOUR (10) }, /* Guam Standard */
2227 { "NZST", tZONE
, HOUR (12) }, /* New Zealand Standard */
2228 { "NZDT", tDAYZONE
, HOUR (12) }, /* New Zealand Daylight */
2232 /* Military time zone table. */
2233 static table
const military_table
[] =
2235 { "A", tZONE
, -HOUR ( 1) },
2236 { "B", tZONE
, -HOUR ( 2) },
2237 { "C", tZONE
, -HOUR ( 3) },
2238 { "D", tZONE
, -HOUR ( 4) },
2239 { "E", tZONE
, -HOUR ( 5) },
2240 { "F", tZONE
, -HOUR ( 6) },
2241 { "G", tZONE
, -HOUR ( 7) },
2242 { "H", tZONE
, -HOUR ( 8) },
2243 { "I", tZONE
, -HOUR ( 9) },
2244 { "K", tZONE
, -HOUR (10) },
2245 { "L", tZONE
, -HOUR (11) },
2246 { "M", tZONE
, -HOUR (12) },
2247 { "N", tZONE
, HOUR ( 1) },
2248 { "O", tZONE
, HOUR ( 2) },
2249 { "P", tZONE
, HOUR ( 3) },
2250 { "Q", tZONE
, HOUR ( 4) },
2251 { "R", tZONE
, HOUR ( 5) },
2252 { "S", tZONE
, HOUR ( 6) },
2253 { "T", tZONE
, HOUR ( 7) },
2254 { "U", tZONE
, HOUR ( 8) },
2255 { "V", tZONE
, HOUR ( 9) },
2256 { "W", tZONE
, HOUR (10) },
2257 { "X", tZONE
, HOUR (11) },
2258 { "Y", tZONE
, HOUR (12) },
2259 { "Z", tZONE
, HOUR ( 0) },
2266 to_hour (int hours
, int meridian
)
2271 return 0 <= hours
&& hours
< 24 ? hours
: -1;
2273 return 0 < hours
&& hours
< 12 ? hours
: hours
== 12 ? 0 : -1;
2275 return 0 < hours
&& hours
< 12 ? hours
+ 12 : hours
== 12 ? 12 : -1;
2284 to_year (textint textyear
)
2286 int year
= textyear
.value
;
2291 /* XPG4 suggests that years 00-68 map to 2000-2068, and
2292 years 69-99 map to 1969-1999. */
2293 if (textyear
.digits
== 2)
2294 year
+= year
< 69 ? 2000 : 1900;
2299 static table
const *
2300 lookup_zone (struct parser_control
const *pc
, char const *name
)
2304 /* Try local zone abbreviations first; they're more likely to be right. */
2305 for (tp
= pc
->local_time_zone_table
; tp
->name
; tp
++)
2306 if (strcmp (name
, tp
->name
) == 0)
2309 for (tp
= time_zone_table
; tp
->name
; tp
++)
2310 if (strcmp (name
, tp
->name
) == 0)
2316 #if ! HAVE_TM_GMTOFF
2317 /* Yield the difference between *A and *B,
2318 measured in seconds, ignoring leap seconds.
2319 The body of this function is taken directly from the GNU C Library;
2320 see src/strftime.c. */
2322 tm_diff (struct tm
const *a
, struct tm
const *b
)
2324 /* Compute intervening leap days correctly even if year is negative.
2325 Take care to avoid int overflow in leap day calculations,
2326 but it's OK to assume that A and B are close to each other. */
2327 int a4
= (a
->tm_year
>> 2) + (TM_YEAR_BASE
>> 2) - ! (a
->tm_year
& 3);
2328 int b4
= (b
->tm_year
>> 2) + (TM_YEAR_BASE
>> 2) - ! (b
->tm_year
& 3);
2329 int a100
= a4
/ 25 - (a4
% 25 < 0);
2330 int b100
= b4
/ 25 - (b4
% 25 < 0);
2331 int a400
= a100
>> 2;
2332 int b400
= b100
>> 2;
2333 int intervening_leap_days
= (a4
- b4
) - (a100
- b100
) + (a400
- b400
);
2334 int years
= a
->tm_year
- b
->tm_year
;
2335 int days
= (365 * years
+ intervening_leap_days
2336 + (a
->tm_yday
- b
->tm_yday
));
2337 return (60 * (60 * (24 * days
+ (a
->tm_hour
- b
->tm_hour
))
2338 + (a
->tm_min
- b
->tm_min
))
2339 + (a
->tm_sec
- b
->tm_sec
));
2341 #endif /* ! HAVE_TM_GMTOFF */
2343 static table
const *
2344 lookup_word (struct parser_control
const *pc
, char *word
)
2353 /* Make it uppercase. */
2354 for (p
= word
; *p
; p
++)
2355 if (ISLOWER ((unsigned char) *p
))
2356 *p
= toupper ((unsigned char) *p
);
2358 for (tp
= meridian_table
; tp
->name
; tp
++)
2359 if (strcmp (word
, tp
->name
) == 0)
2362 /* See if we have an abbreviation for a month. */
2363 wordlen
= strlen (word
);
2364 abbrev
= wordlen
== 3 || (wordlen
== 4 && word
[3] == '.');
2366 for (tp
= month_and_day_table
; tp
->name
; tp
++)
2367 if ((abbrev
? strncmp (word
, tp
->name
, 3) : strcmp (word
, tp
->name
)) == 0)
2370 if ((tp
= lookup_zone (pc
, word
)))
2373 if (strcmp (word
, dst_table
[0].name
) == 0)
2376 for (tp
= time_units_table
; tp
->name
; tp
++)
2377 if (strcmp (word
, tp
->name
) == 0)
2380 /* Strip off any plural and try the units table again. */
2381 if (word
[wordlen
- 1] == 'S')
2383 word
[wordlen
- 1] = '\0';
2384 for (tp
= time_units_table
; tp
->name
; tp
++)
2385 if (strcmp (word
, tp
->name
) == 0)
2387 word
[wordlen
- 1] = 'S'; /* For "this" in relative_time_table. */
2390 for (tp
= relative_time_table
; tp
->name
; tp
++)
2391 if (strcmp (word
, tp
->name
) == 0)
2394 /* Military time zones. */
2396 for (tp
= military_table
; tp
->name
; tp
++)
2397 if (word
[0] == tp
->name
[0])
2400 /* Drop out any periods and try the time zone table again. */
2401 for (i
= 0, p
= q
= word
; (*p
= *q
); q
++)
2406 if (i
&& (tp
= lookup_zone (pc
, word
)))
2413 yylex (YYSTYPE
*lvalp
, struct parser_control
*pc
)
2420 while (c
= *pc
->input
, ISSPACE (c
))
2423 if (ISDIGIT (c
) || c
== '-' || c
== '+')
2428 if (c
== '-' || c
== '+')
2430 sign
= c
== '-' ? -1 : 1;
2433 /* skip the '-' sign */
2442 value
= 10 * value
+ c
- '0';
2445 while (ISDIGIT (c
));
2446 lvalp
->textintval
.value
= sign
< 0 ? -value
: value
;
2447 lvalp
->textintval
.digits
= p
- pc
->input
;
2449 return sign
? tSNUMBER
: tUNUMBER
;
2464 while (ISALPHA (c
) || c
== '.');
2467 tp
= lookup_word (pc
, buff
);
2470 lvalp
->intval
= tp
->value
;
2475 return *pc
->input
++;
2491 /* Do nothing if the parser reports an error. */
2493 yyerror (struct parser_control
*pc ATTRIBUTE_UNUSED
, const char *s ATTRIBUTE_UNUSED
)
2498 /* Parse a date/time string P. Return the corresponding time_t value,
2499 or (time_t) -1 if there is an error. P can be an incomplete or
2500 relative time specification; if so, use *NOW as the basis for the
2503 get_date (const char *p
, const time_t *now
)
2505 time_t Start
= now
? *now
: time (0);
2506 struct tm
*tmp
= localtime (&Start
);
2509 struct parser_control pc
;
2515 pc
.year
.value
= tmp
->tm_year
+ TM_YEAR_BASE
;
2517 pc
.month
= tmp
->tm_mon
+ 1;
2518 pc
.day
= tmp
->tm_mday
;
2519 pc
.hour
= tmp
->tm_hour
;
2520 pc
.minutes
= tmp
->tm_min
;
2521 pc
.seconds
= tmp
->tm_sec
;
2522 tm
.tm_isdst
= tmp
->tm_isdst
;
2524 pc
.meridian
= MER24
;
2535 pc
.local_zones_seen
= 0;
2538 #ifdef HAVE_STRUCT_TM_TM_ZONE
2539 pc
.local_time_zone_table
[0].name
= tmp
->tm_zone
;
2540 pc
.local_time_zone_table
[0].type
= tLOCAL_ZONE
;
2541 pc
.local_time_zone_table
[0].value
= tmp
->tm_isdst
;
2542 pc
.local_time_zone_table
[1].name
= 0;
2544 /* Probe the names used in the next three calendar quarters, looking
2545 for a tm_isdst different from the one we already have. */
2548 for (quarter
= 1; quarter
<= 3; quarter
++)
2550 time_t probe
= Start
+ quarter
* (90 * 24 * 60 * 60);
2551 struct tm
*probe_tm
= localtime (&probe
);
2552 if (probe_tm
&& probe_tm
->tm_zone
2553 && probe_tm
->tm_isdst
!= pc
.local_time_zone_table
[0].value
)
2556 pc
.local_time_zone_table
[1].name
= probe_tm
->tm_zone
;
2557 pc
.local_time_zone_table
[1].type
= tLOCAL_ZONE
;
2558 pc
.local_time_zone_table
[1].value
= probe_tm
->tm_isdst
;
2559 pc
.local_time_zone_table
[2].name
= 0;
2569 extern char *tzname
[];
2572 for (i
= 0; i
< 2; i
++)
2574 pc
.local_time_zone_table
[i
].name
= tzname
[i
];
2575 pc
.local_time_zone_table
[i
].type
= tLOCAL_ZONE
;
2576 pc
.local_time_zone_table
[i
].value
= i
;
2578 pc
.local_time_zone_table
[i
].name
= 0;
2581 pc
.local_time_zone_table
[0].name
= 0;
2585 if (pc
.local_time_zone_table
[0].name
&& pc
.local_time_zone_table
[1].name
2586 && ! strcmp (pc
.local_time_zone_table
[0].name
,
2587 pc
.local_time_zone_table
[1].name
))
2589 /* This locale uses the same abbrevation for standard and
2590 daylight times. So if we see that abbreviation, we don't
2591 know whether it's daylight time. */
2592 pc
.local_time_zone_table
[0].value
= -1;
2593 pc
.local_time_zone_table
[1].name
= 0;
2596 if (yyparse (&pc
) != 0
2597 || 1 < pc
.times_seen
|| 1 < pc
.dates_seen
|| 1 < pc
.days_seen
2598 || 1 < (pc
.local_zones_seen
+ pc
.zones_seen
)
2599 || (pc
.local_zones_seen
&& 1 < pc
.local_isdst
))
2602 tm
.tm_year
= to_year (pc
.year
) - TM_YEAR_BASE
+ pc
.rel_year
;
2603 tm
.tm_mon
= pc
.month
- 1 + pc
.rel_month
;
2604 tm
.tm_mday
= pc
.day
+ pc
.rel_day
;
2605 if (pc
.times_seen
|| (pc
.rels_seen
&& ! pc
.dates_seen
&& ! pc
.days_seen
))
2607 tm
.tm_hour
= to_hour (pc
.hour
, pc
.meridian
);
2610 tm
.tm_min
= pc
.minutes
;
2611 tm
.tm_sec
= pc
.seconds
;
2615 tm
.tm_hour
= tm
.tm_min
= tm
.tm_sec
= 0;
2618 /* Let mktime deduce tm_isdst if we have an absolute time stamp,
2619 or if the relative time stamp mentions days, months, or years. */
2620 if (pc
.dates_seen
| pc
.days_seen
| pc
.times_seen
| pc
.rel_day
2621 | pc
.rel_month
| pc
.rel_year
)
2624 /* But if the input explicitly specifies local time with or without
2625 DST, give mktime that information. */
2626 if (pc
.local_zones_seen
)
2627 tm
.tm_isdst
= pc
.local_isdst
;
2631 Start
= mktime (&tm
);
2633 if (Start
== (time_t) -1)
2636 /* Guard against falsely reporting errors near the time_t boundaries
2637 when parsing times in other time zones. For example, if the min
2638 time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
2639 of UTC, then the min localtime value is 1970-01-01 08:00:00; if
2640 we apply mktime to 1970-01-01 00:00:00 we will get an error, so
2641 we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
2642 zone by 24 hours to compensate. This algorithm assumes that
2643 there is no DST transition within a day of the time_t boundaries. */
2647 if (tm
.tm_year
<= EPOCH_YEAR
- TM_YEAR_BASE
)
2650 pc
.time_zone
+= 24 * 60;
2655 pc
.time_zone
-= 24 * 60;
2657 Start
= mktime (&tm
);
2660 if (Start
== (time_t) -1)
2664 if (pc
.days_seen
&& ! pc
.dates_seen
)
2666 tm
.tm_mday
+= ((pc
.day_number
- tm
.tm_wday
+ 7) % 7
2667 + 7 * (pc
.day_ordinal
- (0 < pc
.day_ordinal
)));
2669 Start
= mktime (&tm
);
2670 if (Start
== (time_t) -1)
2676 int delta
= pc
.time_zone
* 60;
2677 #ifdef HAVE_TM_GMTOFF
2678 delta
-= tm
.tm_gmtoff
;
2680 struct tm
*gmt
= gmtime (&Start
);
2683 delta
-= tm_diff (&tm
, gmt
);
2685 if ((Start
< Start
- delta
) != (delta
< 0))
2686 return -1; /* time_t overflow */
2690 /* Add relative hours, minutes, and seconds. Ignore leap seconds;
2691 i.e. "+ 10 minutes" means 600 seconds, even if one of them is a
2692 leap second. Typically this is not what the user wants, but it's
2693 too hard to do it the other way, because the time zone indicator
2694 must be applied before relative times, and if mktime is applied
2695 again the time zone will be lost. */
2698 long d1
= 60 * 60 * (long) pc
.rel_hour
;
2699 time_t t1
= t0
+ d1
;
2700 long d2
= 60 * (long) pc
.rel_minutes
;
2701 time_t t2
= t1
+ d2
;
2702 int d3
= pc
.rel_seconds
;
2703 time_t t3
= t2
+ d3
;
2704 if ((d1
/ (60 * 60) ^ pc
.rel_hour
)
2705 | (d2
/ 60 ^ pc
.rel_minutes
)
2706 | ((t0
+ d1
< t0
) ^ (d1
< 0))
2707 | ((t1
+ d2
< t1
) ^ (d2
< 0))
2708 | ((t2
+ d3
< t2
) ^ (d3
< 0)))
2721 main (int ac
, char **av
)
2726 printf ("Enter date, or blank line to exit.\n\t> ");
2729 buff
[BUFSIZ
- 1] = 0;
2730 while (fgets (buff
, BUFSIZ
- 1, stdin
) && buff
[0])
2732 d
= get_date (buff
, 0);
2733 if (d
== (time_t) -1)
2734 printf ("Bad format - couldn't convert.\n");
2736 printf ("%s", ctime (&d
));
2742 #endif /* defined TEST */