~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to lib/getdate.c

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*@-globstate -statictrans -unqualifiedtrans -noparams @*/
 
2
/*@-retvalint -usedef -varuse -nullderef -nullassign @*/
 
3
/*@-readonlytrans -modunconnomods @*/
 
4
#ifndef lint
 
5
static char const 
 
6
yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
 
7
#endif
 
8
#include <stdlib.h>
 
9
#define YYBYACC 1
 
10
#define YYMAJOR 1
 
11
#define YYMINOR 9
 
12
#define YYLEX yylex()
 
13
#define YYEMPTY -1
 
14
#define yyclearin (yychar=(YYEMPTY))
 
15
#define yyerrok (yyerrflag=0)
 
16
#define YYRECOVERING() (yyerrflag!=0)
 
17
static int yygrowstack();
 
18
#define YYPREFIX "yy"
 
19
#line 2 "./getdate.y"
 
20
/*
 
21
**  Originally written by Steven M. Bellovin <smb@research.att.com> while
 
22
**  at the University of North Carolina at Chapel Hill.  Later tweaked by
 
23
**  a couple of people on Usenet.  Completely overhauled by Rich $alz
 
24
**  <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
 
25
**
 
26
**  This grammar has 10 shift/reduce conflicts.
 
27
**
 
28
**  This code is in the public domain and has no copyright.
 
29
*/
 
30
/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
 
31
/* SUPPRESS 288 on yyerrlab *//* Label unused */
 
32
 
 
33
#ifdef HAVE_CONFIG_H
 
34
#if defined (emacs) || defined (CONFIG_BROKETS)
 
35
#include <config.h>
 
36
#else
 
37
#include "config.h"
 
38
#endif
 
39
#endif
 
40
 
 
41
/* Since the code of getdate.y is not included in the Emacs executable
 
42
   itself, there is no need to #define static in this file.  Even if
 
43
   the code were included in the Emacs executable, it probably
 
44
   wouldn't do any harm to #undef it here; this will only cause
 
45
   problems if we try to write to a static variable, which I don't
 
46
   think this code needs to do.  */
 
47
#ifdef emacs
 
48
#undef static
 
49
#endif
 
50
 
 
51
#include <stdio.h>
 
52
#include <ctype.h>
 
53
 
 
54
/* The code at the top of get_date which figures out the offset of the
 
55
   current time zone checks various CPP symbols to see if special
 
56
   tricks are need, but defaults to using the gettimeofday system call.
 
57
   Include <sys/time.h> if that will be used.  */
 
58
 
 
59
#if     defined(vms)
 
60
 
 
61
#include <types.h>
 
62
#include <time.h>
 
63
 
 
64
#else
 
65
 
 
66
#include <sys/types.h>
 
67
 
 
68
#ifdef TIME_WITH_SYS_TIME
 
69
#include <sys/time.h>
 
70
#include <time.h>
 
71
#else
 
72
#ifdef HAVE_SYS_TIME_H
 
73
#include <sys/time.h>
 
74
#else
 
75
#include <time.h>
 
76
#endif
 
77
#endif
 
78
 
 
79
#ifdef timezone
 
80
#undef timezone /* needed for sgi */
 
81
#endif
 
82
 
 
83
#if defined(HAVE_SYS_TIMEB_H)
 
84
#include <sys/timeb.h>
 
85
#else
 
86
/*
 
87
** We use the obsolete `struct timeb' as part of our interface!
 
88
** Since the system doesn't have it, we define it here;
 
89
** our callers must do likewise.
 
90
*/
 
91
struct timeb {
 
92
    time_t              time;           /* Seconds since the epoch      */
 
93
    unsigned short      millitm;        /* Field not used               */
 
94
    short               timezone;       /* Minutes west of GMT          */
 
95
    short               dstflag;        /* Field not used               */
 
96
};
 
97
#endif /* defined(HAVE_SYS_TIMEB_H) */
 
98
 
 
99
#endif  /* defined(vms) */
 
100
 
 
101
#if defined (STDC_HEADERS) || defined (USG)
 
102
#include <string.h>
 
103
#endif
 
104
 
 
105
/* Some old versions of bison generate parsers that use bcopy.
 
106
   That loses on systems that don't provide the function, so we have
 
107
   to redefine it here.  */
 
108
#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
 
109
#define bcopy(from, to, len) memcpy ((to), (from), (len))
 
110
#endif
 
111
 
 
112
#if defined (STDC_HEADERS)
 
113
#include <stdlib.h>
 
114
#endif
 
115
 
 
116
/* NOTES on rebuilding getdate.c (particularly for inclusion in CVS
 
117
   releases):
 
118
 
 
119
   We don't want to mess with all the portability hassles of alloca.
 
120
   In particular, most (all?) versions of bison will use alloca in
 
121
   their parser.  If bison works on your system (e.g. it should work
 
122
   with gcc), then go ahead and use it, but the more general solution
 
123
   is to use byacc instead of bison, which should generate a portable
 
124
   parser.  I played with adding "#define alloca dont_use_alloca", to
 
125
   give an error if the parser generator uses alloca (and thus detect
 
126
   unportable getdate.c's), but that seems to cause as many problems
 
127
   as it solves.  */
 
128
 
 
129
#if 0
 
130
extern struct tm        *gmtime();
 
131
extern struct tm        *localtime();
 
132
#endif
 
133
 
 
134
extern time_t get_date(char * p, struct timeb * now);
 
135
 
 
136
#define yyparse getdate_yyparse
 
137
#define yylex getdate_yylex
 
138
#define yyerror getdate_yyerror
 
139
 
 
140
static int yyparse (void);
 
141
static int yylex (void);
 
142
static int yyerror(const char * s);
 
143
 
 
144
#define EPOCH           1970
 
145
#define HOUR(x)         ((time_t)(x) * 60)
 
146
#define SECSPERDAY      (24L * 60L * 60L)
 
147
 
 
148
 
 
149
/*
 
150
**  An entry in the lexical lookup table.
 
151
*/
 
152
typedef struct _TABLE {
 
153
    char        *name;
 
154
    int         type;
 
155
    time_t      value;
 
156
} TABLE;
 
157
 
 
158
 
 
159
/*
 
160
**  Daylight-savings mode:  on, off, or not yet known.
 
161
*/
 
162
typedef enum _DSTMODE {
 
163
    DSTon, DSToff, DSTmaybe
 
164
} DSTMODE;
 
165
 
 
166
/*
 
167
**  Meridian:  am, pm, or 24-hour style.
 
168
*/
 
169
typedef enum _MERIDIAN {
 
170
    MERam, MERpm, MER24
 
171
} MERIDIAN;
 
172
 
 
173
 
 
174
/*
 
175
**  Global variables.  We could get rid of most of these by using a good
 
176
**  union as the yacc stack.  (This routine was originally written before
 
177
**  yacc had the %union construct.)  Maybe someday; right now we only use
 
178
**  the %union very rarely.
 
179
*/
 
180
static char     *yyInput;
 
181
static DSTMODE  yyDSTmode;
 
182
static time_t   yyDayOrdinal;
 
183
static time_t   yyDayNumber;
 
184
static int      yyHaveDate;
 
185
static int      yyHaveDay;
 
186
static int      yyHaveRel;
 
187
static int      yyHaveTime;
 
188
static int      yyHaveZone;
 
189
static time_t   yyTimezone;
 
190
static time_t   yyDay;
 
191
static time_t   yyHour;
 
192
static time_t   yyMinutes;
 
193
static time_t   yyMonth;
 
194
static time_t   yySeconds;
 
195
static time_t   yyYear;
 
196
static MERIDIAN yyMeridian;
 
197
static time_t   yyRelMonth;
 
198
static time_t   yyRelSeconds;
 
199
 
 
200
#line 184 "./getdate.y"
 
201
typedef union {
 
202
    time_t              Number;
 
203
    enum _MERIDIAN      Meridian;
 
204
} YYSTYPE;
 
205
#line 203 "getdate.c"
 
206
#define YYERRCODE 256
 
207
#define tAGO 257
 
208
#define tDAY 258
 
209
#define tDAYZONE 259
 
210
#define tID 260
 
211
#define tMERIDIAN 261
 
212
#define tMINUTE_UNIT 262
 
213
#define tMONTH 263
 
214
#define tMONTH_UNIT 264
 
215
#define tSEC_UNIT 265
 
216
#define tSNUMBER 266
 
217
#define tUNUMBER 267
 
