2
/* A Bison parser, made from getdate.y
3
by GNU Bison version 1.28 */
5
#define YYBISON 1 /* Identify Bison output. */
12
#define tHOUR_UNIT 262
15
#define tMINUTE_UNIT 265
17
#define tMONTH_UNIT 267
21
#define tYEAR_UNIT 271
27
** Originally written by Steven M. Bellovin <smb@research.att.com> while
28
** at the University of North Carolina at Chapel Hill. Later tweaked by
29
** a couple of people on Usenet. Completely overhauled by Rich $alz
30
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
32
** This code is in the public domain and has no copyright.
46
/* to satisfy gcc -Wundef, we set this to 0 */
50
/* Since the code of getdate.y is not included in the Emacs executable
51
itself, there is no need to #define static in this file. Even if
52
the code were included in the Emacs executable, it probably
53
wouldn't do any harm to #undef it here; this will only cause
54
problems if we try to write to a static variable, which I don't
55
think this code needs to do. */
61
#include <sys/types.h>
62
#include <sys/malloc.h>
71
# include <stdlib.h> /* for `free'; used by Bison 1.27 */
80
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
81
# define IN_CTYPE_DOMAIN(c) 1
83
# define IN_CTYPE_DOMAIN(c) isascii((int)(c))
86
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace ((int)(c)))
87
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha ((int)(c)))
88
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper ((int)(c)))
89
#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit ((int)(c)))
91
/* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
92
- Its arg may be any int or unsigned int; it need not be an unsigned char.
93
- It's guaranteed to evaluate its argument exactly once.
94
- It's typically faster.
95
Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
96
only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
97
it's important to use the locale's definition of `digit' even when the
98
host does not conform to Posix. */
99
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
101
#if defined (STDC_HEADERS) || defined (USG)
105
/* The last #include file should be: */
107
#include "memdebug.h"
110
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
111
# define __attribute__(x)
114
#ifndef ATTRIBUTE_UNUSED
115
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
118
/* Some old versions of bison generate parsers that use bcopy.
119
That loses on systems that don't provide the function, so we have
120
to redefine it here. */
121
#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
122
# define bcopy(from, to, len) memcpy ((to), (from), (len))
125
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
126
as well as gratuitiously global symbol names, so we can have multiple
127
yacc generated parsers in the same program. Note that these are only
128
the variables produced by yacc. If other parser generators (bison,
129
byacc, etc) produce additional global names that conflict at link time,
130
then those parser generators need to be fixed instead of adding those
131
names to this list. */
133
#define yymaxdepth Curl_gd_maxdepth
134
#define yyparse Curl_gd_parse
135
#define yylex Curl_gd_lex
136
#define yyerror Curl_gd_error
137
#define yylval Curl_gd_lval
138
#define yychar Curl_gd_char
139
#define yydebug Curl_gd_debug
140
#define yypact Curl_gd_pact
141
#define yyr1 Curl_gd_r1
142
#define yyr2 Curl_gd_r2
143
#define yydef Curl_gd_def
144
#define yychk Curl_gd_chk
145
#define yypgo Curl_gd_pgo
146
#define yyact Curl_gd_act
147
#define yyexca Curl_gd_exca
148
#define yyerrflag Curl_gd_errflag
149
#define yynerrs Curl_gd_nerrs
150
#define yyps Curl_gd_ps
151
#define yypv Curl_gd_pv
152
#define yys Curl_gd_s
153
#define yy_yys Curl_gd_yys
154
#define yystate Curl_gd_state
155
#define yytmp Curl_gd_tmp
156
#define yyv Curl_gd_v
157
#define yy_yyv Curl_gd_yyv
158
#define yyval Curl_gd_val
159
#define yylloc Curl_gd_lloc
160
#define yyreds Curl_gd_reds /* With YYDEBUG defined */
161
#define yytoks Curl_gd_toks /* With YYDEBUG defined */
162
#define yylhs Curl_gd_yylhs
163
#define yylen Curl_gd_yylen
164
#define yydefred Curl_gd_yydefred
165
#define yydgoto Curl_gd_yydgoto
166
#define yysindex Curl_gd_yysindex
167
#define yyrindex Curl_gd_yyrindex
168
#define yygindex Curl_gd_yygindex
169
#define yytable Curl_gd_yytable
170
#define yycheck Curl_gd_yycheck
173
static int yyerror ();
176
#define HOUR(x) ((x) * 60)
178
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
181
** An entry in the lexical lookup table.
183
typedef struct _TABLE {
191
** Meridian: am, pm, or 24-hour style.
193
typedef enum _MERIDIAN {
197
/* parse results and input string */
198
typedef struct _CONTEXT {
223
/* enable use of extra argument to yyparse and yylex which can be used to pass
224
** in a user defined value (CONTEXT struct in our case)
226
#define YYPARSE_PARAM cookie
227
#define YYLEX_PARAM cookie
228
#define context ((CONTEXT *) cookie)
230
#line 215 "getdate.y"
233
enum _MERIDIAN Meridian;
246
#define YYFLAG -32768
249
#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 32)
251
static const char yytranslate[] = { 0,
252
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
253
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
254
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
255
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
256
2, 2, 2, 20, 2, 2, 21, 2, 2, 2,
257
2, 2, 2, 2, 2, 2, 2, 19, 2, 2,
258
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
259
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
260
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
261
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
262
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
263
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
264
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
265
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
266
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
267
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
268
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
269
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
270
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
271
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
272
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
273
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
274
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
275
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
276
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
277
2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
278
7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
283
static const short yyprhs[] = { 0,
284
0, 1, 4, 6, 8, 10, 12, 14, 16, 19,
285
24, 29, 36, 43, 45, 47, 50, 52, 55, 58,
286
62, 68, 72, 76, 79, 84, 87, 91, 94, 96,
287
99, 102, 104, 107, 110, 112, 115, 118, 120, 123,
288
126, 128, 131, 134, 136, 139, 142, 144, 146, 147
291
static const short yyrhs[] = { -1,
292
22, 23, 0, 24, 0, 25, 0, 27, 0, 26,
293
0, 28, 0, 30, 0, 16, 10, 0, 16, 19,
294
16, 31, 0, 16, 19, 16, 15, 0, 16, 19,
295
16, 19, 16, 31, 0, 16, 19, 16, 19, 16,
296
15, 0, 18, 0, 6, 0, 18, 7, 0, 4,
297
0, 4, 20, 0, 16, 4, 0, 16, 21, 16,
298
0, 16, 21, 16, 21, 16, 0, 16, 15, 15,
299
0, 16, 12, 15, 0, 12, 16, 0, 12, 16,
300
20, 16, 0, 16, 12, 0, 16, 12, 16, 0,
301
29, 3, 0, 29, 0, 16, 17, 0, 15, 17,
302
0, 17, 0, 16, 13, 0, 15, 13, 0, 13,
303
0, 16, 5, 0, 15, 5, 0, 5, 0, 16,
304
8, 0, 15, 8, 0, 8, 0, 16, 11, 0,
305
15, 11, 0, 11, 0, 16, 14, 0, 15, 14,
306
0, 14, 0, 16, 0, 0, 10, 0
312
static const short yyrline[] = { 0,
313
231, 232, 235, 238, 241, 244, 247, 250, 253, 259,
314
265, 274, 280, 292, 295, 298, 304, 308, 312, 318,
315
322, 340, 346, 352, 356, 361, 365, 372, 380, 383,
316
386, 389, 392, 395, 398, 401, 404, 407, 410, 413,
317
416, 419, 422, 425, 428, 431, 434, 439, 473, 477
322
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
324
static const char * const yytname[] = { "$","error","$undefined.","tAGO","tDAY",
325
"tDAY_UNIT","tDAYZONE","tDST","tHOUR_UNIT","tID","tMERIDIAN","tMINUTE_UNIT",
326
"tMONTH","tMONTH_UNIT","tSEC_UNIT","tSNUMBER","tUNUMBER","tYEAR_UNIT","tZONE",
327
"':'","','","'/'","spec","item","time","zone","day","date","rel","relunit","number",
332
static const short yyr1[] = { 0,
333
22, 22, 23, 23, 23, 23, 23, 23, 24, 24,
334
24, 24, 24, 25, 25, 25, 26, 26, 26, 27,
335
27, 27, 27, 27, 27, 27, 27, 28, 28, 29,
336
29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
337
29, 29, 29, 29, 29, 29, 29, 30, 31, 31
340
static const short yyr2[] = { 0,
341
0, 2, 1, 1, 1, 1, 1, 1, 2, 4,
342
4, 6, 6, 1, 1, 2, 1, 2, 2, 3,
343
5, 3, 3, 2, 4, 2, 3, 2, 1, 2,
344
2, 1, 2, 2, 1, 2, 2, 1, 2, 2,
345
1, 2, 2, 1, 2, 2, 1, 1, 0, 1
348
static const short yydefact[] = { 1,
349
0, 17, 38, 15, 41, 44, 0, 35, 47, 0,
350
48, 32, 14, 2, 3, 4, 6, 5, 7, 29,
351
8, 18, 24, 37, 40, 43, 34, 46, 31, 19,
352
36, 39, 9, 42, 26, 33, 45, 0, 30, 0,
353
0, 16, 28, 0, 23, 27, 22, 49, 20, 25,
354
50, 11, 0, 10, 0, 49, 21, 13, 12, 0,
358
static const short yydefgoto[] = { 1,
359
14, 15, 16, 17, 18, 19, 20, 21, 54
362
static const short yypact[] = {-32768,
363
0, -19,-32768,-32768,-32768,-32768, -13,-32768,-32768, 30,
364
15,-32768, 14,-32768,-32768,-32768,-32768,-32768,-32768, 19,
365
-32768,-32768, 4,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
366
-32768,-32768,-32768,-32768, -6,-32768,-32768, 16,-32768, 17,
367
23,-32768,-32768, 24,-32768,-32768,-32768, 27, 28,-32768,
368
-32768,-32768, 29,-32768, 32, -8,-32768,-32768,-32768, 50,
372
static const short yypgoto[] = {-32768,
373
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -5
380
static const short yytable[] = { 60,
381
22, 51, 23, 2, 3, 4, 58, 5, 45, 46,
382
6, 7, 8, 9, 10, 11, 12, 13, 30, 31,
383
42, 43, 32, 44, 33, 34, 35, 36, 37, 38,
384
47, 39, 48, 40, 24, 41, 51, 25, 49, 50,
385
26, 52, 27, 28, 56, 53, 29, 57, 55, 61,
389
static const short yycheck[] = { 0,
390
20, 10, 16, 4, 5, 6, 15, 8, 15, 16,
391
11, 12, 13, 14, 15, 16, 17, 18, 4, 5,
392
7, 3, 8, 20, 10, 11, 12, 13, 14, 15,
393
15, 17, 16, 19, 5, 21, 10, 8, 16, 16,
394
11, 15, 13, 14, 16, 19, 17, 16, 21, 0,
399
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
400
#line 3 "/usr/local/share/bison.simple"
401
/* This file comes from bison-1.28. */
403
/* Skeleton output parser for bison,
404
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
406
This program is free software; you can redistribute it and/or modify
407
it under the terms of the GNU General Public License as published by
408
the Free Software Foundation; either version 2, or (at your option)
411
This program is distributed in the hope that it will be useful,
412
but WITHOUT ANY WARRANTY; without even the implied warranty of
413
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
414
GNU General Public License for more details.
416
You should have received a copy of the GNU General Public License
417
along with this program; if not, write to the Free Software
418
Foundation, Inc., 59 Temple Place - Suite 330,
419
Boston, MA 02111-1307, USA. */
421
/* As a special exception, when this file is copied by Bison into a
422
Bison output file, you may use that output file without restriction.
423
This special exception was added by the Free Software Foundation
424
in version 1.24 of Bison. */
426
/* This is the parser code that is written into each bison parser
427
when the %semantic_parser declaration is not specified in the grammar.
428
It was written by Richard Stallman by simplifying the hairy parser
429
used when %semantic_parser is specified. */
431
#ifndef YYSTACK_USE_ALLOCA
433
#define YYSTACK_USE_ALLOCA
434
#else /* alloca not defined */
436
#define YYSTACK_USE_ALLOCA
437
#define alloca __builtin_alloca
438
#else /* not GNU C. */
439
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
440
#define YYSTACK_USE_ALLOCA
442
#else /* not sparc */
443
/* We think this test detects Watcom and Microsoft C. */
444
/* This used to test MSDOS, but that is a bad idea
445
since that symbol is in the user namespace. */
446
#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
447
#if 0 /* No need for malloc.h, which pollutes the namespace;
448
instead, just don't use alloca. */
451
#else /* not MSDOS, or __TURBOC__ */
453
/* I don't know what this was needed for, but it pollutes the namespace.
454
So I turned it off. rms, 2 May 1997. */
455
/* #include <malloc.h> */
457
#define YYSTACK_USE_ALLOCA
458
#else /* not MSDOS, or __TURBOC__, or _AIX */
460
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
461
and on HPUX 10. Eventually we can turn this on. */
462
#define YYSTACK_USE_ALLOCA
463
#define alloca __builtin_alloca
466
#endif /* not _AIX */
467
#endif /* not MSDOS, or __TURBOC__ */
468
#endif /* not sparc */
469
#endif /* not GNU C */
470
#endif /* alloca not defined */
471
#endif /* YYSTACK_USE_ALLOCA not defined */
473
#ifdef YYSTACK_USE_ALLOCA
474
#define YYSTACK_ALLOC alloca
476
#define YYSTACK_ALLOC malloc
479
/* Note: there must be only one dollar sign in this file.
480
It is replaced by the list of actions, each action
481
as one case of the switch. */
483
#define yyerrok (yyerrstatus = 0)
484
#define yyclearin (yychar = YYEMPTY)
487
#define YYACCEPT goto yyacceptlab
488
#define YYABORT goto yyabortlab
489
#define YYERROR goto yyerrlab1
490
/* Like YYERROR except do call yyerror.
491
This remains here temporarily to ease the
492
transition to the new meaning of YYERROR, for GCC.
493
Once GCC version 2 has supplanted version 1, this can go. */
494
#define YYFAIL goto yyerrlab
495
#define YYRECOVERING() (!!yyerrstatus)
496
#define YYBACKUP(token, value) \
498
if (yychar == YYEMPTY && yylen == 1) \
499
{ yychar = (token), yylval = (value); \
500
yychar1 = YYTRANSLATE (yychar); \
505
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
509
#define YYERRCODE 256
512
#define YYLEX yylex()
518
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
520
#define YYLEX yylex(&yylval, &yylloc)
522
#else /* not YYLSP_NEEDED */
524
#define YYLEX yylex(&yylval, YYLEX_PARAM)
526
#define YYLEX yylex(&yylval)
528
#endif /* not YYLSP_NEEDED */
531
/* If nonreentrant, generate the variables here */
535
int yychar; /* the lookahead symbol */
536
YYSTYPE yylval; /* the semantic value of the */
537
/* lookahead symbol */
540
YYLTYPE yylloc; /* location data for the lookahead */
544
int yynerrs; /* number of parse errors so far */
545
#endif /* not YYPURE */
548
int yydebug; /* nonzero means print parse trace */
549
/* Since this is uninitialized, it does not stop multiple parsers
553
/* YYINITDEPTH indicates the initial size of the parser's stacks */
556
#define YYINITDEPTH 200
559
/* YYMAXDEPTH is the maximum size the stacks can grow to
560
(effective only if the built-in stack extension method is used). */
567
#define YYMAXDEPTH 10000
570
/* Define __yy_memcpy. Note that the size argument
571
should be passed with type unsigned int, because that is what the non-GCC
572
definitions require. With GCC, __builtin_memcpy takes an arg
573
of type size_t, but it can handle unsigned int. */
575
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
576
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
577
#else /* not GNU C or C++ */
580
/* This is the most reliable way to avoid incompatibilities
581
in available built-in functions on various systems. */
583
__yy_memcpy (to, from, count)
588
register char *f = from;
589
register char *t = to;
590
register int i = count;
596
#else /* __cplusplus */
598
/* This is the most reliable way to avoid incompatibilities
599
in available built-in functions on various systems. */
601
__yy_memcpy (char *to, char *from, unsigned int count)
603
register char *t = to;
604
register char *f = from;
605
register int i = count;
614
#line 217 "/usr/local/share/bison.simple"
616
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
617
into yyparse. The argument should have type void *.
618
It should actually point to an object.
619
Grammar actions can access the variable by casting it
620
to the proper pointer type. */
624
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
625
#define YYPARSE_PARAM_DECL
626
#else /* not __cplusplus */
627
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
628
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
629
#endif /* not __cplusplus */
630
#else /* not YYPARSE_PARAM */
631
#define YYPARSE_PARAM_ARG
632
#define YYPARSE_PARAM_DECL
633
#endif /* not YYPARSE_PARAM */
635
/* Prevent warning if -Wstrict-prototypes. */
638
int yyparse (void *);
645
yyparse(YYPARSE_PARAM_ARG)
648
register int yystate;
650
register short *yyssp;
651
register YYSTYPE *yyvsp;
652
int yyerrstatus; /* number of tokens to shift before error messages enabled */
653
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
655
short yyssa[YYINITDEPTH]; /* the state stack */
656
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
658
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
659
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
662
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
663
YYLTYPE *yyls = yylsa;
666
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
668
#define YYPOPSTACK (yyvsp--, yyssp--)
671
int yystacksize = YYINITDEPTH;
672
int yyfree_stacks = 0;
683
YYSTYPE yyval; /* the variable used to return */
684
/* semantic values from the action */
691
fprintf(stderr, "Starting parse\n");
700
yychar = YYEMPTY; /* Cause a token to be read. */
702
/* Initialize stack pointers.
703
Waste one element of value and location stack
704
so that they stay on the same level as the state stack.
705
The wasted elements are never initialized. */
713
/* Push a new state, which is found in yystate . */
714
/* In all cases, when you get here, the value and location stacks
715
have just been pushed. so pushing a state here evens the stacks. */
718
*++yyssp = (short)yystate;
720
if (yyssp >= yyss + yystacksize - 1)
722
/* Give user a chance to reallocate the stack */
723
/* Use copies of these so that the &'s don't force the real ones into memory. */
724
YYSTYPE *yyvs1 = yyvs;
727
YYLTYPE *yyls1 = yyls;
730
/* Get the current used size of the three stacks, in elements. */
731
int size = (int)(yyssp - yyss + 1);
734
/* Each stack pointer address is followed by the size of
735
the data in use in that stack, in bytes. */
737
/* This used to be a conditional around just the two extra args,
738
but that might be undefined if yyoverflow is a macro. */
739
yyoverflow("parser stack overflow",
740
&yyss1, size * sizeof (*yyssp),
741
&yyvs1, size * sizeof (*yyvsp),
742
&yyls1, size * sizeof (*yylsp),
745
yyoverflow("parser stack overflow",
746
&yyss1, size * sizeof (*yyssp),
747
&yyvs1, size * sizeof (*yyvsp),
751
yyss = yyss1; yyvs = yyvs1;
755
#else /* no yyoverflow */
756
/* Extend the stack our own way. */
757
if (yystacksize >= YYMAXDEPTH)
759
yyerror("parser stack overflow");
771
if (yystacksize > YYMAXDEPTH)
772
yystacksize = YYMAXDEPTH;
773
#ifndef YYSTACK_USE_ALLOCA
776
yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
777
__yy_memcpy ((char *)yyss, (char *)yyss1,
778
size * (unsigned int) sizeof (*yyssp));
779
yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
780
__yy_memcpy ((char *)yyvs, (char *)yyvs1,
781
size * (unsigned int) sizeof (*yyvsp));
783
yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
784
__yy_memcpy ((char *)yyls, (char *)yyls1,
785
size * (unsigned int) sizeof (*yylsp));
787
#endif /* no yyoverflow */
789
yyssp = yyss + size - 1;
790
yyvsp = yyvs + size - 1;
792
yylsp = yyls + size - 1;
797
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
800
if (yyssp >= yyss + yystacksize - 1)
806
fprintf(stderr, "Entering state %d\n", yystate);
812
/* Do appropriate processing given the current state. */
813
/* Read a lookahead token if we need one and don't already have one. */
816
/* First try to decide what to do without reference to lookahead token. */
818
yyn = yypact[yystate];
822
/* Not known => get a lookahead token if don't already have one. */
824
/* yychar is either YYEMPTY or YYEOF
825
or a valid token in external form. */
827
if (yychar == YYEMPTY)
831
fprintf(stderr, "Reading a token: ");
836
/* Convert token to internal form (in yychar1) for indexing tables with */
838
if (yychar <= 0) /* This means end of input. */
841
yychar = YYEOF; /* Don't call YYLEX any more */
845
fprintf(stderr, "Now at end of input.\n");
850
yychar1 = YYTRANSLATE(yychar);
855
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
856
/* Give the individual parser a way to print the precise meaning
857
of a token, for further debugging info. */
859
YYPRINT (stderr, yychar, yylval);
861
fprintf (stderr, ")\n");
867
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
872
/* yyn is what to do for this token type in this state.
873
Negative => reduce, -yyn is rule number.
874
Positive => shift, yyn is new state.
875
New state is final state => don't bother to shift,
877
0, or most negative number => error. */
892
/* Shift the lookahead token. */
896
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
899
/* Discard the token being shifted unless it is eof. */
908
/* count tokens shifted since error; after three, turn off error status. */
909
if (yyerrstatus) yyerrstatus--;
914
/* Do the default action for the current state. */
917
yyn = yydefact[yystate];
921
/* Do a reduction. yyn is the number of a rule to reduce with. */
925
yyval = yyvsp[1-yylen]; /* implement default value of the action */
932
fprintf (stderr, "Reducing via rule %d (line %d), ",
935
/* Print the symbols being reduced, and their result. */
936
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
937
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
938
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
946
#line 235 "getdate.y"
948
context->yyHaveTime++;
952
#line 238 "getdate.y"
954
context->yyHaveZone++;
958
#line 241 "getdate.y"
960
context->yyHaveDate++;
964
#line 244 "getdate.y"
966
context->yyHaveDay++;
970
#line 247 "getdate.y"
972
context->yyHaveRel++;
976
#line 253 "getdate.y"
978
context->yyHour = yyvsp[-1].Number;
979
context->yyMinutes = 0;
980
context->yySeconds = 0;
981
context->yyMeridian = yyvsp[0].Meridian;
985
#line 259 "getdate.y"
987
context->yyHour = yyvsp[-3].Number;
988
context->yyMinutes = yyvsp[-1].Number;
989
context->yySeconds = 0;
990
context->yyMeridian = yyvsp[0].Meridian;
994
#line 265 "getdate.y"
996
context->yyHour = yyvsp[-3].Number;
997
context->yyMinutes = yyvsp[-1].Number;
998
context->yyMeridian = MER24;
999
context->yyHaveZone++;
1000
context->yyTimezone = (yyvsp[0].Number < 0
1001
? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
1002
: - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
1006
#line 274 "getdate.y"
1008
context->yyHour = yyvsp[-5].Number;
1009
context->yyMinutes = yyvsp[-3].Number;
1010
context->yySeconds = yyvsp[-1].Number;
1011
context->yyMeridian = yyvsp[0].Meridian;
1015
#line 280 "getdate.y"
1017
context->yyHour = yyvsp[-5].Number;
1018
context->yyMinutes = yyvsp[-3].Number;
1019
context->yySeconds = yyvsp[-1].Number;
1020
context->yyMeridian = MER24;
1021
context->yyHaveZone++;
1022
context->yyTimezone = (yyvsp[0].Number < 0
1023
? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
1024
: - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
1028
#line 292 "getdate.y"
1030
context->yyTimezone = yyvsp[0].Number;
1034
#line 295 "getdate.y"
1036
context->yyTimezone = yyvsp[0].Number - 60;
1040
#line 299 "getdate.y"
1042
context->yyTimezone = yyvsp[-1].Number - 60;
1046
#line 304 "getdate.y"
1048
context->yyDayOrdinal = 1;
1049
context->yyDayNumber = yyvsp[0].Number;
1053
#line 308 "getdate.y"
1055
context->yyDayOrdinal = 1;
1056
context->yyDayNumber = yyvsp[-1].Number;
1060
#line 312 "getdate.y"
1062
context->yyDayOrdinal = yyvsp[-1].Number;
1063
context->yyDayNumber = yyvsp[0].Number;
1067
#line 318 "getdate.y"
1069
context->yyMonth = yyvsp[-2].Number;
1070
context->yyDay = yyvsp[0].Number;
1074
#line 322 "getdate.y"
1076
/* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
1077
The goal in recognizing YYYY/MM/DD is solely to support legacy
1078
machine-generated dates like those in an RCS log listing. If
1079
you want portability, use the ISO 8601 format. */
1080
if (yyvsp[-4].Number >= 1000)
1082
context->yyYear = yyvsp[-4].Number;
1083
context->yyMonth = yyvsp[-2].Number;
1084
context->yyDay = yyvsp[0].Number;
1088
context->yyMonth = yyvsp[-4].Number;
1089
context->yyDay = yyvsp[-2].Number;
1090
context->yyYear = yyvsp[0].Number;
1095
#line 340 "getdate.y"
1097
/* ISO 8601 format. yyyy-mm-dd. */
1098
context->yyYear = yyvsp[-2].Number;
1099
context->yyMonth = -yyvsp[-1].Number;
1100
context->yyDay = -yyvsp[0].Number;
1104
#line 346 "getdate.y"
1106
/* e.g. 17-JUN-1992. */
1107
context->yyDay = yyvsp[-2].Number;
1108
context->yyMonth = yyvsp[-1].Number;
1109
context->yyYear = -yyvsp[0].Number;
1113
#line 352 "getdate.y"
1115
context->yyMonth = yyvsp[-1].Number;
1116
context->yyDay = yyvsp[0].Number;
1120
#line 356 "getdate.y"
1122
context->yyMonth = yyvsp[-3].Number;
1123
context->yyDay = yyvsp[-2].Number;
1124
context->yyYear = yyvsp[0].Number;
1128
#line 361 "getdate.y"
1130
context->yyMonth = yyvsp[0].Number;
1131
context->yyDay = yyvsp[-1].Number;
1135
#line 365 "getdate.y"
1137
context->yyMonth = yyvsp[-1].Number;
1138
context->yyDay = yyvsp[-2].Number;
1139
context->yyYear = yyvsp[0].Number;
1143
#line 372 "getdate.y"
1145
context->yyRelSeconds = -context->yyRelSeconds;
1146
context->yyRelMinutes = -context->yyRelMinutes;
1147
context->yyRelHour = -context->yyRelHour;
1148
context->yyRelDay = -context->yyRelDay;
1149
context->yyRelMonth = -context->yyRelMonth;
1150
context->yyRelYear = -context->yyRelYear;
1154
#line 383 "getdate.y"
1156
context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
1160
#line 386 "getdate.y"
1162
context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
1166
#line 389 "getdate.y"
1168
context->yyRelYear += yyvsp[0].Number;
1172
#line 392 "getdate.y"
1174
context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
1178
#line 395 "getdate.y"
1180
context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
1184
#line 398 "getdate.y"
1186
context->yyRelMonth += yyvsp[0].Number;
1190
#line 401 "getdate.y"
1192
context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
1196
#line 404 "getdate.y"
1198
context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
1202
#line 407 "getdate.y"
1204
context->yyRelDay += yyvsp[0].Number;
1208
#line 410 "getdate.y"
1210
context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
1214
#line 413 "getdate.y"
1216
context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
1220
#line 416 "getdate.y"
1222
context->yyRelHour += yyvsp[0].Number;
1226
#line 419 "getdate.y"
1228
context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
1232
#line 422 "getdate.y"
1234
context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
1238
#line 425 "getdate.y"
1240
context->yyRelMinutes += yyvsp[0].Number;
1244
#line 428 "getdate.y"
1246
context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
1250
#line 431 "getdate.y"
1252
context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
1256
#line 434 "getdate.y"
1258
context->yyRelSeconds += yyvsp[0].Number;
1262
#line 440 "getdate.y"
1264
if (context->yyHaveTime && context->yyHaveDate &&
1265
!context->yyHaveRel)
1266
context->yyYear = yyvsp[0].Number;
1269
if (yyvsp[0].Number>10000)
1271
context->yyHaveDate++;
1272
context->yyDay= (yyvsp[0].Number)%100;
1273
context->yyMonth= (yyvsp[0].Number/100)%100;
1274
context->yyYear = yyvsp[0].Number/10000;
1278
context->yyHaveTime++;
1279
if (yyvsp[0].Number < 100)
1281
context->yyHour = yyvsp[0].Number;
1282
context->yyMinutes = 0;
1286
context->yyHour = yyvsp[0].Number / 100;
1287
context->yyMinutes = yyvsp[0].Number % 100;
1289
context->yySeconds = 0;
1290
context->yyMeridian = MER24;
1296
#line 474 "getdate.y"
1298
yyval.Meridian = MER24;
1302
#line 478 "getdate.y"
1304
yyval.Meridian = yyvsp[0].Meridian;
1308
/* the action file gets copied in in place of this dollarsign */
1309
#line 543 "/usr/local/share/bison.simple"
1320
short *ssp1 = yyss - 1;
1321
fprintf (stderr, "state stack now");
1322
while (ssp1 != yyssp)
1323
fprintf (stderr, " %d", *++ssp1);
1324
fprintf (stderr, "\n");
1334
yylsp->first_line = yylloc.first_line;
1335
yylsp->first_column = yylloc.first_column;
1336
yylsp->last_line = (yylsp-1)->last_line;
1337
yylsp->last_column = (yylsp-1)->last_column;
1342
yylsp->last_line = (yylsp+yylen-1)->last_line;
1343
yylsp->last_column = (yylsp+yylen-1)->last_column;
1347
/* Now "shift" the result of the reduction.
1348
Determine what state that goes to,
1349
based on the state we popped back to
1350
and the rule number reduced by. */
1354
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1355
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1356
yystate = yytable[yystate];
1358
yystate = yydefgoto[yyn - YYNTBASE];
1362
yyerrlab: /* here on detecting error */
1365
/* If not already recovering from an error, report this error. */
1369
#ifdef YYERROR_VERBOSE
1370
yyn = yypact[yystate];
1372
if (yyn > YYFLAG && yyn < YYLAST)
1379
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1380
for (x = (yyn < 0 ? -yyn : 0);
1381
x < (sizeof(yytname) / sizeof(char *)); x++)
1382
if (yycheck[x + yyn] == x)
1383
size += strlen(yytname[x]) + 15, count++;
1384
msg = (char *) malloc(size + 15);
1387
strcpy(msg, "parse error");
1392
for (x = (yyn < 0 ? -yyn : 0);
1393
x < (sizeof(yytname) / sizeof(char *)); x++)
1394
if (yycheck[x + yyn] == x)
1396
strcat(msg, count == 0 ? ", expecting `" : " or `");
1397
strcat(msg, yytname[x]);
1406
yyerror ("parse error; also virtual memory exceeded");
1409
#endif /* YYERROR_VERBOSE */
1410
yyerror("parse error");
1414
yyerrlab1: /* here on error raised explicitly by an action */
1416
if (yyerrstatus == 3)
1418
/* if just tried and failed to reuse lookahead token after an error, discard it. */
1420
/* return failure if at end of input */
1421
if (yychar == YYEOF)
1426
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1432
/* Else will try to reuse lookahead token
1433
after shifting the error token. */
1435
yyerrstatus = 3; /* Each real token shifted decrements this */
1439
yyerrdefault: /* current state does not do anything special for the error token. */
1442
/* This is wrong; only states that explicitly want error tokens
1443
should shift them. */
1444
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1445
if (yyn) goto yydefault;
1448
yyerrpop: /* pop the current state because it cannot handle the error token */
1450
if (yyssp == yyss) YYABORT;
1460
short *ssp1 = yyss - 1;
1461
fprintf (stderr, "Error: state stack now");
1462
while (ssp1 != yyssp)
1463
fprintf (stderr, " %d", *++ssp1);
1464
fprintf (stderr, "\n");
1470
yyn = yypact[yystate];
1475
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1494
fprintf(stderr, "Shifting error token, ");
1506
/* YYACCEPT comes here. */
1518
/* YYABORT comes here. */
1529
#line 483 "getdate.y"
1532
/* Include this file down here because bison inserts code above which
1533
may define-away `const'. We want the prototype for get_date to have
1534
the same signature as the function definition does. */
1535
#include "getdate.h"
1537
#ifndef WIN32 /* the windows dudes don't need these, does anyone really? */
1538
extern struct tm *gmtime (const time_t *timer);
1539
extern struct tm *localtime (const time_t *timer);
1540
extern time_t mktime (struct tm *timeptr);
1543
/* Month and day table. */
1544
static TABLE const MonthDayTable[] = {
1545
{ "january", tMONTH, 1 },
1546
{ "february", tMONTH, 2 },
1547
{ "march", tMONTH, 3 },
1548
{ "april", tMONTH, 4 },
1549
{ "may", tMONTH, 5 },
1550
{ "june", tMONTH, 6 },
1551
{ "july", tMONTH, 7 },
1552
{ "august", tMONTH, 8 },
1553
{ "september", tMONTH, 9 },
1554
{ "sept", tMONTH, 9 },
1555
{ "october", tMONTH, 10 },
1556
{ "november", tMONTH, 11 },
1557
{ "december", tMONTH, 12 },
1558
{ "sunday", tDAY, 0 },
1559
{ "monday", tDAY, 1 },
1560
{ "tuesday", tDAY, 2 },
1561
{ "tues", tDAY, 2 },
1562
{ "wednesday", tDAY, 3 },
1563
{ "wednes", tDAY, 3 },
1564
{ "thursday", tDAY, 4 },
1565
{ "thur", tDAY, 4 },
1566
{ "thurs", tDAY, 4 },
1567
{ "friday", tDAY, 5 },
1568
{ "saturday", tDAY, 6 },
1572
/* Time units table. */
1573
static TABLE const UnitsTable[] = {
1574
{ "year", tYEAR_UNIT, 1 },
1575
{ "month", tMONTH_UNIT, 1 },
1576
{ "fortnight", tDAY_UNIT, 14 },
1577
{ "week", tDAY_UNIT, 7 },
1578
{ "day", tDAY_UNIT, 1 },
1579
{ "hour", tHOUR_UNIT, 1 },
1580
{ "minute", tMINUTE_UNIT, 1 },
1581
{ "min", tMINUTE_UNIT, 1 },
1582
{ "second", tSEC_UNIT, 1 },
1583
{ "sec", tSEC_UNIT, 1 },
1587
/* Assorted relative-time words. */
1588
static TABLE const OtherTable[] = {
1589
{ "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
1590
{ "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
1591
{ "today", tMINUTE_UNIT, 0 },
1592
{ "now", tMINUTE_UNIT, 0 },
1593
{ "last", tUNUMBER, -1 },
1594
{ "this", tMINUTE_UNIT, 0 },
1595
{ "next", tUNUMBER, 1 },
1596
{ "first", tUNUMBER, 1 },
1597
/* { "second", tUNUMBER, 2 }, */
1598
{ "third", tUNUMBER, 3 },
1599
{ "fourth", tUNUMBER, 4 },
1600
{ "fifth", tUNUMBER, 5 },
1601
{ "sixth", tUNUMBER, 6 },
1602
{ "seventh", tUNUMBER, 7 },
1603
{ "eighth", tUNUMBER, 8 },
1604
{ "ninth", tUNUMBER, 9 },
1605
{ "tenth", tUNUMBER, 10 },
1606
{ "eleventh", tUNUMBER, 11 },
1607
{ "twelfth", tUNUMBER, 12 },
1612
/* The timezone table. */
1613
static TABLE const TimezoneTable[] = {
1614
{ "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */
1615
{ "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
1616
{ "utc", tZONE, HOUR ( 0) },
1617
{ "wet", tZONE, HOUR ( 0) }, /* Western European */
1618
{ "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
1619
{ "wat", tZONE, HOUR ( 1) }, /* West Africa */
1620
{ "at", tZONE, HOUR ( 2) }, /* Azores */
1622
/* For completeness. BST is also British Summer, and GST is
1623
* also Guam Standard. */
1624
{ "bst", tZONE, HOUR ( 3) }, /* Brazil Standard */
1625
{ "gst", tZONE, HOUR ( 3) }, /* Greenland Standard */
1628
{ "nft", tZONE, HOUR (3.5) }, /* Newfoundland */
1629
{ "nst", tZONE, HOUR (3.5) }, /* Newfoundland Standard */
1630
{ "ndt", tDAYZONE, HOUR (3.5) }, /* Newfoundland Daylight */
1632
{ "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
1633
{ "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
1634
{ "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
1635
{ "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
1636
{ "cst", tZONE, HOUR ( 6) }, /* Central Standard */
1637
{ "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */
1638
{ "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */
1639
{ "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
1640
{ "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */
1641
{ "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
1642
{ "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */
1643
{ "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
1644
{ "hst", tZONE, HOUR (10) }, /* Hawaii Standard */
1645
{ "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
1646
{ "cat", tZONE, HOUR (10) }, /* Central Alaska */
1647
{ "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
1648
{ "nt", tZONE, HOUR (11) }, /* Nome */
1649
{ "idlw", tZONE, HOUR (12) }, /* International Date Line West */
1650
{ "cet", tZONE, -HOUR (1) }, /* Central European */
1651
{ "met", tZONE, -HOUR (1) }, /* Middle European */
1652
{ "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */
1653
{ "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
1654
{ "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
1655
{ "swt", tZONE, -HOUR (1) }, /* Swedish Winter */
1656
{ "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */
1657
{ "fwt", tZONE, -HOUR (1) }, /* French Winter */
1658
{ "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
1659
{ "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
1660
{ "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
1662
{ "it", tZONE, -HOUR (3.5) },/* Iran */
1664
{ "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
1665
{ "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
1667
{ "ist", tZONE, -HOUR (5.5) },/* Indian Standard */
1669
{ "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
1671
/* For completeness. NST is also Newfoundland Standard, and SST is
1672
* also Swedish Summer. */
1673
{ "nst", tZONE, -HOUR (6.5) },/* North Sumatra */
1674
{ "sst", tZONE, -HOUR (7) }, /* South Sumatra, USSR Zone 6 */
1676
{ "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
1677
{ "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
1679
{ "jt", tZONE, -HOUR (7.5) },/* Java (3pm in Cronusland!) */
1681
{ "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
1682
{ "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
1684
{ "cast", tZONE, -HOUR (9.5) },/* Central Australian Standard */
1685
{ "cadt", tDAYZONE, -HOUR (9.5) },/* Central Australian Daylight */
1687
{ "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
1688
{ "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
1689
{ "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
1690
{ "nzt", tZONE, -HOUR (12) }, /* New Zealand */
1691
{ "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
1692
{ "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
1693
{ "idle", tZONE, -HOUR (12) }, /* International Date Line East */
1697
/* Military timezone table. */
1698
static TABLE const MilitaryTable[] = {
1699
{ "a", tZONE, HOUR ( 1) },
1700
{ "b", tZONE, HOUR ( 2) },
1701
{ "c", tZONE, HOUR ( 3) },
1702
{ "d", tZONE, HOUR ( 4) },
1703
{ "e", tZONE, HOUR ( 5) },
1704
{ "f", tZONE, HOUR ( 6) },
1705
{ "g", tZONE, HOUR ( 7) },
1706
{ "h", tZONE, HOUR ( 8) },
1707
{ "i", tZONE, HOUR ( 9) },
1708
{ "k", tZONE, HOUR ( 10) },
1709
{ "l", tZONE, HOUR ( 11) },
1710
{ "m", tZONE, HOUR ( 12) },
1711
{ "n", tZONE, HOUR (- 1) },
1712
{ "o", tZONE, HOUR (- 2) },
1713
{ "p", tZONE, HOUR (- 3) },
1714
{ "q", tZONE, HOUR (- 4) },
1715
{ "r", tZONE, HOUR (- 5) },
1716
{ "s", tZONE, HOUR (- 6) },
1717
{ "t", tZONE, HOUR (- 7) },
1718
{ "u", tZONE, HOUR (- 8) },
1719
{ "v", tZONE, HOUR (- 9) },
1720
{ "w", tZONE, HOUR (-10) },
1721
{ "x", tZONE, HOUR (-11) },
1722
{ "y", tZONE, HOUR (-12) },
1723
{ "z", tZONE, HOUR ( 0) },
1733
char *s ATTRIBUTE_UNUSED;
1740
ToHour (Hours, Meridian)
1747
if (Hours < 0 || Hours > 23)
1751
if (Hours < 1 || Hours > 12)
1757
if (Hours < 1 || Hours > 12)
1775
/* XPG4 suggests that years 00-68 map to 2000-2068, and
1776
years 69-99 map to 1969-1999. */
1779
else if (Year < 100)
1786
LookupWord (yylval, buff)
1792
register const TABLE *tp;
1796
/* Make it lowercase. */
1797
for (p = buff; *p; p++)
1798
if (ISUPPER ((unsigned int)(*p)))
1799
*p = (char)tolower ((unsigned int)(*p));
1801
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
1803
yylval->Meridian = MERam;
1806
if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
1808
yylval->Meridian = MERpm;
1812
/* See if we have an abbreviation for a month. */
1813
if (strlen (buff) == 3)
1815
else if (strlen (buff) == 4 && buff[3] == '.')
1823
for (tp = MonthDayTable; tp->name; tp++)
1827
if (strncmp (buff, tp->name, 3) == 0)
1829
yylval->Number = tp->value;
1833
else if (strcmp (buff, tp->name) == 0)
1835
yylval->Number = tp->value;
1840
for (tp = TimezoneTable; tp->name; tp++)
1841
if (strcmp (buff, tp->name) == 0)
1843
yylval->Number = tp->value;
1847
if (strcmp (buff, "dst") == 0)
1850
for (tp = UnitsTable; tp->name; tp++)
1851
if (strcmp (buff, tp->name) == 0)
1853
yylval->Number = tp->value;
1857
/* Strip off any plural and try the units table again. */
1858
i = (int)strlen (buff) - 1;
1862
for (tp = UnitsTable; tp->name; tp++)
1863
if (strcmp (buff, tp->name) == 0)
1865
yylval->Number = tp->value;
1868
buff[i] = 's'; /* Put back for "this" in OtherTable. */
1871
for (tp = OtherTable; tp->name; tp++)
1872
if (strcmp (buff, tp->name) == 0)
1874
yylval->Number = tp->value;
1878
/* Military timezones. */
1879
if (buff[1] == '\0' && ISALPHA ((unsigned char) *buff))
1881
for (tp = MilitaryTable; tp->name; tp++)
1882
if (strcmp (buff, tp->name) == 0)
1884
yylval->Number = tp->value;
1889
/* Drop out any periods and try the timezone table again. */
1890
for (i = 0, p = q = buff; *q; q++)
1897
for (tp = TimezoneTable; tp->name; tp++)
1898
if (strcmp (buff, tp->name) == 0)
1900
yylval->Number = tp->value;
1908
yylex (yylval, cookie)
1912
register unsigned char c;
1920
while (ISSPACE ((unsigned char) *context->yyInput))
1923
if (ISDIGIT (c = *context->yyInput) || c == '-' || c == '+')
1925
if (c == '-' || c == '+')
1927
sign = c == '-' ? -1 : 1;
1928
if (!ISDIGIT (*++context->yyInput))
1929
/* skip the '-' sign */
1934
for (yylval->Number = 0; ISDIGIT (c = *context->yyInput++);)
1935
yylval->Number = 10 * yylval->Number + c - '0';
1938
yylval->Number = -yylval->Number;
1939
return sign ? tSNUMBER : tUNUMBER;
1943
for (p = buff; (c = *context->yyInput++, ISALPHA (c)) || c == '.';)
1944
if (p < &buff[sizeof buff - 1])
1948
return LookupWord (yylval, buff);
1951
return *context->yyInput++;
1955
c = *context->yyInput++;
1967
#define TM_YEAR_ORIGIN 1900
1969
/* Yield A - B, measured in seconds. */
1971
difftm (struct tm *a, struct tm *b)
1973
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
1974
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
1976
/* difference in day of year */
1977
a->tm_yday - b->tm_yday
1978
/* + intervening leap days */
1979
+ ((ay >> 2) - (by >> 2))
1980
- (ay / 100 - by / 100)
1981
+ ((ay / 100 >> 2) - (by / 100 >> 2))
1982
/* + difference in years * 365 */
1983
+ (long) (ay - by) * 365
1985
return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
1986
+ (a->tm_min - b->tm_min))
1987
+ (a->tm_sec - b->tm_sec));
1991
curl_getdate (const char *p, const time_t *now)
1993
struct tm tm, tm0, *tmp;
1996
#ifdef HAVE_LOCALTIME_R
2000
Start = now ? *now : time ((time_t *) NULL);
2001
#ifdef HAVE_LOCALTIME_R
2002
tmp = (struct tm *)localtime_r(&Start, &keeptime);
2004
tmp = localtime (&Start);
2008
cookie.yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
2009
cookie.yyMonth = tmp->tm_mon + 1;
2010
cookie.yyDay = tmp->tm_mday;
2011
cookie.yyHour = tmp->tm_hour;
2012
cookie.yyMinutes = tmp->tm_min;
2013
cookie.yySeconds = tmp->tm_sec;
2014
tm.tm_isdst = tmp->tm_isdst;
2015
cookie.yyMeridian = MER24;
2016
cookie.yyRelSeconds = 0;
2017
cookie.yyRelMinutes = 0;
2018
cookie.yyRelHour = 0;
2019
cookie.yyRelDay = 0;
2020
cookie.yyRelMonth = 0;
2021
cookie.yyRelYear = 0;
2022
cookie.yyHaveDate = 0;
2023
cookie.yyHaveDay = 0;
2024
cookie.yyHaveRel = 0;
2025
cookie.yyHaveTime = 0;
2026
cookie.yyHaveZone = 0;
2028
if (yyparse ((void*)&cookie)
2029
|| cookie.yyHaveTime > 1 || cookie.yyHaveZone > 1 ||
2030
cookie.yyHaveDate > 1 || cookie.yyHaveDay > 1)
2033
tm.tm_year = ToYear (cookie.yyYear) - TM_YEAR_ORIGIN + cookie.yyRelYear;
2034
tm.tm_mon = cookie.yyMonth - 1 + cookie.yyRelMonth;
2035
tm.tm_mday = cookie.yyDay + cookie.yyRelDay;
2036
if (cookie.yyHaveTime ||
2037
(cookie.yyHaveRel && !cookie.yyHaveDate && !cookie.yyHaveDay))
2039
tm.tm_hour = ToHour (cookie.yyHour, cookie.yyMeridian);
2042
tm.tm_min = cookie.yyMinutes;
2043
tm.tm_sec = cookie.yySeconds;
2047
tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
2049
tm.tm_hour += cookie.yyRelHour;
2050
tm.tm_min += cookie.yyRelMinutes;
2051
tm.tm_sec += cookie.yyRelSeconds;
2053
/* Let mktime deduce tm_isdst if we have an absolute timestamp,
2054
or if the relative timestamp mentions days, months, or years. */
2055
if (cookie.yyHaveDate | cookie.yyHaveDay | cookie.yyHaveTime |
2056
cookie.yyRelDay | cookie.yyRelMonth | cookie.yyRelYear)
2061
Start = mktime (&tm);
2063
if (Start == (time_t) -1)
2066
/* Guard against falsely reporting errors near the time_t boundaries
2067
when parsing times in other time zones. For example, if the min
2068
time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
2069
of UTC, then the min localtime value is 1970-01-01 08:00:00; if
2070
we apply mktime to 1970-01-01 00:00:00 we will get an error, so
2071
we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
2072
zone by 24 hours to compensate. This algorithm assumes that
2073
there is no DST transition within a day of the time_t boundaries. */
2074
if (cookie.yyHaveZone)
2077
if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
2080
cookie.yyTimezone -= 24 * 60;
2085
cookie.yyTimezone += 24 * 60;
2087
Start = mktime (&tm);
2090
if (Start == (time_t) -1)
2094
if (cookie.yyHaveDay && !cookie.yyHaveDate)
2096
tm.tm_mday += ((cookie.yyDayNumber - tm.tm_wday + 7) % 7
2097
+ 7 * (cookie.yyDayOrdinal - (0 < cookie.yyDayOrdinal)));
2098
Start = mktime (&tm);
2099
if (Start == (time_t) -1)
2103
if (cookie.yyHaveZone)
2107
#ifdef HAVE_GMTIME_R
2108
/* thread-safe version */
2110
gmt = (struct tm *)gmtime_r(&Start, &keeptime);
2112
gmt = gmtime(&Start);
2116
delta = cookie.yyTimezone * 60L + difftm (&tm, gmt);
2117
if ((Start + delta < Start) != (delta < 0))
2118
return -1; /* time_t overflow */
2133
char buff[MAX_BUFF_LEN + 1];
2136
(void) printf ("Enter date, or blank line to exit.\n\t> ");
2137
(void) fflush (stdout);
2139
buff[MAX_BUFF_LEN] = 0;
2140
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
2142
d = curl_getdate (buff, (time_t *) NULL);
2144
(void) printf ("Bad format - couldn't convert.\n");
2146
(void) printf ("%s", ctime (&d));
2147
(void) printf ("\t> ");
2148
(void) fflush (stdout);
2153
#endif /* defined (TEST) */