citadel
About: Citadel is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
  Fossies Dox: citadel.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
parsedate.c
Go to the documentation of this file.
1/* A Bison parser, made by GNU Bison 3.7. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6 Inc.
7
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 3 of the License, or
11 (at your option) any later version.
12
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.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
40
41/* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
47
48/* Identify Bison output. */
49#define YYBISON 1
50
51/* Bison version. */
52#define YYBISON_VERSION "3.7"
53
54/* Skeleton name. */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers. */
58#define YYPURE 0
59
60/* Push parsers. */
61#define YYPUSH 0
62
63/* Pull parsers. */
64#define YYPULL 1
65
66
67
68
69/* First part of user prologue. */
70#line 1 "server/parsedate.y"
71
72/* $Revision$
73**
74** Originally written by Steven M. Bellovin <smb@research.att.com> while
75** at the University of North Carolina at Chapel Hill. Later tweaked by
76** a couple of people on Usenet. Completely overhauled by Rich $alz
77** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
78** Further revised (removed obsolete constructs and cleaned up timezone
79** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
80** helped in September, 1992. Art Cancro <ajc@citadel.org> cleaned
81** it up for ANSI C in December, 1999.
82**
83** This grammar has six shift/reduce conflicts.
84**
85** This code is in the public domain and has no copyright.
86*/
87/* SUPPRESS 530 *//* Empty body for statement */
88/* SUPPRESS 593 on yyerrlab *//* Label was not used */
89/* SUPPRESS 593 on yynewstate *//* Label was not used */
90/* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
91
92#include "sysdep.h"
93
94#include <stdio.h>
95#include <stdlib.h>
96#include <sys/types.h>
97#include <ctype.h>
98#include <time.h>
99#if HAVE_STRING_H
100# if !STDC_HEADERS && HAVE_MEMORY_H
101# include <memory.h>
102# endif
103# include <string.h>
104#endif
105#if HAVE_STRINGS_H
106# include <strings.h>
107#endif
108
109#include "parsedate.h"
110
111int date_lex(void);
112
113#define yyparse date_parse
114#define yylex date_lex
115#define yyerror date_error
116
117
118 /* See the LeapYears table in Convert. */
119#define EPOCH 1970
120#define END_OF_TIME 2038
121 /* Constants for general time calculations. */
122#define DST_OFFSET 1
123#define SECSPERDAY (24L * 60L * 60L)
124 /* Readability for TABLE stuff. */
125#define HOUR(x) (x * 60)
126
127#define LPAREN '('
128#define RPAREN ')'
129#define IS7BIT(x) ((unsigned int)(x) < 0200)
130
131#define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
132#define ENDOF(array) (&array[SIZEOF(array)])
133
134
135/*
136** An entry in the lexical lookup table.
137*/
138typedef struct _TABLE {
139 char *name;
140 int type;
141 time_t value;
143
144/*
145** Daylight-savings mode: on, off, or not yet known.
146*/
147typedef enum _DSTMODE {
150
151/*
152** Meridian: am, pm, or 24-hour style.
153*/
154typedef enum _MERIDIAN {
157
158
159/*
160** Global variables. We could get rid of most of them by using a yacc
161** union, but this is more efficient. (This routine predates the
162** yacc %union construct.)
163*/
164static const char *yyInput;
166static int yyHaveDate;
167static int yyHaveRel;
168static int yyHaveTime;
169static time_t yyTimezone;
170static time_t yyDay;
171static time_t yyHour;
172static time_t yyMinutes;
173static time_t yyMonth;
174static time_t yySeconds;
175static time_t yyYear;
177static time_t yyRelMonth;
178static time_t yyRelSeconds;
179
180
181static void date_error(char *);
182
183#line 184 "y.tab.c"
184
185# ifndef YY_CAST
186# ifdef __cplusplus
187# define YY_CAST(Type, Val) static_cast<Type> (Val)
188# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
189# else
190# define YY_CAST(Type, Val) ((Type) (Val))
191# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
192# endif
193# endif
194# ifndef YY_NULLPTR
195# if defined __cplusplus
196# if 201103L <= __cplusplus
197# define YY_NULLPTR nullptr
198# else
199# define YY_NULLPTR 0
200# endif
201# else
202# define YY_NULLPTR ((void*)0)
203# endif
204# endif
205
206
207/* Debug traces. */
208#ifndef YYDEBUG
209# define YYDEBUG 0
210#endif
211#if YYDEBUG
212extern int yydebug;
213#endif
214
215/* Token kinds. */
216#ifndef YYTOKENTYPE
217# define YYTOKENTYPE
219 {
221 YYEOF = 0, /* "end of file" */
222 YYerror = 256, /* error */
223 YYUNDEF = 257, /* "invalid token" */
224 tDAY = 258, /* tDAY */
225 tDAYZONE = 259, /* tDAYZONE */
226 tMERIDIAN = 260, /* tMERIDIAN */
227 tMONTH = 261, /* tMONTH */
228 tMONTH_UNIT = 262, /* tMONTH_UNIT */
229 tSEC_UNIT = 263, /* tSEC_UNIT */
230 tSNUMBER = 264, /* tSNUMBER */
231 tUNUMBER = 265, /* tUNUMBER */
232 tZONE = 266 /* tZONE */
233 };
235#endif
236/* Token kinds. */
237#define YYEOF 0
238#define YYerror 256
239#define YYUNDEF 257
240#define tDAY 258
241#define tDAYZONE 259
242#define tMERIDIAN 260
243#define tMONTH 261
244#define tMONTH_UNIT 262
245#define tSEC_UNIT 263
246#define tSNUMBER 264
247#define tUNUMBER 265
248#define tZONE 266
249
250/* Value type. */
251#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
253{
254#line 114 "server/parsedate.y"
255
256 time_t Number;
258
259#line 260 "y.tab.c"
260
261};
262typedef union YYSTYPE YYSTYPE;
263# define YYSTYPE_IS_TRIVIAL 1
264# define YYSTYPE_IS_DECLARED 1
265#endif
266
267
268extern YYSTYPE yylval;
269
270int yyparse (void);
271
272
273/* Symbol kind. */
275{
277 YYSYMBOL_YYEOF = 0, /* "end of file" */
278 YYSYMBOL_YYerror = 1, /* error */
279 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
280 YYSYMBOL_tDAY = 3, /* tDAY */
281 YYSYMBOL_tDAYZONE = 4, /* tDAYZONE */
282 YYSYMBOL_tMERIDIAN = 5, /* tMERIDIAN */
283 YYSYMBOL_tMONTH = 6, /* tMONTH */
284 YYSYMBOL_tMONTH_UNIT = 7, /* tMONTH_UNIT */
285 YYSYMBOL_tSEC_UNIT = 8, /* tSEC_UNIT */
286 YYSYMBOL_tSNUMBER = 9, /* tSNUMBER */
287 YYSYMBOL_tUNUMBER = 10, /* tUNUMBER */
288 YYSYMBOL_tZONE = 11, /* tZONE */
289 YYSYMBOL_12_ = 12, /* ':' */
290 YYSYMBOL_13_ = 13, /* '/' */
291 YYSYMBOL_14_ = 14, /* ',' */
292 YYSYMBOL_YYACCEPT = 15, /* $accept */
293 YYSYMBOL_spec = 16, /* spec */
294 YYSYMBOL_item = 17, /* item */
295 YYSYMBOL_time = 18, /* time */
296 YYSYMBOL_zone = 19, /* zone */
297 YYSYMBOL_numzone = 20, /* numzone */
298 YYSYMBOL_date = 21, /* date */
299 YYSYMBOL_rel = 22, /* rel */
300 YYSYMBOL_o_merid = 23 /* o_merid */
303
304
305
306
307#ifdef short
308# undef short
309#endif
310
311/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
312 <limits.h> and (if available) <stdint.h> are included
313 so that the code can choose integer types of a good width. */
314
315#ifndef __PTRDIFF_MAX__
316# include <limits.h> /* INFRINGES ON USER NAME SPACE */
317# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
318# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
319# define YY_STDINT_H
320# endif
321#endif
322
323/* Narrow types that promote to a signed type and that can represent a
324 signed or unsigned integer of at least N bits. In tables they can
325 save space and decrease cache pressure. Promoting to a signed type
326 helps avoid bugs in integer arithmetic. */
327
328#ifdef __INT_LEAST8_MAX__
329typedef __INT_LEAST8_TYPE__ yytype_int8;
330#elif defined YY_STDINT_H
331typedef int_least8_t yytype_int8;
332#else
333typedef signed char yytype_int8;
334#endif
335
336#ifdef __INT_LEAST16_MAX__
337typedef __INT_LEAST16_TYPE__ yytype_int16;
338#elif defined YY_STDINT_H
339typedef int_least16_t yytype_int16;
340#else
341typedef short yytype_int16;
342#endif
343
344#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
345typedef __UINT_LEAST8_TYPE__ yytype_uint8;
346#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
347 && UINT_LEAST8_MAX <= INT_MAX)
348typedef uint_least8_t yytype_uint8;
349#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
350typedef unsigned char yytype_uint8;
351#else
352typedef short yytype_uint8;
353#endif
354
355#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
356typedef __UINT_LEAST16_TYPE__ yytype_uint16;
357#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
358 && UINT_LEAST16_MAX <= INT_MAX)
359typedef uint_least16_t yytype_uint16;
360#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
361typedef unsigned short yytype_uint16;
362#else
363typedef int yytype_uint16;
364#endif
365
366#ifndef YYPTRDIFF_T
367# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
368# define YYPTRDIFF_T __PTRDIFF_TYPE__
369# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
370# elif defined PTRDIFF_MAX
371# ifndef ptrdiff_t
372# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
373# endif
374# define YYPTRDIFF_T ptrdiff_t
375# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
376# else
377# define YYPTRDIFF_T long
378# define YYPTRDIFF_MAXIMUM LONG_MAX
379# endif
380#endif
381
382#ifndef YYSIZE_T
383# ifdef __SIZE_TYPE__
384# define YYSIZE_T __SIZE_TYPE__
385# elif defined size_t
386# define YYSIZE_T size_t
387# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
388# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
389# define YYSIZE_T size_t
390# else
391# define YYSIZE_T unsigned
392# endif
393#endif
394
395#define YYSIZE_MAXIMUM \
396 YY_CAST (YYPTRDIFF_T, \
397 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
398 ? YYPTRDIFF_MAXIMUM \
399 : YY_CAST (YYSIZE_T, -1)))
400
401#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
402
403
404/* Stored state numbers (used for stacks). */
406
407/* State numbers in computations. */
408typedef int yy_state_fast_t;
409
410#ifndef YY_
411# if defined YYENABLE_NLS && YYENABLE_NLS
412# if ENABLE_NLS
413# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
414# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
415# endif
416# endif
417# ifndef YY_
418# define YY_(Msgid) Msgid
419# endif
420#endif
421
422
423#ifndef YY_ATTRIBUTE_PURE
424# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
425# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
426# else
427# define YY_ATTRIBUTE_PURE
428# endif
429#endif
430
431#ifndef YY_ATTRIBUTE_UNUSED
432# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
433# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
434# else
435# define YY_ATTRIBUTE_UNUSED
436# endif
437#endif
438
439/* Suppress unused-variable warnings by "using" E. */
440#if ! defined lint || defined __GNUC__
441# define YYUSE(E) ((void) (E))
442#else
443# define YYUSE(E) /* empty */
444#endif
445
446#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
447/* Suppress an incorrect diagnostic about yylval being uninitialized. */
448# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
449 _Pragma ("GCC diagnostic push") \
450 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
451 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
452# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
453 _Pragma ("GCC diagnostic pop")
454#else
455# define YY_INITIAL_VALUE(Value) Value
456#endif
457#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
458# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
459# define YY_IGNORE_MAYBE_UNINITIALIZED_END
460#endif
461#ifndef YY_INITIAL_VALUE
462# define YY_INITIAL_VALUE(Value) /* Nothing. */
463#endif
464
465#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
466# define YY_IGNORE_USELESS_CAST_BEGIN \
467 _Pragma ("GCC diagnostic push") \
468 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
469# define YY_IGNORE_USELESS_CAST_END \
470 _Pragma ("GCC diagnostic pop")
471#endif
472#ifndef YY_IGNORE_USELESS_CAST_BEGIN
473# define YY_IGNORE_USELESS_CAST_BEGIN
474# define YY_IGNORE_USELESS_CAST_END
475#endif
476
477
478#define YY_ASSERT(E) ((void) (0 && (E)))
479
480#if !defined yyoverflow
481
482/* The parser invokes alloca or malloc; define the necessary symbols. */
483
484# ifdef YYSTACK_USE_ALLOCA
485# if YYSTACK_USE_ALLOCA
486# ifdef __GNUC__
487# define YYSTACK_ALLOC __builtin_alloca
488# elif defined __BUILTIN_VA_ARG_INCR
489# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
490# elif defined _AIX
491# define YYSTACK_ALLOC __alloca
492# elif defined _MSC_VER
493# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
494# define alloca _alloca
495# else
496# define YYSTACK_ALLOC alloca
497# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
498# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
499 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
500# ifndef EXIT_SUCCESS
501# define EXIT_SUCCESS 0
502# endif
503# endif
504# endif
505# endif
506# endif
507
508# ifdef YYSTACK_ALLOC
509 /* Pacify GCC's 'empty if-body' warning. */
510# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
511# ifndef YYSTACK_ALLOC_MAXIMUM
512 /* The OS might guarantee only one guard page at the bottom of the stack,
513 and a page size can be as small as 4096 bytes. So we cannot safely
514 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
515 to allow for a few compiler-allocated temporary stack slots. */
516# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
517# endif
518# else
519# define YYSTACK_ALLOC YYMALLOC
520# define YYSTACK_FREE YYFREE
521# ifndef YYSTACK_ALLOC_MAXIMUM
522# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
523# endif
524# if (defined __cplusplus && ! defined EXIT_SUCCESS \
525 && ! ((defined YYMALLOC || defined malloc) \
526 && (defined YYFREE || defined free)))
527# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
528# ifndef EXIT_SUCCESS
529# define EXIT_SUCCESS 0
530# endif
531# endif
532# ifndef YYMALLOC
533# define YYMALLOC malloc
534# if ! defined malloc && ! defined EXIT_SUCCESS
535void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
536# endif
537# endif
538# ifndef YYFREE
539# define YYFREE free
540# if ! defined free && ! defined EXIT_SUCCESS
541void free (void *); /* INFRINGES ON USER NAME SPACE */
542# endif
543# endif
544# endif
545#endif /* !defined yyoverflow */
546
547#if (! defined yyoverflow \
548 && (! defined __cplusplus \
549 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
550
551/* A type that is properly aligned for any stack member. */
553{
556};
557
558/* The size of the maximum gap between one aligned stack and the next. */
559# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
560
561/* The size of an array large to enough to hold all stacks, each with
562 N elements. */
563# define YYSTACK_BYTES(N) \
564 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
565 + YYSTACK_GAP_MAXIMUM)
566
567# define YYCOPY_NEEDED 1
568
569/* Relocate STACK from its old location to the new one. The
570 local variables YYSIZE and YYSTACKSIZE give the old and new number of
571 elements in the stack, and YYPTR gives the new location of the
572 stack. Advance YYPTR to a properly aligned location for the next
573 stack. */
574# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
575 do \
576 { \
577 YYPTRDIFF_T yynewbytes; \
578 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
579 Stack = &yyptr->Stack_alloc; \
580 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
581 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
582 } \
583 while (0)
584
585#endif
586
587#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
588/* Copy COUNT objects from SRC to DST. The source and destination do
589 not overlap. */
590# ifndef YYCOPY
591# if defined __GNUC__ && 1 < __GNUC__
592# define YYCOPY(Dst, Src, Count) \
593 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
594# else
595# define YYCOPY(Dst, Src, Count) \
596 do \
597 { \
598 YYPTRDIFF_T yyi; \
599 for (yyi = 0; yyi < (Count); yyi++) \
600 (Dst)[yyi] = (Src)[yyi]; \
601 } \
602 while (0)
603# endif
604# endif
605#endif /* !YYCOPY_NEEDED */
606
607/* YYFINAL -- State number of the termination state. */
608#define YYFINAL 2
609/* YYLAST -- Last index in YYTABLE. */
610#define YYLAST 40
611
612/* YYNTOKENS -- Number of terminals. */
613#define YYNTOKENS 15
614/* YYNNTS -- Number of nonterminals. */
615#define YYNNTS 9
616/* YYNRULES -- Number of rules. */
617#define YYNRULES 30
618/* YYNSTATES -- Number of states. */
619#define YYNSTATES 44
620
621/* YYMAXUTOK -- Last valid token kind. */
622#define YYMAXUTOK 266
623
624
625/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
626 as returned by yylex, with out-of-bounds checking. */
627#define YYTRANSLATE(YYX) \
628 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
629 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
630 : YYSYMBOL_YYUNDEF)
631
632/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
633 as returned by yylex. */
634static const yytype_int8 yytranslate[] =
635{
636 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
638 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
640 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
641 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
659 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
661 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
662 5, 6, 7, 8, 9, 10, 11
663};
664
665#if YYDEBUG
666 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
667static const yytype_int16 yyrline[] =
668{
669 0, 128, 128, 129, 132, 141, 145, 148, 153, 165,
670 171, 178, 184, 194, 198, 202, 210, 216, 237, 241,
671 253, 257, 262, 266, 271, 278, 281, 284, 287, 292,
672 295
673};
674#endif
675
676/** Accessing symbol of state STATE. */
677#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
678
679#if YYDEBUG || 0
680/* The user-facing name of the symbol whose (internal) number is
681 YYSYMBOL. No bounds checking. */
682static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
683
684/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
685 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
686static const char *const yytname[] =
687{
688 "\"end of file\"", "error", "\"invalid token\"", "tDAY", "tDAYZONE",
689 "tMERIDIAN", "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER",
690 "tUNUMBER", "tZONE", "':'", "'/'", "','", "$accept", "spec", "item",
691 "time", "zone", "numzone", "date", "rel", "o_merid", YY_NULLPTR
692};
693
694static const char *
695yysymbol_name (yysymbol_kind_t yysymbol)
696{
697 return yytname[yysymbol];
698}
699#endif
700
701#ifdef YYPRINT
702/* YYTOKNUM[NUM] -- (External) token number corresponding to the
703 (internal) symbol number NUM (which must be that of a token). */
704static const yytype_int16 yytoknum[] =
705{
706 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
707 265, 266, 58, 47, 44
708};
709#endif
710
711#define YYPACT_NINF (-29)
712
713#define yypact_value_is_default(Yyn) \
714 ((Yyn) == YYPACT_NINF)
715
716#define YYTABLE_NINF (-1)
717
718#define yytable_value_is_error(Yyn) \
719 0
720
721 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
722 STATE-NUM. */
723static const yytype_int8 yypact[] =
724{
725 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
726 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
727 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
728 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
729 0, -29, -29, -29
730};
731
732 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
733 Performed when YYTABLE does not specify something else to do. Zero
734 means the default is an error. */
735static const yytype_int8 yydefact[] =
736{
737 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
738 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
739 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
740 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
741 29, 19, 12, 11
742};
743
744 /* YYPGOTO[NTERM-NUM]. */
745static const yytype_int8 yypgoto[] =
746{
747 -29, -29, -29, -29, -29, -24, -29, -29, -28
748};
749
750 /* YYDEFGOTO[NTERM-NUM]. */
751static const yytype_int8 yydefgoto[] =
752{
753 -1, 1, 7, 8, 25, 26, 9, 10, 21
754};
755
756 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
757 positive, shift that token. If negative, reduce the rule whose
758 number is the opposite. If YYTABLE_NINF, syntax error. */
759static const yytype_int8 yytable[] =
760{
761 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
762 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
763 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
764 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
765 41
766};
767
768static const yytype_int8 yycheck[] =
769{
770 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
771 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
772 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
773 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
774 10
775};
776
777 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
778 symbol of state STATE-NUM. */
779static const yytype_int8 yystos[] =
780{
781 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
782 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
783 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
784 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
785 10, 10, 20, 23
786};
787
788 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
789static const yytype_int8 yyr1[] =
790{
791 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
792 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
793 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
794 23
795};
796
797 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
798static const yytype_int8 yyr2[] =
799{
800 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
801 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
802 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
803 1
804};
805
806
807enum { YYENOMEM = -2 };
808
809#define yyerrok (yyerrstatus = 0)
810#define yyclearin (yychar = YYEMPTY)
811
812#define YYACCEPT goto yyacceptlab
813#define YYABORT goto yyabortlab
814#define YYERROR goto yyerrorlab
815
816
817#define YYRECOVERING() (!!yyerrstatus)
818
819#define YYBACKUP(Token, Value) \
820 do \
821 if (yychar == YYEMPTY) \
822 { \
823 yychar = (Token); \
824 yylval = (Value); \
825 YYPOPSTACK (yylen); \
826 yystate = *yyssp; \
827 goto yybackup; \
828 } \
829 else \
830 { \
831 yyerror (YY_("syntax error: cannot back up")); \
832 YYERROR; \
833 } \
834 while (0)
835
836/* Backward compatibility with an undocumented macro.
837 Use YYerror or YYUNDEF. */
838#define YYERRCODE YYUNDEF
839
840
841/* Enable debugging if requested. */
842#if YYDEBUG
843
844# ifndef YYFPRINTF
845# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
846# define YYFPRINTF fprintf
847# endif
848
849# define YYDPRINTF(Args) \
850do { \
851 if (yydebug) \
852 YYFPRINTF Args; \
853} while (0)
854
855/* This macro is provided for backward compatibility. */
856# ifndef YY_LOCATION_PRINT
857# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
858# endif
859
860
861# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
862do { \
863 if (yydebug) \
864 { \
865 YYFPRINTF (stderr, "%s ", Title); \
866 yy_symbol_print (stderr, \
867 Kind, Value); \
868 YYFPRINTF (stderr, "\n"); \
869 } \
870} while (0)
871
872
873/*-----------------------------------.
874| Print this symbol's value on YYO. |
875`-----------------------------------*/
876
877static void
878yy_symbol_value_print (FILE *yyo,
879 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
880{
881 FILE *yyoutput = yyo;
882 YYUSE (yyoutput);
883 if (!yyvaluep)
884 return;
885# ifdef YYPRINT
886 if (yykind < YYNTOKENS)
887 YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
888# endif
890 YYUSE (yykind);
892}
893
894
895/*---------------------------.
896| Print this symbol on YYO. |
897`---------------------------*/
898
899static void
900yy_symbol_print (FILE *yyo,
901 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
902{
903 YYFPRINTF (yyo, "%s %s (",
904 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
905
906 yy_symbol_value_print (yyo, yykind, yyvaluep);
907 YYFPRINTF (yyo, ")");
908}
909
910/*------------------------------------------------------------------.
911| yy_stack_print -- Print the state stack from its BOTTOM up to its |
912| TOP (included). |
913`------------------------------------------------------------------*/
914
915static void
916yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
917{
918 YYFPRINTF (stderr, "Stack now");
919 for (; yybottom <= yytop; yybottom++)
920 {
921 int yybot = *yybottom;
922 YYFPRINTF (stderr, " %d", yybot);
923 }
924 YYFPRINTF (stderr, "\n");
925}
926
927# define YY_STACK_PRINT(Bottom, Top) \
928do { \
929 if (yydebug) \
930 yy_stack_print ((Bottom), (Top)); \
931} while (0)
932
933
934/*------------------------------------------------.
935| Report that the YYRULE is going to be reduced. |
936`------------------------------------------------*/
937
938static void
939yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
940 int yyrule)
941{
942 int yylno = yyrline[yyrule];
943 int yynrhs = yyr2[yyrule];
944 int yyi;
945 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
946 yyrule - 1, yylno);
947 /* The symbols being reduced. */
948 for (yyi = 0; yyi < yynrhs; yyi++)
949 {
950 YYFPRINTF (stderr, " $%d = ", yyi + 1);
951 yy_symbol_print (stderr,
952 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
953 &yyvsp[(yyi + 1) - (yynrhs)]);
954 YYFPRINTF (stderr, "\n");
955 }
956}
957
958# define YY_REDUCE_PRINT(Rule) \
959do { \
960 if (yydebug) \
961 yy_reduce_print (yyssp, yyvsp, Rule); \
962} while (0)
963
964/* Nonzero means print parse trace. It is left uninitialized so that
965 multiple parsers can coexist. */
966int yydebug;
967#else /* !YYDEBUG */
968# define YYDPRINTF(Args) ((void) 0)
969# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
970# define YY_STACK_PRINT(Bottom, Top)
971# define YY_REDUCE_PRINT(Rule)
972#endif /* !YYDEBUG */
973
974
975/* YYINITDEPTH -- initial size of the parser's stacks. */
976#ifndef YYINITDEPTH
977# define YYINITDEPTH 200
978#endif
979
980/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
981 if the built-in stack extension method is used).
982
983 Do not make this value too large; the results are undefined if
984 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
985 evaluated with infinite-precision integer arithmetic. */
986
987#ifndef YYMAXDEPTH
988# define YYMAXDEPTH 10000
989#endif
990
991
992
993
994
995
996/*-----------------------------------------------.
997| Release the memory associated to this symbol. |
998`-----------------------------------------------*/
999
1000static void
1001yydestruct (const char *yymsg,
1002 yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
1003{
1004 YYUSE (yyvaluep);
1005 if (!yymsg)
1006 yymsg = "Deleting";
1007 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1008
1010 YYUSE (yykind);
1012}
1013
1014
1015/* Lookahead token kind. */
1017
1018/* The semantic value of the lookahead symbol. */
1020/* Number of syntax errors so far. */
1022
1023
1024
1025
1026/*----------.
1027| yyparse. |
1028`----------*/
1029
1030int
1032{
1033 yy_state_fast_t yystate = 0;
1034 /* Number of tokens to shift before error messages enabled. */
1035 int yyerrstatus = 0;
1036
1037 /* Refer to the stacks through separate pointers, to allow yyoverflow
1038 to reallocate them elsewhere. */
1039
1040 /* Their size. */
1041 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1042
1043 /* The state stack: array, bottom, top. */
1044 yy_state_t yyssa[YYINITDEPTH];
1045 yy_state_t *yyss = yyssa;
1046 yy_state_t *yyssp = yyss;
1047
1048 /* The semantic value stack: array, bottom, top. */
1049 YYSTYPE yyvsa[YYINITDEPTH];
1050 YYSTYPE *yyvs = yyvsa;
1051 YYSTYPE *yyvsp = yyvs;
1052
1053 int yyn;
1054 /* The return value of yyparse. */
1055 int yyresult;
1056 /* Lookahead symbol kind. */
1058 /* The variables used to return semantic value and location from the
1059 action routines. */
1060 YYSTYPE yyval;
1061
1062
1063
1064#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1065
1066 /* The number of symbols on the RHS of the reduced rule.
1067 Keep to zero when no symbol should be popped. */
1068 int yylen = 0;
1069
1070 YYDPRINTF ((stderr, "Starting parse\n"));
1071
1072 yychar = YYEMPTY; /* Cause a token to be read. */
1073 goto yysetstate;
1074
1075
1076/*------------------------------------------------------------.
1077| yynewstate -- push a new state, which is found in yystate. |
1078`------------------------------------------------------------*/
1079yynewstate:
1080 /* In all cases, when you get here, the value and location stacks
1081 have just been pushed. So pushing a state here evens the stacks. */
1082 yyssp++;
1083
1084
1085/*--------------------------------------------------------------------.
1086| yysetstate -- set current state (the top of the stack) to yystate. |
1087`--------------------------------------------------------------------*/
1088yysetstate:
1089 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1090 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1092 *yyssp = YY_CAST (yy_state_t, yystate);
1094 YY_STACK_PRINT (yyss, yyssp);
1095
1096 if (yyss + yystacksize - 1 <= yyssp)
1097#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1098 goto yyexhaustedlab;
1099#else
1100 {
1101 /* Get the current used size of the three stacks, in elements. */
1102 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1103
1104# if defined yyoverflow
1105 {
1106 /* Give user a chance to reallocate the stack. Use copies of
1107 these so that the &'s don't force the real ones into
1108 memory. */
1109 yy_state_t *yyss1 = yyss;
1110 YYSTYPE *yyvs1 = yyvs;
1111
1112 /* Each stack pointer address is followed by the size of the
1113 data in use in that stack, in bytes. This used to be a
1114 conditional around just the two extra args, but that might
1115 be undefined if yyoverflow is a macro. */
1116 yyoverflow (YY_("memory exhausted"),
1117 &yyss1, yysize * YYSIZEOF (*yyssp),
1118 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1119 &yystacksize);
1120 yyss = yyss1;
1121 yyvs = yyvs1;
1122 }
1123# else /* defined YYSTACK_RELOCATE */
1124 /* Extend the stack our own way. */
1125 if (YYMAXDEPTH <= yystacksize)
1126 goto yyexhaustedlab;
1127 yystacksize *= 2;
1128 if (YYMAXDEPTH < yystacksize)
1129 yystacksize = YYMAXDEPTH;
1130
1131 {
1132 yy_state_t *yyss1 = yyss;
1133 union yyalloc *yyptr =
1134 YY_CAST (union yyalloc *,
1135 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1136 if (! yyptr)
1137 goto yyexhaustedlab;
1140# undef YYSTACK_RELOCATE
1141 if (yyss1 != yyssa)
1142 YYSTACK_FREE (yyss1);
1143 }
1144# endif
1145
1146 yyssp = yyss + yysize - 1;
1147 yyvsp = yyvs + yysize - 1;
1148
1150 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1151 YY_CAST (long, yystacksize)));
1153
1154 if (yyss + yystacksize - 1 <= yyssp)
1155 YYABORT;
1156 }
1157#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1158
1159 if (yystate == YYFINAL)
1160 YYACCEPT;
1161
1162 goto yybackup;
1163
1164
1165/*-----------.
1166| yybackup. |
1167`-----------*/
1168yybackup:
1169 /* Do appropriate processing given the current state. Read a
1170 lookahead token if we need one and don't already have one. */
1171
1172 /* First try to decide what to do without reference to lookahead token. */
1173 yyn = yypact[yystate];
1174 if (yypact_value_is_default (yyn))
1175 goto yydefault;
1176
1177 /* Not known => get a lookahead token if don't already have one. */
1178
1179 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1180 if (yychar == YYEMPTY)
1181 {
1182 YYDPRINTF ((stderr, "Reading a token\n"));
1183 yychar = yylex ();
1184 }
1185
1186 if (yychar <= YYEOF)
1187 {
1188 yychar = YYEOF;
1189 yytoken = YYSYMBOL_YYEOF;
1190 YYDPRINTF ((stderr, "Now at end of input.\n"));
1191 }
1192 else if (yychar == YYerror)
1193 {
1194 /* The scanner already issued an error message, process directly
1195 to error recovery. But do not keep the error token as
1196 lookahead, it is too special and may lead us to an endless
1197 loop in error recovery. */
1198 yychar = YYUNDEF;
1199 yytoken = YYSYMBOL_YYerror;
1200 goto yyerrlab1;
1201 }
1202 else
1203 {
1204 yytoken = YYTRANSLATE (yychar);
1205 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1206 }
1207
1208 /* If the proper action on seeing token YYTOKEN is to reduce or to
1209 detect an error, take that action. */
1210 yyn += yytoken;
1211 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1212 goto yydefault;
1213 yyn = yytable[yyn];
1214 if (yyn <= 0)
1215 {
1216 if (yytable_value_is_error (yyn))
1217 goto yyerrlab;
1218 yyn = -yyn;
1219 goto yyreduce;
1220 }
1221
1222 /* Count tokens shifted since error; after three, turn off error
1223 status. */
1224 if (yyerrstatus)
1225 yyerrstatus--;
1226
1227 /* Shift the lookahead token. */
1228 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1229 yystate = yyn;
1231 *++yyvsp = yylval;
1233
1234 /* Discard the shifted token. */
1235 yychar = YYEMPTY;
1236 goto yynewstate;
1237
1238
1239/*-----------------------------------------------------------.
1240| yydefault -- do the default action for the current state. |
1241`-----------------------------------------------------------*/
1242yydefault:
1243 yyn = yydefact[yystate];
1244 if (yyn == 0)
1245 goto yyerrlab;
1246 goto yyreduce;
1247
1248
1249/*-----------------------------.
1250| yyreduce -- do a reduction. |
1251`-----------------------------*/
1252yyreduce:
1253 /* yyn is the number of a rule to reduce with. */
1254 yylen = yyr2[yyn];
1255
1256 /* If YYLEN is nonzero, implement the default value of the action:
1257 '$$ = $1'.
1258
1259 Otherwise, the following line sets YYVAL to garbage.
1260 This behavior is undocumented and Bison
1261 users should not rely upon it. Assigning to YYVAL
1262 unconditionally makes the parser a bit smaller, and it avoids a
1263 GCC warning that YYVAL may be used uninitialized. */
1264 yyval = yyvsp[1-yylen];
1265
1266
1267 YY_REDUCE_PRINT (yyn);
1268 switch (yyn)
1269 {
1270 case 4: /* item: time */
1271#line 132 "server/parsedate.y"
1272 {
1273 yyHaveTime++;
1274#ifdef lint
1275 /* I am compulsive about lint natterings... */
1276 if (yyHaveTime == -1) {
1277 YYERROR;
1278 }
1279#endif /* lint */
1280 }
1281#line 1282 "y.tab.c"
1282 break;
1283
1284 case 5: /* item: time zone */
1285#line 141 "server/parsedate.y"
1286 {
1287 yyHaveTime++;
1288 yyTimezone = (yyvsp[0].Number);
1289 }
1290#line 1291 "y.tab.c"
1291 break;
1292
1293 case 6: /* item: date */
1294#line 145 "server/parsedate.y"
1295 {
1296 yyHaveDate++;
1297 }
1298#line 1299 "y.tab.c"
1299 break;
1300
1301 case 7: /* item: rel */
1302#line 148 "server/parsedate.y"
1303 {
1304 yyHaveRel = 1;
1305 }
1306#line 1307 "y.tab.c"
1307 break;
1308
1309 case 8: /* time: tUNUMBER o_merid */
1310#line 153 "server/parsedate.y"
1311 {
1312 if ((yyvsp[-1].Number) < 100) {
1313 yyHour = (yyvsp[-1].Number);
1314 yyMinutes = 0;
1315 }
1316 else {
1317 yyHour = (yyvsp[-1].Number) / 100;
1318 yyMinutes = (yyvsp[-1].Number) % 100;
1319 }
1320 yySeconds = 0;
1321 yyMeridian = (yyvsp[0].Meridian);
1322 }
1323#line 1324 "y.tab.c"
1324 break;
1325
1326 case 9: /* time: tUNUMBER ':' tUNUMBER o_merid */
1327#line 165 "server/parsedate.y"
1328 {
1329 yyHour = (yyvsp[-3].Number);
1330 yyMinutes = (yyvsp[-1].Number);
1331 yySeconds = 0;
1332 yyMeridian = (yyvsp[0].Meridian);
1333 }
1334#line 1335 "y.tab.c"
1335 break;
1336
1337 case 10: /* time: tUNUMBER ':' tUNUMBER numzone */
1338#line 171 "server/parsedate.y"
1339 {
1340 yyHour = (yyvsp[-3].Number);
1341 yyMinutes = (yyvsp[-1].Number);
1342 yyTimezone = (yyvsp[0].Number);
1343 yyMeridian = MER24;
1344 yyDSTmode = DSToff;
1345 }
1346#line 1347 "y.tab.c"
1347 break;
1348
1349 case 11: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid */
1350#line 178 "server/parsedate.y"
1351 {
1352 yyHour = (yyvsp[-5].Number);
1353 yyMinutes = (yyvsp[-3].Number);
1354 yySeconds = (yyvsp[-1].Number);
1355 yyMeridian = (yyvsp[0].Meridian);
1356 }
1357#line 1358 "y.tab.c"
1358 break;
1359
1360 case 12: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER numzone */
1361#line 184 "server/parsedate.y"
1362 {
1363 yyHour = (yyvsp[-5].Number);
1364 yyMinutes = (yyvsp[-3].Number);
1365 yySeconds = (yyvsp[-1].Number);
1366 yyTimezone = (yyvsp[0].Number);
1367 yyMeridian = MER24;
1368 yyDSTmode = DSToff;
1369 }
1370#line 1371 "y.tab.c"
1371 break;
1372
1373 case 13: /* zone: tZONE */
1374#line 194 "server/parsedate.y"
1375 {
1376 (yyval.Number) = (yyvsp[0].Number);
1377 yyDSTmode = DSToff;
1378 }
1379#line 1380 "y.tab.c"
1380 break;
1381
1382 case 14: /* zone: tDAYZONE */
1383#line 198 "server/parsedate.y"
1384 {
1385 (yyval.Number) = (yyvsp[0].Number);
1386 yyDSTmode = DSTon;
1387 }
1388#line 1389 "y.tab.c"
1389 break;
1390
1391 case 15: /* zone: tZONE numzone */
1392#line 202 "server/parsedate.y"
1393 {
1394 /* Only allow "GMT+300" and "GMT-0800" */
1395 if ((yyvsp[-1].Number) != 0) {
1396 YYABORT;
1397 }
1398 (yyval.Number) = (yyvsp[0].Number);
1399 yyDSTmode = DSToff;
1400 }
1401#line 1402 "y.tab.c"
1402 break;
1403
1404 case 16: /* zone: numzone */
1405#line 210 "server/parsedate.y"
1406 {
1407 (yyval.Number) = (yyvsp[0].Number);
1408 yyDSTmode = DSToff;
1409 }
1410#line 1411 "y.tab.c"
1411 break;
1412
1413 case 17: /* numzone: tSNUMBER */
1414#line 216 "server/parsedate.y"
1415 {
1416 int i;
1417
1418 /* Unix and GMT and numeric timezones -- a little confusing. */
1419 if ((yyvsp[0].Number) < 0) {
1420 /* Don't work with negative modulus. */
1421 (yyvsp[0].Number) = -(yyvsp[0].Number);
1422 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1423 YYABORT;
1424 }
1425 (yyval.Number) = ((yyvsp[0].Number) / 100) * 60 + i;
1426 }
1427 else {
1428 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1429 YYABORT;
1430 }
1431 (yyval.Number) = -(((yyvsp[0].Number) / 100) * 60 + i);
1432 }
1433 }
1434#line 1435 "y.tab.c"
1435 break;
1436
1437 case 18: /* date: tUNUMBER '/' tUNUMBER */
1438#line 237 "server/parsedate.y"
1439 {
1440 yyMonth = (yyvsp[-2].Number);
1441 yyDay = (yyvsp[0].Number);
1442 }
1443#line 1444 "y.tab.c"
1444 break;
1445
1446 case 19: /* date: tUNUMBER '/' tUNUMBER '/' tUNUMBER */
1447#line 241 "server/parsedate.y"
1448 {
1449 if ((yyvsp[-4].Number) > 100) {
1450 yyYear = (yyvsp[-4].Number);
1451 yyMonth = (yyvsp[-2].Number);
1452 yyDay = (yyvsp[0].Number);
1453 }
1454 else {
1455 yyMonth = (yyvsp[-4].Number);
1456 yyDay = (yyvsp[-2].Number);
1457 yyYear = (yyvsp[0].Number);
1458 }
1459 }
1460#line 1461 "y.tab.c"
1461 break;
1462
1463 case 20: /* date: tMONTH tUNUMBER */
1464#line 253 "server/parsedate.y"
1465 {
1466 yyMonth = (yyvsp[-1].Number);
1467 yyDay = (yyvsp[0].Number);
1468 }
1469#line 1470 "y.tab.c"
1470 break;
1471
1472 case 21: /* date: tMONTH tUNUMBER ',' tUNUMBER */
1473#line 257 "server/parsedate.y"
1474 {
1475 yyMonth = (yyvsp[-3].Number);
1476 yyDay = (yyvsp[-2].Number);
1477 yyYear = (yyvsp[0].Number);
1478 }
1479#line 1480 "y.tab.c"
1480 break;
1481
1482 case 22: /* date: tUNUMBER tMONTH */
1483#line 262 "server/parsedate.y"
1484 {
1485 yyDay = (yyvsp[-1].Number);
1486 yyMonth = (yyvsp[0].Number);
1487 }
1488#line 1489 "y.tab.c"
1489 break;
1490
1491 case 23: /* date: tUNUMBER tMONTH tUNUMBER */
1492#line 266 "server/parsedate.y"
1493 {
1494 yyDay = (yyvsp[-2].Number);
1495 yyMonth = (yyvsp[-1].Number);
1496 yyYear = (yyvsp[0].Number);
1497 }
1498#line 1499 "y.tab.c"
1499 break;
1500
1501 case 24: /* date: tDAY ',' tUNUMBER tMONTH tUNUMBER */
1502#line 271 "server/parsedate.y"
1503 {
1504 yyDay = (yyvsp[-2].Number);
1505 yyMonth = (yyvsp[-1].Number);
1506 yyYear = (yyvsp[0].Number);
1507 }
1508#line 1509 "y.tab.c"
1509 break;
1510
1511 case 25: /* rel: tSNUMBER tSEC_UNIT */
1512#line 278 "server/parsedate.y"
1513 {
1514 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1515 }
1516#line 1517 "y.tab.c"
1517 break;
1518
1519 case 26: /* rel: tUNUMBER tSEC_UNIT */
1520#line 281 "server/parsedate.y"
1521 {
1522 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1523 }
1524#line 1525 "y.tab.c"
1525 break;
1526
1527 case 27: /* rel: tSNUMBER tMONTH_UNIT */
1528#line 284 "server/parsedate.y"
1529 {
1530 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1531 }
1532#line 1533 "y.tab.c"
1533 break;
1534
1535 case 28: /* rel: tUNUMBER tMONTH_UNIT */
1536#line 287 "server/parsedate.y"
1537 {
1538 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1539 }
1540#line 1541 "y.tab.c"
1541 break;
1542
1543 case 29: /* o_merid: %empty */
1544#line 292 "server/parsedate.y"
1545 {
1546 (yyval.Meridian) = MER24;
1547 }
1548#line 1549 "y.tab.c"
1549 break;
1550
1551 case 30: /* o_merid: tMERIDIAN */
1552#line 295 "server/parsedate.y"
1553 {
1554 (yyval.Meridian) = (yyvsp[0].Meridian);
1555 }
1556#line 1557 "y.tab.c"
1557 break;
1558
1559
1560#line 1561 "y.tab.c"
1561
1562 default: break;
1563 }
1564 /* User semantic actions sometimes alter yychar, and that requires
1565 that yytoken be updated with the new translation. We take the
1566 approach of translating immediately before every use of yytoken.
1567 One alternative is translating here after every semantic action,
1568 but that translation would be missed if the semantic action invokes
1569 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1570 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1571 incorrect destructor might then be invoked immediately. In the
1572 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1573 to an incorrect destructor call or verbose syntax error message
1574 before the lookahead is translated. */
1575 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1576
1577 YYPOPSTACK (yylen);
1578 yylen = 0;
1579
1580 *++yyvsp = yyval;
1581
1582 /* Now 'shift' the result of the reduction. Determine what state
1583 that goes to, based on the state we popped back to and the rule
1584 number reduced by. */
1585 {
1586 const int yylhs = yyr1[yyn] - YYNTOKENS;
1587 const int yyi = yypgoto[yylhs] + *yyssp;
1588 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1589 ? yytable[yyi]
1590 : yydefgoto[yylhs]);
1591 }
1592
1593 goto yynewstate;
1594
1595
1596/*--------------------------------------.
1597| yyerrlab -- here on detecting error. |
1598`--------------------------------------*/
1599yyerrlab:
1600 /* Make sure we have latest lookahead translation. See comments at
1601 user semantic actions for why this is necessary. */
1603 /* If not already recovering from an error, report this error. */
1604 if (!yyerrstatus)
1605 {
1606 ++yynerrs;
1607 yyerror (YY_("syntax error"));
1608 }
1609
1610 if (yyerrstatus == 3)
1611 {
1612 /* If just tried and failed to reuse lookahead token after an
1613 error, discard it. */
1614
1615 if (yychar <= YYEOF)
1616 {
1617 /* Return failure if at end of input. */
1618 if (yychar == YYEOF)
1619 YYABORT;
1620 }
1621 else
1622 {
1623 yydestruct ("Error: discarding",
1624 yytoken, &yylval);
1625 yychar = YYEMPTY;
1626 }
1627 }
1628
1629 /* Else will try to reuse lookahead token after shifting the error
1630 token. */
1631 goto yyerrlab1;
1632
1633
1634/*---------------------------------------------------.
1635| yyerrorlab -- error raised explicitly by YYERROR. |
1636`---------------------------------------------------*/
1637yyerrorlab:
1638 /* Pacify compilers when the user code never invokes YYERROR and the
1639 label yyerrorlab therefore never appears in user code. */
1640 if (0)
1641 YYERROR;
1642
1643 /* Do not reclaim the symbols of the rule whose action triggered
1644 this YYERROR. */
1645 YYPOPSTACK (yylen);
1646 yylen = 0;
1647 YY_STACK_PRINT (yyss, yyssp);
1648 yystate = *yyssp;
1649 goto yyerrlab1;
1650
1651
1652/*-------------------------------------------------------------.
1653| yyerrlab1 -- common code for both syntax error and YYERROR. |
1654`-------------------------------------------------------------*/
1655yyerrlab1:
1656 yyerrstatus = 3; /* Each real token shifted decrements this. */
1657
1658 /* Pop stack until we find a state that shifts the error token. */
1659 for (;;)
1660 {
1661 yyn = yypact[yystate];
1662 if (!yypact_value_is_default (yyn))
1663 {
1664 yyn += YYSYMBOL_YYerror;
1665 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1666 {
1667 yyn = yytable[yyn];
1668 if (0 < yyn)
1669 break;
1670 }
1671 }
1672
1673 /* Pop the current state because it cannot handle the error token. */
1674 if (yyssp == yyss)
1675 YYABORT;
1676
1677
1678 yydestruct ("Error: popping",
1679 YY_ACCESSING_SYMBOL (yystate), yyvsp);
1680 YYPOPSTACK (1);
1681 yystate = *yyssp;
1682 YY_STACK_PRINT (yyss, yyssp);
1683 }
1684
1686 *++yyvsp = yylval;
1688
1689
1690 /* Shift the error token. */
1691 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1692
1693 yystate = yyn;
1694 goto yynewstate;
1695
1696
1697/*-------------------------------------.
1698| yyacceptlab -- YYACCEPT comes here. |
1699`-------------------------------------*/
1700yyacceptlab:
1701 yyresult = 0;
1702 goto yyreturn;
1703
1704
1705/*-----------------------------------.
1706| yyabortlab -- YYABORT comes here. |
1707`-----------------------------------*/
1708yyabortlab:
1709 yyresult = 1;
1710 goto yyreturn;
1711
1712
1713#if !defined yyoverflow
1714/*-------------------------------------------------.
1715| yyexhaustedlab -- memory exhaustion comes here. |
1716`-------------------------------------------------*/
1717yyexhaustedlab:
1718 yyerror (YY_("memory exhausted"));
1719 yyresult = 2;
1720 goto yyreturn;
1721#endif
1722
1723
1724/*-------------------------------------------------------.
1725| yyreturn -- parsing is finished, clean up and return. |
1726`-------------------------------------------------------*/
1727yyreturn:
1728 if (yychar != YYEMPTY)
1729 {
1730 /* Make sure we have latest lookahead translation. See comments at
1731 user semantic actions for why this is necessary. */
1732 yytoken = YYTRANSLATE (yychar);
1733 yydestruct ("Cleanup: discarding lookahead",
1734 yytoken, &yylval);
1735 }
1736 /* Do not reclaim the symbols of the rule whose action triggered
1737 this YYABORT or YYACCEPT. */
1738 YYPOPSTACK (yylen);
1739 YY_STACK_PRINT (yyss, yyssp);
1740 while (yyssp != yyss)
1741 {
1742 yydestruct ("Cleanup: popping",
1743 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1744 YYPOPSTACK (1);
1745 }
1746#ifndef yyoverflow
1747 if (yyss != yyssa)
1748 YYSTACK_FREE (yyss);
1749#endif
1750
1751 return yyresult;
1752}
1753
1754#line 300 "server/parsedate.y"
1755
1756
1757/* Month and day table. */
1759 { "january", tMONTH, 1 },
1760 { "february", tMONTH, 2 },
1761 { "march", tMONTH, 3 },
1762 { "april", tMONTH, 4 },
1763 { "may", tMONTH, 5 },
1764 { "june", tMONTH, 6 },
1765 { "july", tMONTH, 7 },
1766 { "august", tMONTH, 8 },
1767 { "september", tMONTH, 9 },
1768 { "october", tMONTH, 10 },
1769 { "november", tMONTH, 11 },
1770 { "december", tMONTH, 12 },
1771 /* The value of the day isn't used... */
1772 { "sunday", tDAY, 0 },
1773 { "monday", tDAY, 0 },
1774 { "tuesday", tDAY, 0 },
1775 { "wednesday", tDAY, 0 },
1776 { "thursday", tDAY, 0 },
1777 { "friday", tDAY, 0 },
1778 { "saturday", tDAY, 0 },
1779};
1780
1781/* Time units table. */
1782static TABLE UnitsTable[] = {
1783 { "year", tMONTH_UNIT, 12 },
1784 { "month", tMONTH_UNIT, 1 },
1785 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
1786 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
1787 { "hour", tSEC_UNIT, 60 * 60 },
1788 { "minute", tSEC_UNIT, 60 },
1789 { "min", tSEC_UNIT, 60 },
1790 { "second", tSEC_UNIT, 1 },
1791 { "sec", tSEC_UNIT, 1 },
1792};
1793
1794/* Timezone table. */
1796 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
1797 { "ut", tZONE, HOUR( 0) }, /* Universal */
1798 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
1799 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
1800 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
1801 { "wet", tZONE, HOUR( 0) }, /* Western European */
1802 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
1803 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
1804 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
1805 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
1806 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
1807 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
1808 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
1809 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
1810 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
1811 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
1812 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
1813 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
1814 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
1815 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
1816 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
1817 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
1818 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
1819 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
1820 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
1821 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
1822 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1823 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1824 { "mez", tZONE, -HOUR(1) }, /* Middle European */
1825 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
1826 { "cet", tZONE, -HOUR(1) }, /* Central European */
1827 { "met", tZONE, -HOUR(1) }, /* Middle European */
1828 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
1829 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
1830 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
1831 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
1832 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
1833 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
1834 { "cct", tZONE, -HOUR(8) }, /* China Coast */
1835 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
1836 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
1837 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
1838 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
1839 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
1840 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
1841 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
1842 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
1843 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
1844
1845 /* For completeness we include the following entries. */
1846#if 0
1847
1848 /* Duplicate names. Either they conflict with a zone listed above
1849 * (which is either more likely to be seen or just been in circulation
1850 * longer), or they conflict with another zone in this section and
1851 * we could not reasonably choose one over the other. */
1852 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
1853 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
1854 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
1855 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
1856 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
1857 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
1858 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
1859 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
1860 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
1861 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
1862 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
1863 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
1864 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
1865 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
1866 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
1867 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
1868 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
1869 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
1870 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
1871 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
1872 { "cst", tZONE, -HOUR(8) }, /* China Standard */
1873 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
1874 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
1875
1876 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
1877 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
1878 { "wat", tZONE, -HOUR(1) }, /* West Africa */
1879 { "at", tZONE, HOUR( 2) }, /* Azores */
1880 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
1881 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
1882 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
1883 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
1884 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
1885 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
1886 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
1887 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
1888 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
1889 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
1890 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
1891 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
1892 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
1893 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
1894 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
1895 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
1896 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
1897 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
1898 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
1899 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
1900 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
1901 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
1902 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
1903 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
1904#endif /* 0 */
1905};
1906
1907
1908/* ARGSUSED */
1909static void
1911{
1912 /* NOTREACHED */
1913}
1914
1915
1916static time_t
1917ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
1918{
1919 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
1920 return -1;
1921 if (Meridian == MER24) {
1922 if (Hours < 0 || Hours > 23)
1923 return -1;
1924 }
1925 else {
1926 if (Hours < 1 || Hours > 12)
1927 return -1;
1928 if (Hours == 12)
1929 Hours = 0;
1930 if (Meridian == MERpm)
1931 Hours += 12;
1932 }
1933 return (Hours * 60L + Minutes) * 60L + Seconds;
1934}
1935
1936
1937static time_t
1938Convert(time_t Month, time_t Day, time_t Year,
1939 time_t Hours, time_t Minutes, time_t Seconds,
1940 MERIDIAN Meridian, DSTMODE dst)
1941{
1942 static int DaysNormal[13] = {
1943 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
1944 };
1945 static int DaysLeap[13] = {
1946 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
1947 };
1948 static int LeapYears[] = {
1949 1972, 1976, 1980, 1984, 1988, 1992, 1996,
1950 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
1951 };
1952 register int *yp;
1953 register int *mp;
1954 register time_t Julian;
1955 register int i;
1956 time_t tod;
1957
1958 if (Year < 0)
1959 Year = -Year;
1960 if (Year < 100)
1961 Year += 1900;
1962 if (Year < EPOCH)
1963 Year += 100;
1964 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
1965 if (Year == *yp) {
1966 mp = DaysLeap;
1967 break;
1968 }
1969 if (Year < EPOCH || Year > END_OF_TIME
1970 || Month < 1 || Month > 12
1971 /* NOSTRICT *//* conversion from long may lose accuracy */
1972 || Day < 1 || Day > mp[(int)Month])
1973 return -1;
1974
1975 Julian = Day - 1 + (Year - EPOCH) * 365;
1976 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
1977 if (Year <= *yp)
1978 break;
1979 for (i = 1; i < Month; i++)
1980 Julian += *++mp;
1981 Julian *= SECSPERDAY;
1982 Julian += yyTimezone * 60L;
1983 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
1984 return -1;
1985 Julian += tod;
1986 tod = Julian;
1987 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
1988 Julian -= DST_OFFSET * 60L * 60L;
1989 return Julian;
1990}
1991
1992
1993static time_t
1994DSTcorrect(time_t Start, time_t Future)
1995{
1996 time_t StartDay;
1997 time_t FutureDay;
1998
1999 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2000 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2001 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2002}
2003
2004
2005static time_t
2006RelativeMonth(time_t Start, time_t RelMonth)
2007{
2008 struct tm *tm;
2009 time_t Month;
2010 time_t Year;
2011
2012 tm = localtime(&Start);
2013 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2014 Year = Month / 12;
2015 Month = Month % 12 + 1;
2016 return DSTcorrect(Start,
2017 Convert(Month, (time_t)tm->tm_mday, Year,
2018 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2019 MER24, DSTmaybe));
2020}
2021
2022
2023static int
2024LookupWord(char *buff, register int length)
2025{
2026 register char *p;
2027 register char *q;
2028 register TABLE *tp;
2029 register int c;
2030
2031 p = buff;
2032 c = p[0];
2033
2034 /* See if we have an abbreviation for a month. */
2035 if (length == 3 || (length == 4 && p[3] == '.'))
2036 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2037 q = tp->name;
2038 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2039 yylval.Number = tp->value;
2040 return tp->type;
2041 }
2042 }
2043 else
2044 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2045 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2046 yylval.Number = tp->value;
2047 return tp->type;
2048 }
2049
2050 /* Try for a timezone. */
2051 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2052 if (c == tp->name[0] && p[1] == tp->name[1]
2053 && strcmp(p, tp->name) == 0) {
2054 yylval.Number = tp->value;
2055 return tp->type;
2056 }
2057
2058 /* Try the units table. */
2059 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2060 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2061 yylval.Number = tp->value;
2062 return tp->type;
2063 }
2064
2065 /* Strip off any plural and try the units table again. */
2066 if (--length > 0 && p[length] == 's') {
2067 p[length] = '\0';
2068 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2069 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2070 p[length] = 's';
2071 yylval.Number = tp->value;
2072 return tp->type;
2073 }
2074 p[length] = 's';
2075 }
2076 length++;
2077
2078 /* Drop out any periods. */
2079 for (p = buff, q = (char*)buff; *q; q++)
2080 if (*q != '.')
2081 *p++ = *q;
2082 *p = '\0';
2083
2084 /* Try the meridians. */
2085 if (buff[1] == 'm' && buff[2] == '\0') {
2086 if (buff[0] == 'a') {
2088 return tMERIDIAN;
2089 }
2090 if (buff[0] == 'p') {
2092 return tMERIDIAN;
2093 }
2094 }
2095
2096 /* If we saw any periods, try the timezones again. */
2097 if (p - buff != length) {
2098 c = buff[0];
2099 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2100 if (c == tp->name[0] && p[1] == tp->name[1]
2101 && strcmp(p, tp->name) == 0) {
2102 yylval.Number = tp->value;
2103 return tp->type;
2104 }
2105 }
2106
2107 /* Unknown word -- assume GMT timezone. */
2108 yylval.Number = 0;
2109 return tZONE;
2110}
2111
2112
2113int
2115{
2116 register char c;
2117 register char *p;
2118 char buff[20];
2119 register int sign;
2120 register int i;
2121 register int nesting;
2122
2123 for ( ; ; ) {
2124 /* Get first character after the whitespace. */
2125 for ( ; ; ) {
2126 while (isspace(*yyInput))
2127 yyInput++;
2128 c = *yyInput;
2129
2130 /* Ignore RFC 822 comments, typically time zone names. */
2131 if (c != LPAREN)
2132 break;
2133 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2134 if (c == LPAREN)
2135 nesting++;
2136 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2137 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2138 /* Lexical error: bad comment. */
2139 return '?';
2140 yyInput++;
2141 }
2142
2143 /* A number? */
2144 if (isdigit(c) || c == '-' || c == '+') {
2145 if (c == '-' || c == '+') {
2146 sign = c == '-' ? -1 : 1;
2147 yyInput++;
2148 if (!isdigit(*yyInput))
2149 /* Skip the plus or minus sign. */
2150 continue;
2151 }
2152 else
2153 sign = 0;
2154 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2155 i = 10 * i + c - '0';
2156 yyInput--;
2157 yylval.Number = sign < 0 ? -i : i;
2158 return sign ? tSNUMBER : tUNUMBER;
2159 }
2160
2161 /* A word? */
2162 if (isalpha(c)) {
2163 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2164 if (p < &buff[sizeof buff - 1])
2165 *p++ = isupper(c) ? tolower(c) : c;
2166 *p = '\0';
2167 yyInput--;
2168 return LookupWord(buff, p - buff);
2169 }
2170
2171 return *yyInput++;
2172 }
2173}
2174
2175
2176time_t
2177parsedate(const char *p)
2178{
2179 extern int date_parse(void);
2180 time_t Start;
2181
2182 yyInput = p; /* well, its supposed to be const... */
2183
2184 yyYear = 0;
2185 yyMonth = 0;
2186 yyDay = 0;
2187 yyTimezone = 0;
2189 yyHour = 0;
2190 yyMinutes = 0;
2191 yySeconds = 0;
2192 yyMeridian = MER24;
2193 yyRelSeconds = 0;
2194 yyRelMonth = 0;
2195 yyHaveDate = 0;
2196 yyHaveRel = 0;
2197 yyHaveTime = 0;
2198
2199 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2200 return -1;
2201
2202 if (yyHaveDate || yyHaveTime) {
2205 if (Start < 0)
2206 return -1;
2207 }
2208 else
2209 return -1;
2210
2211 Start += yyRelSeconds;
2212 if (yyRelMonth)
2213 Start += RelativeMonth(Start, yyRelMonth);
2214
2215 /* Have to do *something* with a legitimate -1 so it's distinguishable
2216 * from the error return value. (Alternately could set errno on error.) */
2217 return Start == -1 ? 0 : Start;
2218}
2219
2220
2221#ifdef TEST
2222
2223#if YYDEBUG
2224extern int yydebug;
2225#endif /* YYDEBUG */
2226
2227/* ARGSUSED */
2228int
2229main(int ac, char *av[])
2230{
2231 char buff[128];
2232 time_t d;
2233
2234#if YYDEBUG
2235 yydebug = 1;
2236#endif /* YYDEBUG */
2237
2238 (void)printf("Enter date, or blank line to exit.\n\t> ");
2239 for ( ; ; ) {
2240 (void)printf("\t> ");
2241 (void)fflush(stdout);
2242 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2243 break;
2244#if YYDEBUG
2245 if (strcmp(buff, "yydebug") == 0) {
2246 yydebug = !yydebug;
2247 printf("yydebug = %s\n", yydebug ? "on" : "off");
2248 continue;
2249 }
2250#endif /* YYDEBUG */
2251 d = parsedate(buff, (TIMEINFO *)NULL);
2252 if (d == -1)
2253 (void)printf("Bad format - couldn't convert.\n");
2254 else
2255 (void)printf("%s", ctime(&d));
2256 }
2257
2258 exit(0);
2259 /* NOTREACHED */
2260}
2261#endif /* TEST */
int main(void)
Definition: chkpwd.c:23
#define SECSPERDAY
Definition: parsedate.c:123
#define tDAY
Definition: parsedate.c:240
#define EPOCH
Definition: parsedate.c:119
int yynerrs
Definition: parsedate.c:1021
#define tMERIDIAN
Definition: parsedate.c:242
static int LookupWord(char *buff, register int length)
Definition: parsedate.c:2024
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: parsedate.c:458
#define tMONTH
Definition: parsedate.c:243
#define YYMAXDEPTH
Definition: parsedate.c:988
yytokentype
Definition: parsedate.c:219
@ YYEMPTY
Definition: parsedate.c:220
static TABLE UnitsTable[]
Definition: parsedate.c:1782
static TABLE MonthDayTable[]
Definition: parsedate.c:1758
#define YYSTACK_FREE
Definition: parsedate.c:520
static time_t yyDay
Definition: parsedate.c:170
static const yytype_int8 yytranslate[]
Definition: parsedate.c:634
yysymbol_kind_t
Definition: parsedate.c:275
@ YYSYMBOL_o_merid
Definition: parsedate.c:300
@ YYSYMBOL_YYUNDEF
Definition: parsedate.c:279
@ YYSYMBOL_tMERIDIAN
Definition: parsedate.c:282
@ YYSYMBOL_14_
Definition: parsedate.c:291
@ YYSYMBOL_tZONE
Definition: parsedate.c:288
@ YYSYMBOL_numzone
Definition: parsedate.c:297
@ YYSYMBOL_tSEC_UNIT
Definition: parsedate.c:285
@ YYSYMBOL_YYerror
Definition: parsedate.c:278
@ YYSYMBOL_12_
Definition: parsedate.c:289
@ YYSYMBOL_zone
Definition: parsedate.c:296
@ YYSYMBOL_rel
Definition: parsedate.c:299
@ YYSYMBOL_tMONTH
Definition: parsedate.c:283
@ YYSYMBOL_date
Definition: parsedate.c:298
@ YYSYMBOL_tUNUMBER
Definition: parsedate.c:287
@ YYSYMBOL_spec
Definition: parsedate.c:293
@ YYSYMBOL_item
Definition: parsedate.c:294
@ YYSYMBOL_tSNUMBER
Definition: parsedate.c:286
@ YYSYMBOL_tMONTH_UNIT
Definition: parsedate.c:284
@ YYSYMBOL_YYACCEPT
Definition: parsedate.c:292
@ YYSYMBOL_tDAYZONE
Definition: parsedate.c:281
@ YYSYMBOL_YYEOF
Definition: parsedate.c:277
@ YYSYMBOL_13_
Definition: parsedate.c:290
@ YYSYMBOL_YYEMPTY
Definition: parsedate.c:276
@ YYSYMBOL_time
Definition: parsedate.c:295
@ YYSYMBOL_tDAY
Definition: parsedate.c:280
#define YY_ASSERT(E)
Definition: parsedate.c:478
#define YY_(Msgid)
Definition: parsedate.c:418
#define tMONTH_UNIT
Definition: parsedate.c:244
enum _MERIDIAN MERIDIAN
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: parsedate.c:459
static const yytype_int8 yydefact[]
Definition: parsedate.c:735
#define YYNSTATES
Definition: parsedate.c:619
#define tSNUMBER
Definition: parsedate.c:246
static time_t yySeconds
Definition: parsedate.c:174
#define YY_IGNORE_USELESS_CAST_END
Definition: parsedate.c:474
short yytype_int16
Definition: parsedate.c:341
#define YYUSE(E)
Definition: parsedate.c:441
#define HOUR(x)
Definition: parsedate.c:125
#define YYEOF
Definition: parsedate.c:237
#define YYABORT
Definition: parsedate.c:813
#define YYSTACK_BYTES(N)
Definition: parsedate.c:563
static const yytype_int8 yycheck[]
Definition: parsedate.c:768
#define YY_REDUCE_PRINT(Rule)
Definition: parsedate.c:971
#define YY_CAST(Type, Val)
Definition: parsedate.c:190
#define IS7BIT(x)
Definition: parsedate.c:129
static void yydestruct(const char *yymsg, yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
Definition: parsedate.c:1001
static int yyHaveTime
Definition: parsedate.c:168
#define END_OF_TIME
Definition: parsedate.c:120
YYSTYPE yylval
Definition: parsedate.c:1019
#define tSEC_UNIT
Definition: parsedate.c:245
#define yylex
Definition: parsedate.c:114
#define YYerror
Definition: parsedate.c:238
#define YY_NULLPTR
Definition: parsedate.c:202
#define DST_OFFSET
Definition: parsedate.c:122
#define tDAYZONE
Definition: parsedate.c:241
#define YYUNDEF
Definition: parsedate.c:239
static time_t Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian, DSTMODE dst)
Definition: parsedate.c:1938
static const yytype_int8 yypact[]
Definition: parsedate.c:723
#define tZONE
Definition: parsedate.c:248
#define RPAREN
Definition: parsedate.c:128
static time_t yyTimezone
Definition: parsedate.c:169
#define YYFINAL
Definition: parsedate.c:608
#define YY_ACCESSING_SYMBOL(State)
Definition: parsedate.c:677
static MERIDIAN yyMeridian
Definition: parsedate.c:176
#define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
Definition: parsedate.c:969
static time_t yyRelSeconds
Definition: parsedate.c:178
time_t parsedate(const char *p)
Definition: parsedate.c:2177
#define yyparse
Definition: parsedate.c:113
static time_t ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
Definition: parsedate.c:1917
#define YYNTOKENS
Definition: parsedate.c:613
static DSTMODE yyDSTmode
Definition: parsedate.c:165
unsigned char yytype_uint8
Definition: parsedate.c:350
#define YY_STACK_PRINT(Bottom, Top)
Definition: parsedate.c:970
struct _TABLE TABLE
static int yyHaveDate
Definition: parsedate.c:166
#define YYSIZE_T
Definition: parsedate.c:391
static int yyHaveRel
Definition: parsedate.c:167
#define YY_IGNORE_USELESS_CAST_BEGIN
Definition: parsedate.c:473
static const yytype_int8 yyr2[]
Definition: parsedate.c:798
static const yytype_int8 yytable[]
Definition: parsedate.c:759
#define YYPTRDIFF_T
Definition: parsedate.c:377
static time_t yyMonth
Definition: parsedate.c:173
static time_t yyYear
Definition: parsedate.c:175
_MERIDIAN
Definition: parsedate.c:154
@ MERam
Definition: parsedate.c:155
@ MERpm
Definition: parsedate.c:155
@ MER24
Definition: parsedate.c:155
int yychar
Definition: parsedate.c:1016
#define YYACCEPT
Definition: parsedate.c:812
#define yytable_value_is_error(Yyn)
Definition: parsedate.c:718
int date_parse(void)
Definition: parsedate.c:1031
static TABLE TimezoneTable[]
Definition: parsedate.c:1795
#define YYTRANSLATE(YYX)
Definition: parsedate.c:627
static const yytype_int8 yystos[]
Definition: parsedate.c:779
@ YYENOMEM
Definition: parsedate.c:807
void * malloc(unsigned)
#define YY_ATTRIBUTE_UNUSED
Definition: parsedate.c:435
static const yytype_int8 yypgoto[]
Definition: parsedate.c:745
#define LPAREN
Definition: parsedate.c:127
#define ENDOF(array)
Definition: parsedate.c:132
static const yytype_int8 yyr1[]
Definition: parsedate.c:789
static const char * yyInput
Definition: parsedate.c:164
static time_t yyHour
Definition: parsedate.c:171
static time_t yyRelMonth
Definition: parsedate.c:177
enum yytokentype yytoken_kind_t
Definition: parsedate.c:234
#define YYPOPSTACK(N)
int yy_state_fast_t
Definition: parsedate.c:408
_DSTMODE
Definition: parsedate.c:147
@ DSToff
Definition: parsedate.c:148
@ DSTmaybe
Definition: parsedate.c:148
@ DSTon
Definition: parsedate.c:148
unsigned short yytype_uint16
Definition: parsedate.c:361
static const yytype_int8 yydefgoto[]
Definition: parsedate.c:751
#define YYLAST
Definition: parsedate.c:610
static void date_error(char *)
Definition: parsedate.c:1910
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: parsedate.c:574
#define yypact_value_is_default(Yyn)
Definition: parsedate.c:713
static time_t DSTcorrect(time_t Start, time_t Future)
Definition: parsedate.c:1994
#define YYINITDEPTH
Definition: parsedate.c:977
static time_t RelativeMonth(time_t Start, time_t RelMonth)
Definition: parsedate.c:2006
signed char yytype_int8
Definition: parsedate.c:333
void free(void *)
#define YYERROR
Definition: parsedate.c:814
#define YYSIZEOF(X)
Definition: parsedate.c:401
#define tUNUMBER
Definition: parsedate.c:247
int date_lex(void)
Definition: parsedate.c:2114
#define YYSTACK_ALLOC
Definition: parsedate.c:519
static time_t yyMinutes
Definition: parsedate.c:172
yytype_int8 yy_state_t
Definition: parsedate.c:405
#define YYDPRINTF(Args)
Definition: parsedate.c:968
enum _DSTMODE DSTMODE
#define yyerror
Definition: parsedate.c:115
char * name
Definition: parsedate.c:139
time_t value
Definition: parsedate.c:141
int type
Definition: parsedate.c:140
enum _MERIDIAN Meridian
Definition: parsedate.c:257
time_t Number
Definition: parsedate.c:256
YYSTYPE yyvs_alloc
Definition: parsedate.c:555
yy_state_t yyss_alloc
Definition: parsedate.c:554