218
#define tZONE 268
 
219
#define tDST 269
 
220
static const short yylhs[] = {                                        -1,
 
221
    0,    0,    2,    2,    2,    2,    2,    2,    3,    3,
 
222
    3,    3,    3,    4,    4,    4,    6,    6,    6,    5,
 
223
    5,    5,    5,    5,    5,    5,    5,    7,    7,    9,
 
224
    9,    9,    9,    9,    9,    9,    9,    9,    8,    1,
 
225
    1,
 
226
};
 
227
static const short yylen[] = {                                         2,
 
228
    0,    2,    1,    1,    1,    1,    1,    1,    2,    4,
 
229
    4,    6,    6,    1,    1,    2,    1,    2,    2,    3,
 
230
    5,    3,    3,    2,    4,    2,    3,    2,    1,    2,
 
231
    2,    1,    2,    2,    1,    2,    2,    1,    1,    0,
 
232
    1,
 
233
};
 
234
static const short yydefred[] = {                                      1,
 
235
    0,    0,   15,   32,    0,   38,   35,    0,    0,    0,
 
236
    2,    3,    4,    5,    6,    7,    8,    0,   18,    0,
 
237
   31,   36,   33,   19,    9,   30,    0,   37,   34,    0,
 
238
    0,    0,   16,   28,    0,   23,   27,   22,    0,    0,
 
239
   25,   41,   11,    0,   10,    0,    0,   21,   13,   12,
 
240
};
 
241
static const short yydgoto[] = {                                       1,
 
242
   45,   11,   12,   13,   14,   15,   16,   17,   18,
 
243
};
 
244
static const short yysindex[] = {                                      0,
 
245
 -249,  -38,    0,    0, -260,    0,    0, -240,  -47, -248,
 
246
    0,    0,    0,    0,    0,    0,    0, -237,    0,  -18,
 
247
    0,    0,    0,    0,    0,    0, -262,    0,    0, -239,
 
248
 -238, -236,    0,    0, -235,    0,    0,    0,  -56,  -19,
 
249
    0,    0,    0, -234,    0, -232, -258,    0,    0,    0,
 
250
};
 
251
static const short yyrindex[] = {                                      0,
 
252
    0,    1,    0,    0,    0,    0,    0,    0,   69,   12,
 
253
    0,    0,    0,    0,    0,    0,    0,   23,    0,   34,
 
254
    0,    0,    0,    0,    0,    0,   67,    0,    0,    0,
 
255
    0,    0,    0,    0,    0,    0,    0,    0,   56,   45,
 
256
    0,    0,    0,    0,    0,    0,   56,    0,    0,    0,
 
257
};
 
258
static const short yygindex[] = {                                      0,
 
259
  -17,    0,    0,    0,    0,    0,    0,    0,    0,
 
260
};
 
261
#define YYTABLESIZE 337
 
262
static const short yytable[] = {                                      32,
 
263
   17,   44,   42,   36,   37,   19,   20,   49,    2,    3,
 
264
   31,   14,    4,    5,    6,    7,    8,    9,   10,   34,
 
265
   33,   21,   29,   22,   23,   35,   38,   46,   39,   50,
 
266
   40,   41,   47,   24,   48,    0,    0,    0,    0,    0,
 
267
    0,    0,    0,    0,   20,    0,    0,    0,    0,    0,
 
268
    0,    0,    0,    0,    0,   40,    0,    0,    0,    0,
 
269
    0,    0,    0,    0,    0,    0,   26,    0,   39,    0,
 
270
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
271
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
272
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
273
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
274
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
275
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
276
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
277
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
278
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
279
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
280
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
281
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
282
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
283
    0,    0,    0,    0,   42,    0,    0,    0,    0,   43,
 
284
   24,    0,    0,   25,   26,   27,   28,   29,   30,    0,
 
285
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
286
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
287
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
288
    0,    0,    0,    0,    0,    0,    0,    0,   17,   17,
 
289
    0,    0,   17,   17,   17,   17,   17,   17,   17,   14,
 
290
   14,    0,    0,   14,   14,   14,   14,   14,   14,   14,
 
291
   29,   29,    0,    0,   29,   29,   29,   29,   29,   29,
 
292
   29,   24,   24,    0,    0,   24,   24,   24,   24,   24,
 
293
   24,   24,   20,   20,    0,    0,   20,   20,   20,   20,
 
294
   20,   20,   20,   40,   40,    0,    0,   40,   40,   40,
 
295
   40,    0,   40,   40,   26,   26,    0,   39,   26,   26,
 
296
   26,   26,    0,    0,   26,   39,   39,
 
297
};
 
298
static const short yycheck[] = {                                      47,
 
299
    0,   58,  261,  266,  267,   44,  267,  266,  258,  259,
 
300
   58,    0,  262,  263,  264,  265,  266,  267,  268,  257,
 
301
  269,  262,    0,  264,  265,   44,  266,   47,  267,   47,
 
302
  267,  267,  267,    0,  267,   -1,   -1,   -1,   -1,   -1,
 
303
   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,
 
304
   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,
 
305
   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,    0,   -1,
 
306
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
307
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
308
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
309
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
310
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
311
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
312
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
313
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
314
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
315
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
316
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
317
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
318
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
319
   -1,   -1,   -1,   -1,  261,   -1,   -1,   -1,   -1,  266,
 
320
  258,   -1,   -1,  261,  262,  263,  264,  265,  266,   -1,
 
321
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
322
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
323
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
 
324
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,  259,
 
325
   -1,   -1,  262,  263,  264,  265,  266,  267,  268,  258,
 
326
  259,   -1,   -1,  262,  263,  264,  265,  266,  267,  268,
 
327
  258,  259,   -1,   -1,  262,  263,  264,  265,  266,  267,
 
328
  268,  258,  259,   -1,   -1,  262,  263,  264,  265,  266,
 
329
  267,  268,  258,  259,   -1,   -1,  262,  263,  264,  265,
 
330
  266,  267,  268,  258,  259,   -1,   -1,  262,  263,  264,
 
331
  265,   -1,  267,  268,  258,  259,   -1,  259,  262,  263,
 
332
  264,  265,   -1,   -1,  268,  267,  268,
 
333
};
 
334
#define YYFINAL 1
 
335
#ifndef YYDEBUG
 
336
#define YYDEBUG 0
 
337
#endif
 
338
#define YYMAXTOKEN 269
 
339
#if YYDEBUG
 
340
const char * const yyname[] = {
 
341
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 
342
0,0,0,0,0,0,0,0,0,0,"','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,0,0,
 
343
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 
344
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 
345
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 
346
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 
347
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"tAGO","tDAY",
 
348
"tDAYZONE","tID","tMERIDIAN","tMINUTE_UNIT","tMONTH","tMONTH_UNIT","tSEC_UNIT",
 
349
"tSNUMBER","tUNUMBER","tZONE","tDST",
 
350
};
 
351
const char * const yyrule[] = {
 
352
"$accept : spec",
 
353
"spec :",
 
354
"spec : spec item",
 
355
"item : time",
 
356
"item : zone",
 
357
"item : date",
 
358
"item : day",
 
359
"item : rel",
 
360
"item : number",
 
361
"time : tUNUMBER tMERIDIAN",
 
362
"time : tUNUMBER ':' tUNUMBER o_merid",
 
363
"time : tUNUMBER ':' tUNUMBER tSNUMBER",
 
364
"time : tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid",
 
365
"time : tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER",
 
366
"zone : tZONE",
 
367
"zone : tDAYZONE",
 
368
"zone : tZONE tDST",
 
369
"day : tDAY",
 
370
"day : tDAY ','",
 
371
"day : tUNUMBER tDAY",
 
372
"date : tUNUMBER '/' tUNUMBER",
 
373
"date : tUNUMBER '/' tUNUMBER '/' tUNUMBER",
 
374
"date : tUNUMBER tSNUMBER tSNUMBER",
 
375
"date : tUNUMBER tMONTH tSNUMBER",
 
376
"date : tMONTH tUNUMBER",
 
377
"date : tMONTH tUNUMBER ',' tUNUMBER",
 
378
"date : tUNUMBER tMONTH",
 
379
"date : tUNUMBER tMONTH tUNUMBER",
 
380
"rel : relunit tAGO",
 
381
"rel : relunit",
 
382
"relunit : tUNUMBER tMINUTE_UNIT",
 
383
"relunit : tSNUMBER tMINUTE_UNIT",
 
384
"relunit : tMINUTE_UNIT",
 
385
"relunit : tSNUMBER tSEC_UNIT",
 
386
"relunit : tUNUMBER tSEC_UNIT",
 
387
"relunit : tSEC_UNIT",
 
388
"relunit : tSNUMBER tMONTH_UNIT",
 
389
"relunit : tUNUMBER tMONTH_UNIT",
 
390
"relunit : tMONTH_UNIT",
 
391
"number : tUNUMBER",
 
392
"o_merid :",
 
393
"o_merid : tMERIDIAN",
 
394
};
 
395
#endif
 
396
#if YYDEBUG
 
397
#include <stdio.h>
 
398
#endif
 
399
#ifdef YYSTACKSIZE
 
400
#undef YYMAXDEPTH
 
401
#define YYMAXDEPTH YYSTACKSIZE
 
402
#else
 
403
#ifdef YYMAXDEPTH
 
404
#define YYSTACKSIZE YYMAXDEPTH
 
405
#else
 
406
#define YYSTACKSIZE 10000
 
407
#define YYMAXDEPTH 10000
 
408
#endif
 
409
#endif
 
410
#define YYINITSTACKSIZE 200
 
411
/*@unused@*/ static int yydebug;
 
412
static int yynerrs;
 
413
static int yyerrflag;
 
414
static int yychar;
 
415
static short *yyssp;
 
416
static YYSTYPE *yyvsp;
 
417
static YYSTYPE yyval;
 
418
static YYSTYPE yylval;
 
419
static short *yyss;
 
420
static short *yysslim;
 
421
static YYSTYPE *yyvs;
 
422
static int yystacksize;
 
423
#line 403 "./getdate.y"
 
424
 
 
425
/* Month and day table. */
 
426
static TABLE const MonthDayTable[] = {
 
427
    { "january",        tMONTH,  1 },
 
428
    { "february",       tMONTH,  2 },
 
429
    { "march",          tMONTH,  3 },
 
430
    { "april",          tMONTH,  4 },
 
431
    { "may",            tMONTH,  5 },
 
432
    { "june",           tMONTH,  6 },
 
433
    { "july",           tMONTH,  7 },
 
434
    { "august",         tMONTH,  8 },
 
435
    { "september",      tMONTH,  9 },
 
436
    { "sept",           tMONTH,  9 },
 
437
    { "october",        tMONTH, 10 },
 
438
    { "november",       tMONTH, 11 },
 
439
    { "december",       tMONTH, 12 },
 
440
    { "sunday",         tDAY, 0 },
 
441
    { "monday",         tDAY, 1 },
 
442
    { "tuesday",        tDAY, 2 },
 
443
    { "tues",           tDAY, 2 },
 
444
    { "wednesday",      tDAY, 3 },
 
445
    { "wednes",         tDAY, 3 },
 
446
    { "thursday",       tDAY, 4 },
 
447
    { "thur",           tDAY, 4 },
 
448
    { "thurs",          tDAY, 4 },
 
449
    { "friday",         tDAY, 5 },
 
450
    { "saturday",       tDAY, 6 },
 
451
    { NULL, 0, 0 }
 
452
};
 
453
 
 
454
/* Time units table. */
 
455
static TABLE const UnitsTable[] = {
 
456
    { "year",           tMONTH_UNIT,    12 },
 
457
    { "month",          tMONTH_UNIT,    1 },
 
458
    { "fortnight",      tMINUTE_UNIT,   14 * 24 * 60 },
 
459
    { "week",           tMINUTE_UNIT,   7 * 24 * 60 },
 
460
    { "day",            tMINUTE_UNIT,   1 * 24 * 60 },
 
461
    { "hour",           tMINUTE_UNIT,   60 },
 
462
    { "minute",         tMINUTE_UNIT,   1 },
 
463
    { "min",            tMINUTE_UNIT,   1 },
 
464
    { "second",         tSEC_UNIT,      1 },
 
465
    { "sec",            tSEC_UNIT,      1 },
 
466
    { NULL, 0, 0 }
 
467
};
 
468
 
 
469
/* Assorted relative-time words. */
 
470
static TABLE const OtherTable[] = {
 
471
    { "tomorrow",       tMINUTE_UNIT,   1 * 24 * 60 },
 
472
    { "yesterday",      tMINUTE_UNIT,   -1 * 24 * 60 },
 
473
    { "today",          tMINUTE_UNIT,   0 },
 
474
    { "now",            tMINUTE_UNIT,   0 },
 
475
    { "last",           tUNUMBER,       -1 },
 
476
    { "this",           tMINUTE_UNIT,   0 },
 
477
    { "next",           tUNUMBER,       2 },
 
478
    { "first",          tUNUMBER,       1 },
 
479
/*  { "second",         tUNUMBER,       2 }, */
 
480
    { "third",          tUNUMBER,       3 },
 
481
    { "fourth",         tUNUMBER,       4 },
 
482
    { "fifth",          tUNUMBER,       5 },
 
483
    { "sixth",          tUNUMBER,       6 },
 
484
    { "seventh",        tUNUMBER,       7 },
 
485
    { "eighth",         tUNUMBER,       8 },
 
486
    { "ninth",          tUNUMBER,       9 },
 
487
    { "tenth",          tUNUMBER,       10 },
 
488
    { "eleventh",       tUNUMBER,       11 },
 
489
    { "twelfth",        tUNUMBER,       12 },
 
490
    { "ago",            tAGO,   1 },
 
491
    { NULL, 0, 0 }
 
492
};
 
493
 
 
494
/* The timezone table. */
 
495
/* Some of these are commented out because a time_t can't store a float. */
 
496
static TABLE const TimezoneTable[] = {
 
497
    { "gmt",    tZONE,     HOUR( 0) },  /* Greenwich Mean */
 
498
    { "ut",     tZONE,     HOUR( 0) },  /* Universal (Coordinated) */
 
499
    { "utc",    tZONE,     HOUR( 0) },
 
500
    { "wet",    tZONE,     HOUR( 0) },  /* Western European */
 
501
    { "bst",    tDAYZONE,  HOUR( 0) },  /* British Summer */
 
502
    { "wat",    tZONE,     HOUR( 1) },  /* West Africa */
 
503
    { "at",     tZONE,     HOUR( 2) },  /* Azores */
 
504
#if     0
 
505
    /* For completeness.  BST is also British Summer, and GST is
 
506
     * also Guam Standard. */
 
507
    { "bst",    tZONE,     HOUR( 3) },  /* Brazil Standard */
 
508
    { "gst",    tZONE,     HOUR( 3) },  /* Greenland Standard */
 
509
#endif
 
510
#if 0
 
511
    { "nft",    tZONE,     HOUR(3.5) }, /* Newfoundland */
 
512
    { "nst",    tZONE,     HOUR(3.5) }, /* Newfoundland Standard */
 
513
    { "ndt",    tDAYZONE,  HOUR(3.5) }, /* Newfoundland Daylight */
 
514
#endif
 
515
    { "ast",    tZONE,     HOUR( 4) },  /* Atlantic Standard */
 
516
    { "adt",    tDAYZONE,  HOUR( 4) },  /* Atlantic Daylight */
 
517
    { "est",    tZONE,     HOUR( 5) },  /* Eastern Standard */
 
518
    { "edt",    tDAYZONE,  HOUR( 5) },  /* Eastern Daylight */
 
519
    { "cst",    tZONE,     HOUR( 6) },  /* Central Standard */
 
520
    { "cdt",    tDAYZONE,  HOUR( 6) },  /* Central Daylight */
 
521
    { "mst",    tZONE,     HOUR( 7) },  /* Mountain Standard */
 
522
    { "mdt",    tDAYZONE,  HOUR( 7) },  /* Mountain Daylight */
 
523
    { "pst",    tZONE,     HOUR( 8) },  /* Pacific Standard */
 
524
    { "pdt",    tDAYZONE,  HOUR( 8) },  /* Pacific Daylight */
 
525
    { "yst",    tZONE,     HOUR( 9) },  /* Yukon Standard */
 
526
    { "ydt",    tDAYZONE,  HOUR( 9) },  /* Yukon Daylight */
 
527
    { "hst",    tZONE,     HOUR(10) },  /* Hawaii Standard */
 
528
    { "hdt",    tDAYZONE,  HOUR(10) },  /* Hawaii Daylight */
 
529
    { "cat",    tZONE,     HOUR(10) },  /* Central Alaska */
 
530
    { "ahst",   tZONE,     HOUR(10) },  /* Alaska-Hawaii Standard */
 
531
    { "nt",     tZONE,     HOUR(11) },  /* Nome */
 
532
    { "idlw",   tZONE,     HOUR(12) },  /* International Date Line West */
 
533
    { "cet",    tZONE,     -HOUR(1) },  /* Central European */
 
534
    { "met",    tZONE,     -HOUR(1) },  /* Middle European */
 
535
    { "mewt",   tZONE,     -HOUR(1) },  /* Middle European Winter */
 
536
    { "mest",   tDAYZONE,  -HOUR(1) },  /* Middle European Summer */
 
537
    { "swt",    tZONE,     -HOUR(1) },  /* Swedish Winter */
 
538
    { "sst",    tDAYZONE,  -HOUR(1) },  /* Swedish Summer */
 
539
    { "fwt",    tZONE,     -HOUR(1) },  /* French Winter */
 
540
    { "fst",    tDAYZONE,  -HOUR(1) },  /* French Summer */
 
541
    { "eet",    tZONE,     -HOUR(2) },  /* Eastern Europe, USSR Zone 1 */
 
542
    { "bt",     tZONE,     -HOUR(3) },  /* Baghdad, USSR Zone 2 */
 
543
#if 0
 
544
    { "it",     tZONE,     -HOUR(3.5) },/* Iran */
 
545
#endif
 
546
    { "zp4",    tZONE,     -HOUR(4) },  /* USSR Zone 3 */
 
547
    { "zp5",    tZONE,     -HOUR(5) },  /* USSR Zone 4 */
 
548
#if 0
 
549
    { "ist",    tZONE,     -HOUR(5.5) },/* Indian Standard */
 
550
#endif
 
551
    { "zp6",    tZONE,     -HOUR(6) },  /* USSR Zone 5 */
 
552
#if     0
 
553
    /* For completeness.  NST is also Newfoundland Stanard, and SST is
 
554
     * also Swedish Summer. */
 
555
    { "nst",    tZONE,     -HOUR(6.5) },/* North Sumatra */
 
556
    { "sst",    tZONE,     -HOUR(7) },  /* South Sumatra, USSR Zone 6 */
 
557
#endif  /* 0 */
 
558
    { "wast",   tZONE,     -HOUR(7) },  /* West Australian Standard */
 
559
    { "wadt",   tDAYZONE,  -HOUR(7) },  /* West Australian Daylight */
 
560
#if 0
 
561
    { "jt",     tZONE,     -HOUR(7.5) },/* Java (3pm in Cronusland!) */
 
562
#endif
 
563
    { "cct",    tZONE,     -HOUR(8) },  /* China Coast, USSR Zone 7 */
 
564
    { "jst",    tZONE,     -HOUR(9) },  /* Japan Standard, USSR Zone 8 */
 
565
#if 0
 
566
    { "cast",   tZONE,     -HOUR(9.5) },/* Central Australian Standard */
 
567
    { "cadt",   tDAYZONE,  -HOUR(9.5) },/* Central Australian Daylight */
 
568
#endif
 
569
    { "east",   tZONE,     -HOUR(10) }, /* Eastern Australian Standard */
 
570
    { "eadt",   tDAYZONE,  -HOUR(10) }, /* Eastern Australian Daylight */
 
571
    { "gst",    tZONE,     -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
 
572
    { "nzt",    tZONE,     -HOUR(12) }, /* New Zealand */
 
573
    { "nzst",   tZONE,     -HOUR(12) }, /* New Zealand Standard */
 
574
    { "nzdt",   tDAYZONE,  -HOUR(12) }, /* New Zealand Daylight */
 
575
    { "idle",   tZONE,     -HOUR(12) }, /* International Date Line East */
 
576
    {  NULL, 0, 0  }
 
577
};
 
578
 
 
579
/* Military timezone table. */
 
580
static TABLE const MilitaryTable[] = {
 
581
    { "a",      tZONE,  HOUR(  1) },
 
582
    { "b",      tZONE,  HOUR(  2) },
 
583
    { "c",      tZONE,  HOUR(  3) },
 
584
    { "d",      tZONE,  HOUR(  4) },
 
585
    { "e",      tZONE,  HOUR(  5) },
 
586
    { "f",      tZONE,  HOUR(  6) },
 
587
    { "g",      tZONE,  HOUR(  7) },
 
588
    { "h",      tZONE,  HOUR(  8) },
 
589
    { "i",      tZONE,  HOUR(  9) },
 
590
    { "k",      tZONE,  HOUR( 10) },
 
591
    { "l",      tZONE,  HOUR( 11) },
 
592
    { "m",      tZONE,  HOUR( 12) },
 
593
    { "n",      tZONE,  HOUR(- 1) },
 
594
    { "o",      tZONE,  HOUR(- 2) },
 
595
    { "p",      tZONE,  HOUR(- 3) },
 
596
    { "q",      tZONE,  HOUR(- 4) },
 
597
    { "r",      tZONE,  HOUR(- 5) },
 
598
    { "s",      tZONE,  HOUR(- 6) },
 
599
    { "t",      tZONE,  HOUR(- 7) },
 
600
    { "u",      tZONE,  HOUR(- 8) },
 
601
    { "v",      tZONE,  HOUR(- 9) },
 
602
    { "w",      tZONE,  HOUR(-10) },
 
603
    { "x",      tZONE,  HOUR(-11) },
 
604
    { "y",      tZONE,  HOUR(-12) },
 
605
    { "z",      tZONE,  HOUR(  0) },
 
606
    { NULL, 0, 0 }
 
607
};
 
608
 
 
609
 
 
610
 
 
611
 
 
612
/* ARGSUSED */
 
613
static int
 
614
yyerror(const char * s)
 
615
{
 
616
  return 0;
 
617
}
 
618
 
 
619
 
 
620
static time_t
 
621
ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
 
622
{
 
623
    if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
 
624
        return -1;
 
625
    switch (Meridian) {
 
626
    case MER24:
 
627
        if (Hours < 0 || Hours > 23)
 
628
            return -1;
 
629
        return (Hours * 60L + Minutes) * 60L + Seconds;
 
630
    case MERam:
 
631
        if (Hours < 1 || Hours > 12)
 
632
            return -1;
 
633
        if (Hours == 12)
 
634
            Hours = 0;
 
635
        return (Hours * 60L + Minutes) * 60L + Seconds;
 
636
    case MERpm:
 
637
        if (Hours < 1 || Hours > 12)
 
638
            return -1;
 
639
        if (Hours == 12)
 
640
            Hours = 0;
 
641
        return ((Hours + 12) * 60L + Minutes) * 60L + Seconds;
 
642
    default:
 
643
        abort ();
 
644
    }
 
645
    /* NOTREACHED */
 
646
}
 
647
 
 
648
 
 
649
/* Year is either
 
650
   * A negative number, which means to use its absolute value (why?)
 
651
   * A number from 0 to 99, which means a year from 1900 to 1999, or
 
652
   * The actual year (>=100).  */
 
653
static time_t
 
654
Convert(time_t Month, time_t Day, time_t Year,
 
655
        time_t Hours, time_t Minutes, time_t Seconds,
 
656
        MERIDIAN Meridian, DSTMODE DSTmode)
 
657
{
 
658
    static int DaysInMonth[12] = {
 
659
        31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
 
660
    };
 
661
    time_t      tod;
 
662
    time_t      Julian;
 
663
    int         i;
 
664
 
 
665
    if (Year < 0)
 
666
        Year = -Year;
 
667
    if (Year < 69)
 
668
        Year += 2000;
 
669
    else if (Year < 100)
 
670
        Year += 1900;
 
671
    DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
 
672
                    ? 29 : 28;
 
673
    /* Checking for 2038 bogusly assumes that time_t is 32 bits.  But
 
674
       I'm too lazy to try to check for time_t overflow in another way.  */
 
675
    if (Year < EPOCH || Year > 2038
 
676
     || Month < 1 || Month > 12
 
677
     /* Lint fluff:  "conversion from long may lose accuracy" */
 
678
     || Day < 1 || Day > DaysInMonth[(int)--Month])
 
679
        return -1;
 
680
 
 
681
    for (Julian = Day - 1, i = 0; i < Month; i++)
 
682
        Julian += DaysInMonth[i];
 
683
    for (i = EPOCH; i < Year; i++)
 
684
        Julian += 365 + (i % 4 == 0);
 
685
    Julian *= SECSPERDAY;
 
686
    Julian += yyTimezone * 60L;
 
687
    if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
 
688
        return -1;
 
689
    Julian += tod;
 
690
    if (DSTmode == DSTon
 
691
     || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst))
 
692
        Julian -= 60 * 60;
 
693
    return Julian;
 
694
}
 
695
 
 
696
 
 
697
static time_t
 
698
DSTcorrect(time_t Start, time_t Future)
 
699
{
 
700
    time_t      StartDay;
 
701
    time_t      FutureDay;
 
702
 
 
703
    StartDay = (localtime(&Start)->tm_hour + 1) % 24;
 
704
    FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
 
705
    return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
 
706
}
 
707
 
 
708
 
 
709
static time_t
 
710
RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber)
 
711
{
 
712
    struct tm   *tm;
 
713
    time_t      now;
 
714
 
 
715
    now = Start;
 
716
    tm = localtime(&now);
 
717
    now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
 
718
    now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
 
719
    return DSTcorrect(Start, now);
 
720
}
 
721
 
 
722
 
 
723
static time_t
 
724
RelativeMonth(time_t Start, time_t RelMonth)
 
725
{
 
726
    struct tm   *tm;
 
727
    time_t      Month;
 
728
    time_t      Year;
 
729
 
 
730
    if (RelMonth == 0)
 
731
        return 0;
 
732
    tm = localtime(&Start);
 
733
    Month = 12 * (tm->tm_year + 1900) + tm->tm_mon + RelMonth;
 
734
    Year = Month / 12;
 
735
    Month = Month % 12 + 1;
 
736
    return DSTcorrect(Start,
 
737
            Convert(Month, (time_t)tm->tm_mday, Year,
 
738
                (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
 
739
                MER24, DSTmaybe));
 
740
}
 
741
 
 
742
 
 
743
static int
 
744
LookupWord(char * buff)
 
745
{
 
746
    register char       *p;
 
747
    register char       *q;
 
748
    register const TABLE        *tp;
 
749
    int                 i;
 
750
    int                 abbrev;
 
751
 
 
752
    /* Make it lowercase. */
 
753
    for (p = buff; *p != '\0'; p++)
 
754
        if (isupper(*p))
 
755
            *p = tolower(*p);
 
756
 
 
757
    if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
 
758
        yylval.Meridian = MERam;
 
759
        return tMERIDIAN;
 
760
    }
 
761
    if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
 
762
        yylval.Meridian = MERpm;
 
763
        return tMERIDIAN;
 
764
    }
 
765
 
 
766
    /* See if we have an abbreviation for a month. */
 
767
    if (strlen(buff) == 3)
 
768
        abbrev = 1;
 
769
    else if (strlen(buff) == 4 && buff[3] == '.') {
 
770
        abbrev = 1;
 
771
        buff[3] = '\0';
 
772
    }
 
773
    else
 
774
        abbrev = 0;
 
775
 
 
776
    for (tp = MonthDayTable; tp->name; tp++) {
 
777
        if (abbrev) {
 
778
            if (strncmp(buff, tp->name, 3) == 0) {
 
779
                yylval.Number = tp->value;
 
780
                return tp->type;
 
781
            }
 
782
        }
 
783
        else if (strcmp(buff, tp->name) == 0) {
 
784
            yylval.Number = tp->value;
 
785
            return tp->type;
 
786
        }
 
787
    }
 
788
 
 
789
    for (tp = TimezoneTable; tp->name; tp++)
 
790
        if (strcmp(buff, tp->name) == 0) {
 
791
            yylval.Number = tp->value;
 
792
            return tp->type;
 
793
        }
 
794
 
 
795
    if (strcmp(buff, "dst") == 0) 
 
796
        return tDST;
 
797
 
 
798
    for (tp = UnitsTable; tp->name; tp++)
 
799
        if (strcmp(buff, tp->name) == 0) {
 
800
            yylval.Number = tp->value;
 
801
            return tp->type;
 
802
        }
 
803
 
 
804
    /* Strip off any plural and try the units table again. */
 
805
    i = strlen(buff) - 1;
 
806
    if (buff[i] == 's') {
 
807
        buff[i] = '\0';
 
808
        for (tp = UnitsTable; tp->name; tp++)
 
809
            if (strcmp(buff, tp->name) == 0) {
 
810
                yylval.Number = tp->value;
 
811
                return tp->type;
 
812
            }
 
813
        buff[i] = 's';          /* Put back for "this" in OtherTable. */
 
814
    }
 
815
 
 
816
    for (tp = OtherTable; tp->name; tp++)
 
817
        if (strcmp(buff, tp->name) == 0) {
 
818
            yylval.Number = tp->value;
 
819
            return tp->type;
 
820
        }
 
821
 
 
822
    /* Military timezones. */
 
823
    if (buff[1] == '\0' && isalpha(*buff)) {
 
824
        for (tp = MilitaryTable; tp->name; tp++)
 
825
            if (strcmp(buff, tp->name) == 0) {
 
826
                yylval.Number = tp->value;
 
827
                return tp->type;
 
828
            }
 
829
    }
 
830
 
 
831
    /* Drop out any periods and try the timezone table again. */
 
832
    for (i = 0, p = q = buff; *q != '\0'; q++)
 
833
        if (*q != '.')
 
834
            *p++ = *q;
 
835
        else
 
836
            i++;
 
837
    *p = '\0';
 
838
    if (i)
 
839
        for (tp = TimezoneTable; tp->name; tp++)
 
840
            if (strcmp(buff, tp->name) == 0) {
 
841
                yylval.Number = tp->value;
 
842
                return tp->type;
 
843
            }
 
844
 
 
845
    return tID;
 
846
}
 
847
 
 
848
 
 
849
static int
 
850
yylex(void)
 
851
{
 
852
    register char       c;
 
853
    register char       *p;
 
854
    char                buff[20];
 
855
    int                 Count;
 
856
    int                 sign;
 
857
 
 
858
    for ( ; ; ) {
 
859
        while (isspace(*yyInput))
 
860
            yyInput++;
 
861
 
 
862
        if (isdigit(c = *yyInput) || c == '-' || c == '+') {
 
863
            if (c == '-' || c == '+') {
 
864
                sign = c == '-' ? -1 : 1;
 
865
                if (!isdigit(*++yyInput))
 
866
                    /* skip the '-' sign */
 
867
                    continue;
 
868
            }
 
869
            else
 
870
                sign = 0;
 
871
            for (yylval.Number = 0; isdigit(c = *yyInput++); )
 
872
                yylval.Number = 10 * yylval.Number + c - '0';
 
873
            yyInput--;
 
874
            if (sign < 0)
 
875
                yylval.Number = -yylval.Number;
 
876
            return sign ? tSNUMBER : tUNUMBER;
 
877
        }
 
878
        if (isalpha(c)) {
 
879
            for (p = buff; isalpha(c = *yyInput++) || c == '.'; )
 
880
                if (p < &buff[sizeof buff - 1])
 
881
                    *p++ = c;
 
882
            *p = '\0';
 
883
            yyInput--;
 
884
            return LookupWord(buff);
 
885
        }
 
886
        if (c != '(')
 
887
            return *yyInput++;
 
888
        Count = 0;
 
889
        do {
 
890
            c = *yyInput++;
 
891
            if (c == '\0')
 
892
                return c;
 
893
            if (c == '(')
 
894
                Count++;
 
895
            else if (c == ')')
 
896
                Count--;
 
897
        } while (Count > 0);
 
898
    }
 
899
    /*@notreached@*/
 
900
    return 0;
 
901
}
 
902
 
 
903
#define TM_YEAR_ORIGIN 1900
 
904
 
 
905
/* Yield A - B, measured in seconds.  */
 
906
static long
 
907
difftm (const struct tm * a, const struct tm * b)
 
908
{
 
909
  unsigned ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
 
910
  unsigned by = b->tm_year + (TM_YEAR_ORIGIN - 1);
 
911
  int days = (
 
912
              /* difference in day of year */
 
913
              a->tm_yday - b->tm_yday
 
914
              /* + intervening leap days */
 
915
              +  ((ay >> 2) - (by >> 2))
 
916
              -  (ay/100 - by/100)
 
917
              +  ((ay/100 >> 2) - (by/100 >> 2))
 
918
              /* + difference in years * 365 */
 
919
              +  (long)(ay-by) * 365
 
920
              );
 
921
  return (60*(60*(24*days + (a->tm_hour - b->tm_hour))
 
922
              + (a->tm_min - b->tm_min))
 
923
          + (a->tm_sec - b->tm_sec));
 
924
}
 
925
 
 
926
time_t
 
927
get_date(char * p, struct timeb * now)
 
928
{
 
929
    struct tm           *tm, gmt;
 
930
    struct timeb        ftz;
 
931
    time_t              Start;
 
932
    time_t              tod;
 
933
    time_t nowtime;
 
934
 
 
935
    yyInput = p;
 
936
    memset(&gmt, 0, sizeof(gmt));
 
937
    if (now == NULL) {
 
938
        struct tm *gmt_ptr;
 
939
 
 
940
        now = &ftz;
 
941
        (void)time (&nowtime);
 
942
 
 
943
        gmt_ptr = gmtime (&nowtime);
 
944
        if (gmt_ptr != NULL)
 
945
        {
 
946
            /* Make a copy, in case localtime modifies *tm (I think
 
947
               that comment now applies to *gmt_ptr, but I am too
 
948
               lazy to dig into how gmtime and locatime allocate the
 
949
               structures they return pointers to).  */
 
950
            gmt = *gmt_ptr;
 
951
        }
 
952
 
 
953
        if (! (tm = localtime (&nowtime)))
 
954
            return -1;
 
955
 
 
956
        if (gmt_ptr != NULL)
 
957
            /*@-observertrans -dependenttrans@*/
 
958
            ftz.timezone = difftm (&gmt, tm) / 60;
 
959
            /*@=observertrans =dependenttrans@*/
 
960
        else
 
961
            /* We are on a system like VMS, where the system clock is
 
962
               in local time and the system has no concept of timezones.
 
963
               Hopefully we can fake this out (for the case in which the
 
964
               user specifies no timezone) by just saying the timezone
 
965
               is zero.  */
 
966
            ftz.timezone = 0;
 
967
 
 
968
        if(tm->tm_isdst)
 
969
            ftz.timezone += 60;
 
970
    }
 
971
    else
 
972
    {
 
973
        nowtime = now->time;
 
974
    }
 
975
 
 
976
    tm = localtime(&nowtime);
 
977
    yyYear = tm->tm_year + 1900;
 
978
    yyMonth = tm->tm_mon + 1;
 
979
    yyDay = tm->tm_mday;
 
980
    yyTimezone = now->timezone;
 
981
    yyDSTmode = DSTmaybe;
 
982
    yyHour = 0;
 
983
    yyMinutes = 0;
 
984
    yySeconds = 0;
 
985
    yyMeridian = MER24;
 
986
    yyRelSeconds = 0;
 
987
    yyRelMonth = 0;
 
988
    yyHaveDate = 0;
 
989
    yyHaveDay = 0;
 
990
    yyHaveRel = 0;
 
991
    yyHaveTime = 0;
 
992
    yyHaveZone = 0;
 
993
 
 
994
    /*@-unrecog@*/
 
995
    if (yyparse()
 
996
     || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
 
997
        return -1;
 
998
    /*@=unrecog@*/
 
999
 
 
1000
    if (yyHaveDate || yyHaveTime || yyHaveDay) {
 
1001
        Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
 
1002
                    yyMeridian, yyDSTmode);
 
1003
        if (Start < 0)
 
1004
            return -1;
 
1005
    }
 
1006
    else {
 
1007
        Start = nowtime;
 
1008
        if (!yyHaveRel)
 
1009
            Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec;
 
1010
    }
 
1011
 
 
1012
    Start += yyRelSeconds;
 
1013
    Start += RelativeMonth(Start, yyRelMonth);
 
1014
 
 
1015
    if (yyHaveDay && !yyHaveDate) {
 
1016
        tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber);
 
1017
        Start += tod;
 
1018
    }
 
1019
 
 
1020
    /* Have to do *something* with a legitimate -1 so it's distinguishable
 
1021
     * from the error return value.  (Alternately could set errno on error.) */
 
1022
    return Start == -1 ? 0 : Start;
 
1023
}
 
1024
 
 
1025
 
 
1026
#if     defined(TEST)
 
1027
 
 
1028
/* ARGSUSED */
 
1029
int
 
1030
main(ac, av)
 
1031
    int         ac;
 
1032
    char        *av[];
 
1033
{
 
1034
    char        buff[128];
 
1035
    time_t      d;
 
1036
 
 
1037
    (void)printf("Enter date, or blank line to exit.\n\t> ");
 
1038
    (void)fflush(stdout);
 
1039
    while (gets(buff) && buff[0]) {
 
1040
        d = get_date(buff, (struct timeb *)NULL);
 
1041
        if (d == -1)
 
1042
            (void)printf("Bad format - couldn't convert.\n");
 
1043
        else
 
1044
            (void)printf("%s", ctime(&d));
 
1045
        (void)printf("\t> ");
 
1046
        (void)fflush(stdout);
 
1047
    }
 
1048
    exit(0);
 
1049
    /* NOTREACHED */
 
1050
}
 
1051
#endif  /* defined(TEST) */
 
1052
#line 1050 "getdate.c"
 
1053
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
 
1054
static int yygrowstack()
 
1055
{
 
1056
    int newsize, i;
 
1057
    short *newss;
 
1058
    YYSTYPE *newvs;
 
1059
 
 
1060
    if ((newsize = yystacksize) == 0)
 
1061
        newsize = YYINITSTACKSIZE;
 
1062
    else if (newsize >= YYMAXDEPTH)
 
1063
        return -1;
 
1064
    else if ((newsize *= 2) > YYMAXDEPTH)
 
1065
        newsize = YYMAXDEPTH;
 
1066
    i = yyssp - yyss;
 
1067
    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
 
1068
      (short *)malloc(newsize * sizeof *newss);
 
1069
    if (newss == NULL)
 
1070
        return -1;
 
1071
    yyss = newss;
 
1072
    yyssp = newss + i;
 
1073
    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
 
1074
      (YYSTYPE *)malloc(newsize * sizeof *newvs);
 
1075
    if (newvs == NULL)
 
1076
        return -1;
 
1077
    yyvs = newvs;
 
1078
    yyvsp = newvs + i;
 
1079
    yystacksize = newsize;
 
1080
    yysslim = yyss + newsize - 1;
 
1081
    return 0;
 
1082
}
 
1083
 
 
1084
#define YYABORT goto yyabort
 
1085
#define YYREJECT goto yyabort
 
1086
#define YYACCEPT goto yyaccept
 
1087
#define YYERROR goto yyerrlab
 
1088
 
 
1089
#ifndef YYPARSE_PARAM
 
1090
#if defined(__cplusplus) || __STDC__
 
1091
#define YYPARSE_PARAM_ARG void
 
1092
#define YYPARSE_PARAM_DECL
 
1093
#else   /* ! ANSI-C/C++ */
 
1094
#define YYPARSE_PARAM_ARG
 
1095
#define YYPARSE_PARAM_DECL
 
1096
#endif  /* ANSI-C/C++ */
 
1097
#else   /* YYPARSE_PARAM */
 
1098
#ifndef YYPARSE_PARAM_TYPE
 
1099
#define YYPARSE_PARAM_TYPE void *
 
1100
#endif
 
1101
#if defined(__cplusplus) || __STDC__
 
1102
#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
 
1103
#define YYPARSE_PARAM_DECL
 
1104
#else   /* ! ANSI-C/C++ */
 
1105
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
 
1106
#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
 
1107
#endif  /* ANSI-C/C++ */
 
1108
#endif  /* ! YYPARSE_PARAM */
 
1109
 
 
1110
int
 
1111
yyparse (YYPARSE_PARAM_ARG)
 
1112
    YYPARSE_PARAM_DECL
 
1113
{
 
1114
    register int yym, yyn, yystate;
 
1115
#if YYDEBUG
 
1116
    register const char *yys;
 
1117
 
 
1118
    if ((yys = getenv("YYDEBUG")))
 
1119
    {
 
1120
        yyn = *yys;
 
1121
        if (yyn >= '0' && yyn <= '9')
 
1122
            yydebug = yyn - '0';
 
1123
    }
 
1124
#endif
 
1125
 
 
1126
    yynerrs = 0;
 
1127
    yyerrflag = 0;
 
1128
    yychar = (-1);
 
1129
 
 
1130
    if (yyss == NULL && yygrowstack()) goto yyoverflow;
 
1131
    yyssp = yyss;
 
1132
    yyvsp = yyvs;
 
1133
    *yyssp = yystate = 0;
 
1134
 
 
1135
yyloop:
 
1136
    if ((yyn = yydefred[yystate])) goto yyreduce;
 
1137
    if (yychar < 0)
 
1138
    {
 
1139
        if ((yychar = yylex()) < 0) yychar = 0;
 
1140
#if YYDEBUG
 
1141
        if (yydebug)
 
1142
        {
 
1143
            yys = 0;
 
1144
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
 
1145
            if (!yys) yys = "illegal-symbol";
 
1146
            printf("%sdebug: state %d, reading %d (%s)\n",
 
1147
                    YYPREFIX, yystate, yychar, yys);
 
1148
        }
 
1149
#endif
 
1150
    }
 
1151
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
 
1152
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
 
1153
    {
 
1154
#if YYDEBUG
 
1155
        if (yydebug)
 
1156
            printf("%sdebug: state %d, shifting to state %d\n",
 
1157
                    YYPREFIX, yystate, yytable[yyn]);
 
1158
#endif
 
1159
        if (yyssp >= yysslim && yygrowstack())
 
1160
        {
 
1161
            goto yyoverflow;
 
1162
        }
 
1163
        *++yyssp = yystate = yytable[yyn];
 
1164
        *++yyvsp = yylval;
 
1165
        yychar = (-1);
 
1166
        if (yyerrflag > 0)  --yyerrflag;
 
1167
        goto yyloop;
 
1168
    }
 
1169
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
 
1170
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
 
1171
    {
 
1172
        yyn = yytable[yyn];
 
1173
        goto yyreduce;
 
1174
    }
 
1175
    if (yyerrflag) goto yyinrecovery;
 
1176
#if defined(lint) || defined(__GNUC__)
 
1177
    goto yynewerror;
 
1178
#endif
 
1179
yynewerror:
 
1180
    yyerror("syntax error");
 
1181
#if defined(lint) || defined(__GNUC__)
 
1182
    goto yyerrlab;
 
1183
#endif
 
1184
yyerrlab:
 
1185
    ++yynerrs;
 
1186
yyinrecovery:
 
1187
    if (yyerrflag < 3)
 
1188
    {
 
1189
        yyerrflag = 3;
 
1190
        for (;;)
 
1191
        {
 
1192
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
 
1193
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
 
1194
            {
 
1195
#if YYDEBUG
 
1196
                if (yydebug)
 
1197
                    printf("%sdebug: state %d, error recovery shifting\
 
1198
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
 
1199
#endif
 
1200
                if (yyssp >= yysslim && yygrowstack())
 
1201
                {
 
1202
                    goto yyoverflow;
 
1203
                }
 
1204
                *++yyssp = yystate = yytable[yyn];
 
1205
                *++yyvsp = yylval;
 
1206
                goto yyloop;
 
1207
            }
 
1208
            else
 
1209
            {
 
1210
#if YYDEBUG
 
1211
                if (yydebug)
 
1212
                    printf("%sdebug: error recovery discarding state %d\n",
 
1213
                            YYPREFIX, *yyssp);
 
1214
#endif
 
1215
                if (yyssp <= yyss) goto yyabort;
 
1216
                --yyssp;
 
1217
                --yyvsp;
 
1218
            }
 
1219
        }
 
1220
    }
 
1221
    else
 
1222
    {
 
1223
        if (yychar == 0) goto yyabort;
 
1224
#if YYDEBUG
 
1225
        if (yydebug)
 
1226
        {
 
1227
            yys = 0;
 
1228
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
 
1229
            if (!yys) yys = "illegal-symbol";
 
1230
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
 
1231
                    YYPREFIX, yystate, yychar, yys);
 
1232
        }
 
1233
#endif
 
1234
        yychar = (-1);
 
1235
        goto yyloop;
 
1236
    }
 
1237
yyreduce:
 
1238
#if YYDEBUG
 
1239
    if (yydebug)
 
1240
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
 
1241
                YYPREFIX, yystate, yyn, yyrule[yyn]);
 
1242
#endif
 
1243
    yym = yylen[yyn];
 
1244
    yyval = yyvsp[1-yym];
 
1245
    switch (yyn)
 
1246
    {
 
1247
case 3:
 
1248
#line 202 "./getdate.y"
 
1249
{
 
1250
            yyHaveTime++;
 
1251
        }
 
1252
break;
 
1253
case 4:
 
1254
#line 205 "./getdate.y"
 
1255
{
 
1256
            yyHaveZone++;
 
1257
        }
 
1258
break;
 
1259
case 5:
 
1260
#line 208 "./getdate.y"
 
1261
{
 
1262
            yyHaveDate++;
 
1263
        }
 
1264
break;
 
1265
case 6:
 
1266
#line 211 "./getdate.y"
 
1267
{
 
1268
            yyHaveDay++;
 
1269
        }
 
1270
break;
 
1271
case 7:
 
1272
#line 214 "./getdate.y"
 
1273
{
 
1274
            yyHaveRel++;
 
1275
        }
 
1276
break;
 
1277
case 9:
 
1278
#line 220 "./getdate.y"
 
1279
{
 
1280
            yyHour = yyvsp[-1].Number;
 
1281
            yyMinutes = 0;
 
1282
            yySeconds = 0;
 
1283
            yyMeridian = yyvsp[0].Meridian;
 
1284
        }
 
1285
break;
 
1286
case 10:
 
1287
#line 226 "./getdate.y"
 
1288
{
 
1289
            yyHour = yyvsp[-3].Number;
 
1290
            yyMinutes = yyvsp[-1].Number;
 
1291
            yySeconds = 0;
 
1292
            yyMeridian = yyvsp[0].Meridian;
 
1293
        }
 
1294
break;
 
1295
case 11:
 
1296
#line 232 "./getdate.y"
 
1297
{
 
1298
            yyHour = yyvsp[-3].Number;
 
1299
            yyMinutes = yyvsp[-1].Number;
 
1300
            yyMeridian = MER24;
 
1301
            yyDSTmode = DSToff;
 
1302
            yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
 
1303
        }
 
1304
break;
 
1305
case 12:
 
1306
#line 239 "./getdate.y"
 
1307
{
 
1308
            yyHour = yyvsp[-5].Number;
 
1309
            yyMinutes = yyvsp[-3].Number;
 
1310
            yySeconds = yyvsp[-1].Number;
 
1311
            yyMeridian = yyvsp[0].Meridian;
 
1312
        }
 
1313
break;
 
1314
case 13:
 
1315
#line 245 "./getdate.y"
 
1316
{
 
1317
            yyHour = yyvsp[-5].Number;
 
1318
            yyMinutes = yyvsp[-3].Number;
 
1319
            yySeconds = yyvsp[-1].Number;
 
1320
            yyMeridian = MER24;
 
1321
            yyDSTmode = DSToff;
 
1322
            yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
 
1323
        }
 
1324
break;
 
1325
case 14:
 
1326
#line 255 "./getdate.y"
 
1327
{
 
1328
            yyTimezone = yyvsp[0].Number;
 
1329
            yyDSTmode = DSToff;
 
1330
        }
 
1331
break;
 
1332
case 15:
 
1333
#line 259 "./getdate.y"
 
1334
{
 
1335
            yyTimezone = yyvsp[0].Number;
 
1336
            yyDSTmode = DSTon;
 
1337
        }
 
1338
break;
 
1339
case 16:
 
1340
#line 264 "./getdate.y"
 
1341
{
 
1342
            yyTimezone = yyvsp[-1].Number;
 
1343
            yyDSTmode = DSTon;
 
1344
        }
 
1345
break;
 
1346
case 17:
 
1347
#line 270 "./getdate.y"
 
1348
{
 
1349
            yyDayOrdinal = 1;
 
1350
            yyDayNumber = yyvsp[0].Number;
 
1351
        }
 
1352
break;
 
1353
case 18:
 
1354
#line 274 "./getdate.y"
 
1355
{
 
1356
            yyDayOrdinal = 1;
 
1357
            yyDayNumber = yyvsp[-1].Number;
 
1358
        }
 
1359
break;
 
1360
case 19:
 
1361
#line 278 "./getdate.y"
 
1362
{
 
1363
            yyDayOrdinal = yyvsp[-1].Number;
 
1364
            yyDayNumber = yyvsp[0].Number;
 
1365
        }
 
1366
break;
 
1367
case 20:
 
1368
#line 284 "./getdate.y"
 
1369
{
 
1370
            yyMonth = yyvsp[-2].Number;
 
1371
            yyDay = yyvsp[0].Number;
 
1372
        }
 
1373
break;
 
1374
case 21:
 
1375
#line 288 "./getdate.y"
 
1376
{
 
1377
            if (yyvsp[-4].Number >= 100) {
 
1378
                yyYear = yyvsp[-4].Number;
 
1379
                yyMonth = yyvsp[-2].Number;
 
1380
                yyDay = yyvsp[0].Number;
 
1381
            } else {
 
1382
                yyMonth = yyvsp[-4].Number;
 
1383
                yyDay = yyvsp[-2].Number;
 
1384
                yyYear = yyvsp[0].Number;
 
1385
            }
 
1386
        }
 
1387
break;
 
1388
case 22:
 
1389
#line 299 "./getdate.y"
 
1390
{
 
1391
            /* ISO 8601 format.  yyyy-mm-dd.  */
 
1392
            yyYear = yyvsp[-2].Number;
 
1393
            yyMonth = -yyvsp[-1].Number;
 
1394
            yyDay = -yyvsp[0].Number;
 
1395
        }
 
1396
break;
 
1397
case 23:
 
1398
#line 305 "./getdate.y"
 
1399
{
 
1400
            /* e.g. 17-JUN-1992.  */
 
1401
            yyDay = yyvsp[-2].Number;
 
1402
            yyMonth = yyvsp[-1].Number;
 
1403
            yyYear = -yyvsp[0].Number;
 
1404
        }
 
1405
break;
 
1406
case 24:
 
1407
#line 311 "./getdate.y"
 
1408
{
 
1409
            yyMonth = yyvsp[-1].Number;
 
1410
            yyDay = yyvsp[0].Number;
 
1411
        }
 
1412
break;
 
1413
case 25:
 
1414
#line 315 "./getdate.y"
 
1415
{
 
1416
            yyMonth = yyvsp[-3].Number;
 
1417
            yyDay = yyvsp[-2].Number;
 
1418
            yyYear = yyvsp[0].Number;
 
1419
        }
 
1420
break;
 
1421
case 26:
 
1422
#line 320 "./getdate.y"
 
1423
{
 
1424
            yyMonth = yyvsp[0].Number;
 
1425
            yyDay = yyvsp[-1].Number;
 
1426
        }
 
1427
break;
 
1428
case 27:
 
1429
#line 324 "./getdate.y"
 
1430
{
 
1431
            yyMonth = yyvsp[-1].Number;
 
1432
            yyDay = yyvsp[-2].Number;
 
1433
            yyYear = yyvsp[0].Number;
 
1434
        }
 
1435
break;
 
1436
case 28:
 
1437
#line 331 "./getdate.y"
 
1438
{
 
1439
            yyRelSeconds = -yyRelSeconds;
 
1440
            yyRelMonth = -yyRelMonth;
 
1441
        }
 
1442
break;
 
1443
case 30:
 
1444
#line 338 "./getdate.y"
 
1445
{
 
1446
            yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L;
 
1447
        }
 
1448
break;
 
1449
case 31:
 
1450
#line 341 "./getdate.y"
 
1451
{
 
1452
            yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L;
 
1453
        }
 
1454
break;
 
1455
case 32:
 
1456
#line 344 "./getdate.y"
 
1457
{
 
1458
            yyRelSeconds += yyvsp[0].Number * 60L;
 
1459
        }
 
1460
break;
 
1461
case 33:
 
1462
#line 347 "./getdate.y"
 
1463
{
 
1464
            yyRelSeconds += yyvsp[-1].Number;
 
1465
        }
 
1466
break;
 
1467
case 34:
 
1468
#line 350 "./getdate.y"
 
1469
{
 
1470
            yyRelSeconds += yyvsp[-1].Number;
 
1471
        }
 
1472
break;
 
1473
case 35:
 
1474
#line 353 "./getdate.y"
 
1475
{
 
1476
            yyRelSeconds++;
 
1477
        }
 
1478
break;
 
1479
case 36:
 
1480
#line 356 "./getdate.y"
 
1481
{
 
1482
            yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
 
1483
        }
 
1484
break;
 
1485
case 37:
 
1486
#line 359 "./getdate.y"
 
1487
{
 
1488
            yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
 
1489
        }
 
1490
break;
 
1491
case 38:
 
1492
#line 362 "./getdate.y"
 
1493
{
 
1494
            yyRelMonth += yyvsp[0].Number;
 
1495
        }
 
1496
break;
 
1497
case 39:
 
1498
#line 367 "./getdate.y"
 
1499
{
 
1500
            if (yyHaveTime && yyHaveDate && !yyHaveRel)
 
1501
                yyYear = yyvsp[0].Number;
 
1502
            else {
 
1503
                if(yyvsp[0].Number>10000) {
 
1504
                    yyHaveDate++;
 
1505
                    yyDay= (yyvsp[0].Number)%100;
 
1506
                    yyMonth= (yyvsp[0].Number/100)%100;
 
1507
                    yyYear = yyvsp[0].Number/10000;
 
1508
                }
 
1509
                else {
 
1510
                    yyHaveTime++;
 
1511
                    if (yyvsp[0].Number < 100) {
 
1512
                        yyHour = yyvsp[0].Number;
 
1513
                        yyMinutes = 0;
 
1514
                    }
 
1515
                    else {
 
1516
                        yyHour = yyvsp[0].Number / 100;
 
1517
                        yyMinutes = yyvsp[0].Number % 100;
 
1518
                    }
 
1519
                    yySeconds = 0;
 
1520
                    yyMeridian = MER24;
 
1521
                }
 
1522
            }
 
1523
        }
 
1524
break;
 
1525
case 40:
 
1526
#line 394 "./getdate.y"
 
1527
{
 
1528
            yyval.Meridian = MER24;
 
1529
        }
 
1530
break;
 
1531
case 41:
 
1532
#line 397 "./getdate.y"
 
1533
{
 
1534
            yyval.Meridian = yyvsp[0].Meridian;
 
1535
        }
 
1536
break;
 
1537
#line 1535 "getdate.c"
 
1538
    }
 
1539
    yyssp -= yym;
 
1540
    yystate = *yyssp;
 
1541
    yyvsp -= yym;
 
1542
    yym = yylhs[yyn];
 
1543
    if (yystate == 0 && yym == 0)
 
1544
    {
 
1545
#if YYDEBUG
 
1546
        if (yydebug)
 
1547
            printf("%sdebug: after reduction, shifting from state 0 to\
 
1548
 state %d\n", YYPREFIX, YYFINAL);
 
1549
#endif
 
1550
        yystate = YYFINAL;
 
1551
        *++yyssp = YYFINAL;
 
1552
        *++yyvsp = yyval;
 
1553
        if (yychar < 0)
 
1554
        {
 
1555
            if ((yychar = yylex()) < 0) yychar = 0;
 
1556
#if YYDEBUG
 
1557
            if (yydebug)
 
1558
            {
 
1559
                yys = 0;
 
1560
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
 
1561
                if (!yys) yys = "illegal-symbol";
 
1562
                printf("%sdebug: state %d, reading %d (%s)\n",
 
1563
                        YYPREFIX, YYFINAL, yychar, yys);
 
1564
            }
 
1565
#endif
 
1566
        }
 
1567
        if (yychar == 0) goto yyaccept;
 
1568
        goto yyloop;
 
1569
    }
 
1570
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
 
1571
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
 
1572
        yystate = yytable[yyn];
 
1573
    else
 
1574
        yystate = yydgoto[yym];
 
1575
#if YYDEBUG
 
1576
    if (yydebug)
 
1577
        printf("%sdebug: after reduction, shifting from state %d \
 
1578
to state %d\n", YYPREFIX, *yyssp, yystate);
 
1579
#endif
 
1580
    if (yyssp >= yysslim && yygrowstack())
 
1581
    {
 
1582
        goto yyoverflow;
 
1583
    }
 
1584
    *++yyssp = yystate;
 
1585
    *++yyvsp = yyval;
 
1586
    goto yyloop;
 
1587
yyoverflow:
 
1588
    yyerror("yacc stack overflow");
 
1589
yyabort:
 
1590
    return (1);
 
1591
yyaccept:
 
1592
    return (0);
 
1593
}
 
1594
/*@=readonlytrans =modunconnomods @*/
 
1595
/*@=retvalint =usedef =varuse =nullderef =nullassign @*/
 
1596
/*@=globstate =statictrans =unqualifiedtrans =noparams @*/