~ubuntu-branches/ubuntu/wily/libuser/wily

« back to all changes in this revision

Viewing changes to lib/getdate.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Habouzit
  • Date: 2006-09-03 21:58:15 UTC
  • mto: (2.1.1 edgy) (1.1.5 upstream) (3.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060903215815-rtvvfzhaer8ymyp4
Tags: upstream-0.54.6-2.1.dfsg.1
ImportĀ upstreamĀ versionĀ 0.54.6-2.1.dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* A Bison parser, made by GNU Bison 2.1.  */
 
2
 
 
3
/* Skeleton parser for Yacc-like parsing with Bison,
 
4
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
5
 
 
6
   This program is free software; you can redistribute it and/or modify
 
7
   it under the terms of the GNU General Public License as published by
 
8
   the Free Software Foundation; either version 2, or (at your option)
 
9
   any later version.
 
10
 
 
11
   This program is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
   GNU General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU General Public License
 
17
   along with this program; if not, write to the Free Software
 
18
   Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
   Boston, MA 02110-1301, USA.  */
 
20
 
 
21
/* As a special exception, when this file is copied by Bison into a
 
22
   Bison output file, you may use that output file without restriction.
 
23
   This special exception was added by the Free Software Foundation
 
24
   in version 1.24 of Bison.  */
 
25
 
 
26
/* Written by Richard Stallman by simplifying the original so called
 
27
   ``semantic'' parser.  */
 
28
 
 
29
/* All symbols defined below should begin with yy or YY, to avoid
 
30
   infringing on user name space.  This should be done even for local
 
31
   variables, as they might otherwise be expanded by user macros.
 
32
   There are some unavoidable exceptions within include files to
 
33
   define necessary library symbols; they are noted "INFRINGES ON
 
34
   USER NAME SPACE" below.  */
 
35
 
 
36
/* Identify Bison output.  */
 
37
#define YYBISON 1
 
38
 
 
39
/* Bison version.  */
 
40
#define YYBISON_VERSION "2.1"
 
41
 
 
42
/* Skeleton name.  */
 
43
#define YYSKELETON_NAME "yacc.c"
 
44
 
 
45
/* Pure parsers.  */
 
46
#define YYPURE 1
 
47
 
 
48
/* Using locations.  */
 
49
#define YYLSP_NEEDED 0
 
50
 
 
51
/* Substitute the variable and function names.  */
 
52
#define yyparse lu_gdparse
 
53
#define yylex   lu_gdlex
 
54
#define yyerror lu_gderror
 
55
#define yylval  lu_gdlval
 
56
#define yychar  lu_gdchar
 
57
#define yydebug lu_gddebug
 
58
#define yynerrs lu_gdnerrs
 
59
 
 
60
 
 
61
/* Tokens.  */
 
62
#ifndef YYTOKENTYPE
 
63
# define YYTOKENTYPE
 
64
   /* Put the tokens into the symbol table, so that GDB and other debuggers
 
65
      know about them.  */
 
66
   enum yytokentype {
 
67
     tAGO = 258,
 
68
     tDAY = 259,
 
69
     tDAY_UNIT = 260,
 
70
     tDAYZONE = 261,
 
71
     tDST = 262,
 
72
     tHOUR_UNIT = 263,
 
73
     tID = 264,
 
74
     tMERIDIAN = 265,
 
75
     tMINUTE_UNIT = 266,
 
76
     tMONTH = 267,
 
77
     tMONTH_UNIT = 268,
 
78
     tSEC_UNIT = 269,
 
79
     tSNUMBER = 270,
 
80
     tUNUMBER = 271,
 
81
     tYEAR_UNIT = 272,
 
82
     tZONE = 273
 
83
   };
 
84
#endif
 
85
/* Tokens.  */
 
86
#define tAGO 258
 
87
#define tDAY 259
 
88
#define tDAY_UNIT 260
 
89
#define tDAYZONE 261
 
90
#define tDST 262
 
91
#define tHOUR_UNIT 263
 
92
#define tID 264
 
93
#define tMERIDIAN 265
 
94
#define tMINUTE_UNIT 266
 
95
#define tMONTH 267
 
96
#define tMONTH_UNIT 268
 
97
#define tSEC_UNIT 269
 
98
#define tSNUMBER 270
 
99
#define tUNUMBER 271
 
100
#define tYEAR_UNIT 272
 
101
#define tZONE 273
 
102
 
 
103
 
 
104
 
 
105
 
 
106
/* Copy the first part of user declarations.  */
 
107
#line 1 "lib/getdate.y"
 
108
 
 
109
/*
 
110
**  Originally written by Steven M. Bellovin <smb@research.att.com> while
 
111
**  at the University of North Carolina at Chapel Hill.  Later tweaked by
 
112
**  a couple of people on Usenet.  Completely overhauled by Rich $alz
 
113
**  <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
 
114
**
 
115
**  This grammar has 13 shift/reduce conflicts.
 
116
**
 
117
**  This code is in the public domain and has no copyright.
 
118
*/
 
119
 
 
120
#ifdef HAVE_CONFIG_H
 
121
# include <config.h>
 
122
#endif
 
123
 
 
124
/* Since the code of getdate.y is not included in the Emacs executable
 
125
   itself, there is no need to #define static in this file.  Even if
 
126
   the code were included in the Emacs executable, it probably
 
127
   wouldn't do any harm to #undef it here; this will only cause
 
128
   problems if we try to write to a static variable, which I don't
 
129
   think this code needs to do.  */
 
130
#ifdef emacs
 
131
# undef static
 
132
#endif
 
133
 
 
134
#include <stdio.h>
 
135
#include <stdlib.h>
 
136
#include <ctype.h>
 
137
#include <time.h>
 
138
#include <string.h>
 
139
 
 
140
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
 
141
 
 
142
#include "lib/internal.h"
 
143
 
 
144
#define EPOCH           1970
 
145
#define HOUR(x)         ((x) * 60)
 
146
 
 
147
#define MAX_BUFF_LEN    128   /* size of buffer to read the date into */
 
148
 
 
149
/*
 
150
**  An entry in the lexical lookup table.
 
151
*/
 
152
typedef struct _TABLE {
 
153
    const char  *name;
 
154
    int         type;
 
155
    int         value;
 
156
} TABLE;
 
157
 
 
158
 
 
159
/*
 
160
**  Meridian:  am, pm, or 24-hour style.
 
161
*/
 
162
typedef enum _MERIDIAN {
 
163
    MERam, MERpm, MER24
 
164
} MERIDIAN;
 
165
 
 
166
struct global {
 
167
  int   DayOrdinal;
 
168
  int   DayNumber;
 
169
  int   HaveDate;
 
170
  int   HaveDay;
 
171
  int   HaveRel;
 
172
  int   HaveTime;
 
173
  int   HaveZone;
 
174
  int   Timezone;
 
175
  int   Day;
 
176
  int   Hour;
 
177
  int   Minutes;
 
178
  int   Month;
 
179
  int   Seconds;
 
180
  int   Year;
 
181
  MERIDIAN      Meridian;
 
182
  int   RelDay;
 
183
  int   RelHour;
 
184
  int   RelMinutes;
 
185
  int   RelMonth;
 
186
  int   RelSeconds;
 
187
  int   RelYear;
 
188
};
 
189
 
 
190
union YYSTYPE;
 
191
static int yylex (union YYSTYPE *lvalp, const char **yyInput);
 
192
static int yyerror (const char **yyInput, struct global *yy, char *s);
 
193
static int yyparse (const char **yyInput, struct global *yy);
 
194
 
 
195
#define YYENABLE_NLS 0
 
196
#define YYLTYPE_IS_TRIVIAL 0
 
197
 
 
198
 
 
199
 
 
200
/* Enabling traces.  */
 
201
#ifndef YYDEBUG
 
202
# define YYDEBUG 0
 
203
#endif
 
204
 
 
205
/* Enabling verbose error messages.  */
 
206
#ifdef YYERROR_VERBOSE
 
207
# undef YYERROR_VERBOSE
 
208
# define YYERROR_VERBOSE 1
 
209
#else
 
210
# define YYERROR_VERBOSE 0
 
211
#endif
 
212
 
 
213
/* Enabling the token table.  */
 
214
#ifndef YYTOKEN_TABLE
 
215
# define YYTOKEN_TABLE 0
 
216
#endif
 
217
 
 
218
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 
219
#line 100 "lib/getdate.y"
 
220
typedef union YYSTYPE {
 
221
    int                 Number;
 
222
    enum _MERIDIAN      Meridian;
 
223
} YYSTYPE;
 
224
/* Line 196 of yacc.c.  */
 
225
#line 226 "lib/getdate.c"
 
226
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
 
227
# define YYSTYPE_IS_DECLARED 1
 
228
# define YYSTYPE_IS_TRIVIAL 1
 
229
#endif
 
230
 
 
231
 
 
232
 
 
233
/* Copy the second part of user declarations.  */
 
234
 
 
235
 
 
236
/* Line 219 of yacc.c.  */
 
237
#line 238 "lib/getdate.c"
 
238
 
 
239
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
 
240
# define YYSIZE_T __SIZE_TYPE__
 
241
#endif
 
242
#if ! defined (YYSIZE_T) && defined (size_t)
 
243
# define YYSIZE_T size_t
 
244
#endif
 
245
#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
 
246
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 
247
# define YYSIZE_T size_t
 
248
#endif
 
249
#if ! defined (YYSIZE_T)
 
250
# define YYSIZE_T unsigned int
 
251
#endif
 
252
 
 
253
#ifndef YY_
 
254
# if YYENABLE_NLS
 
255
#  if ENABLE_NLS
 
256
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
 
257
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
 
258
#  endif
 
259
# endif
 
260
# ifndef YY_
 
261
#  define YY_(msgid) msgid
 
262
# endif
 
263
#endif
 
264
 
 
265
#if ! defined (yyoverflow) || YYERROR_VERBOSE
 
266
 
 
267
/* The parser invokes alloca or malloc; define the necessary symbols.  */
 
268
 
 
269
# ifdef YYSTACK_USE_ALLOCA
 
270
#  if YYSTACK_USE_ALLOCA
 
271
#   ifdef __GNUC__
 
272
#    define YYSTACK_ALLOC __builtin_alloca
 
273
#   else
 
274
#    define YYSTACK_ALLOC alloca
 
275
#    if defined (__STDC__) || defined (__cplusplus)
 
276
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 
277
#     define YYINCLUDED_STDLIB_H
 
278
#    endif
 
279
#   endif
 
280
#  endif
 
281
# endif
 
282
 
 
283
# ifdef YYSTACK_ALLOC
 
284
   /* Pacify GCC's `empty if-body' warning. */
 
285
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
 
286
#  ifndef YYSTACK_ALLOC_MAXIMUM
 
287
    /* The OS might guarantee only one guard page at the bottom of the stack,
 
288
       and a page size can be as small as 4096 bytes.  So we cannot safely
 
289
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
 
290
       to allow for a few compiler-allocated temporary stack slots.  */
 
291
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
 
292
#  endif
 
293
# else
 
294
#  define YYSTACK_ALLOC YYMALLOC
 
295
#  define YYSTACK_FREE YYFREE
 
296
#  ifndef YYSTACK_ALLOC_MAXIMUM
 
297
#   define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
 
298
#  endif
 
299
#  ifdef __cplusplus
 
300
extern "C" {
 
301
#  endif
 
302
#  ifndef YYMALLOC
 
303
#   define YYMALLOC malloc
 
304
#   if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
 
305
        && (defined (__STDC__) || defined (__cplusplus)))
 
306
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
 
307
#   endif
 
308
#  endif
 
309
#  ifndef YYFREE
 
310
#   define YYFREE free
 
311
#   if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
 
312
        && (defined (__STDC__) || defined (__cplusplus)))
 
313
void free (void *); /* INFRINGES ON USER NAME SPACE */
 
314
#   endif
 
315
#  endif
 
316
#  ifdef __cplusplus
 
317
}
 
318
#  endif
 
319
# endif
 
320
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
 
321
 
 
322
 
 
323
#if (! defined (yyoverflow) \
 
324
     && (! defined (__cplusplus) \
 
325
         || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
 
326
 
 
327
/* A type that is properly aligned for any stack member.  */
 
328
union yyalloc
 
329
{
 
330
  short int yyss;
 
331
  YYSTYPE yyvs;
 
332
  };
 
333
 
 
334
/* The size of the maximum gap between one aligned stack and the next.  */
 
335
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
 
336
 
 
337
/* The size of an array large to enough to hold all stacks, each with
 
338
   N elements.  */
 
339
# define YYSTACK_BYTES(N) \
 
340
     ((N) * (sizeof (short int) + sizeof (YYSTYPE))                     \
 
341
      + YYSTACK_GAP_MAXIMUM)
 
342
 
 
343
/* Copy COUNT objects from FROM to TO.  The source and destination do
 
344
   not overlap.  */
 
345
# ifndef YYCOPY
 
346
#  if defined (__GNUC__) && 1 < __GNUC__
 
347
#   define YYCOPY(To, From, Count) \
 
348
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
 
349
#  else
 
350
#   define YYCOPY(To, From, Count)              \
 
351
      do                                        \
 
352
        {                                       \
 
353
          YYSIZE_T yyi;                         \
 
354
          for (yyi = 0; yyi < (Count); yyi++)   \
 
355
            (To)[yyi] = (From)[yyi];            \
 
356
        }                                       \
 
357
      while (0)
 
358
#  endif
 
359
# endif
 
360
 
 
361
/* Relocate STACK from its old location to the new one.  The
 
362
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
 
363
   elements in the stack, and YYPTR gives the new location of the
 
364
   stack.  Advance YYPTR to a properly aligned location for the next
 
365
   stack.  */
 
366
# define YYSTACK_RELOCATE(Stack)                                        \
 
367
    do                                                                  \
 
368
      {                                                                 \
 
369
        YYSIZE_T yynewbytes;                                            \
 
370
        YYCOPY (&yyptr->Stack, Stack, yysize);                          \
 
371
        Stack = &yyptr->Stack;                                          \
 
372
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
 
373
        yyptr += yynewbytes / sizeof (*yyptr);                          \
 
374
      }                                                                 \
 
375
    while (0)
 
376
 
 
377
#endif
 
378
 
 
379
#if defined (__STDC__) || defined (__cplusplus)
 
380
   typedef signed char yysigned_char;
 
381
#else
 
382
   typedef short int yysigned_char;
 
383
#endif
 
384
 
 
385
/* YYFINAL -- State number of the termination state. */
 
386
#define YYFINAL  2
 
387
/* YYLAST -- Last index in YYTABLE.  */
 
388
#define YYLAST   50
 
389
 
 
390
/* YYNTOKENS -- Number of terminals. */
 
391
#define YYNTOKENS  22
 
392
/* YYNNTS -- Number of nonterminals. */
 
393
#define YYNNTS  11
 
394
/* YYNRULES -- Number of rules. */
 
395
#define YYNRULES  51
 
396
/* YYNRULES -- Number of states. */
 
397
#define YYNSTATES  61
 
398
 
 
399
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 
400
#define YYUNDEFTOK  2
 
401
#define YYMAXUTOK   273
 
402
 
 
403
#define YYTRANSLATE(YYX)                                                \
 
404
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
405
 
 
406
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
 
407
static const unsigned char yytranslate[] =
 
408
{
 
409
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
410
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
411
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
412
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
413
       2,     2,     2,     2,    20,     2,     2,    21,     2,     2,
 
414
       2,     2,     2,     2,     2,     2,     2,     2,    19,     2,
 
415
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
416
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
417
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
418
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
419
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
420
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
421
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
422
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
423
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
424
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
425
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
426
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
427
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
428
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
429
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
430
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
431
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
432
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
433
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
434
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
 
435
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
 
436
      15,    16,    17,    18
 
437
};
 
438
 
 
439
#if YYDEBUG
 
440
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
 
441
   YYRHS.  */
 
442
static const unsigned char yyprhs[] =
 
443
{
 
444
       0,     0,     3,     4,     7,     9,    11,    13,    15,    17,
 
445
      19,    22,    27,    32,    39,    46,    48,    50,    53,    55,
 
446
      58,    61,    65,    71,    75,    79,    82,    87,    90,    94,
 
447
      97,    99,   102,   105,   107,   110,   113,   115,   118,   121,
 
448
     123,   126,   129,   131,   134,   137,   139,   142,   145,   147,
 
449
     149,   150
 
450
};
 
451
 
 
452
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
 
453
static const yysigned_char yyrhs[] =
 
454
{
 
455
      23,     0,    -1,    -1,    23,    24,    -1,    25,    -1,    26,
 
456
      -1,    28,    -1,    27,    -1,    29,    -1,    31,    -1,    16,
 
457
      10,    -1,    16,    19,    16,    32,    -1,    16,    19,    16,
 
458
      15,    -1,    16,    19,    16,    19,    16,    32,    -1,    16,
 
459
      19,    16,    19,    16,    15,    -1,    18,    -1,     6,    -1,
 
460
      18,     7,    -1,     4,    -1,     4,    20,    -1,    16,     4,
 
461
      -1,    16,    21,    16,    -1,    16,    21,    16,    21,    16,
 
462
      -1,    16,    15,    15,    -1,    16,    12,    15,    -1,    12,
 
463
      16,    -1,    12,    16,    20,    16,    -1,    16,    12,    -1,
 
464
      16,    12,    16,    -1,    30,     3,    -1,    30,    -1,    16,
 
465
      17,    -1,    15,    17,    -1,    17,    -1,    16,    13,    -1,
 
466
      15,    13,    -1,    13,    -1,    16,     5,    -1,    15,     5,
 
467
      -1,     5,    -1,    16,     8,    -1,    15,     8,    -1,     8,
 
468
      -1,    16,    11,    -1,    15,    11,    -1,    11,    -1,    16,
 
469
      14,    -1,    15,    14,    -1,    14,    -1,    16,    -1,    -1,
 
470
      10,    -1
 
471
};
 
472
 
 
473
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 
474
static const unsigned short int yyrline[] =
 
475
{
 
476
       0,   118,   118,   119,   122,   125,   128,   131,   134,   137,
 
477
     140,   146,   152,   161,   167,   179,   182,   186,   191,   195,
 
478
     199,   205,   209,   227,   233,   239,   243,   248,   252,   259,
 
479
     267,   270,   273,   276,   279,   282,   285,   288,   291,   294,
 
480
     297,   300,   303,   306,   309,   312,   315,   318,   321,   326,
 
481
     360,   363
 
482
};
 
483
#endif
 
484
 
 
485
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
 
486
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
 
487
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
 
488
static const char *const yytname[] =
 
489
{
 
490
  "$end", "error", "$undefined", "tAGO", "tDAY", "tDAY_UNIT", "tDAYZONE",
 
491
  "tDST", "tHOUR_UNIT", "tID", "tMERIDIAN", "tMINUTE_UNIT", "tMONTH",
 
492
  "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tYEAR_UNIT",
 
493
  "tZONE", "':'", "','", "'/'", "$accept", "spec", "item", "time", "zone",
 
494
  "day", "date", "rel", "relunit", "number", "o_merid", 0
 
495
};
 
496
#endif
 
497
 
 
498
# ifdef YYPRINT
 
499
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
 
500
   token YYLEX-NUM.  */
 
501
static const unsigned short int yytoknum[] =
 
502
{
 
503
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
 
504
     265,   266,   267,   268,   269,   270,   271,   272,   273,    58,
 
505
      44,    47
 
506
};
 
507
# endif
 
508
 
 
509
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 
510
static const unsigned char yyr1[] =
 
511
{
 
512
       0,    22,    23,    23,    24,    24,    24,    24,    24,    24,
 
513
      25,    25,    25,    25,    25,    26,    26,    26,    27,    27,
 
514
      27,    28,    28,    28,    28,    28,    28,    28,    28,    29,
 
515
      29,    30,    30,    30,    30,    30,    30,    30,    30,    30,
 
516
      30,    30,    30,    30,    30,    30,    30,    30,    30,    31,
 
517
      32,    32
 
518
};
 
519
 
 
520
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 
521
static const unsigned char yyr2[] =
 
522
{
 
523
       0,     2,     0,     2,     1,     1,     1,     1,     1,     1,
 
524
       2,     4,     4,     6,     6,     1,     1,     2,     1,     2,
 
525
       2,     3,     5,     3,     3,     2,     4,     2,     3,     2,
 
526
       1,     2,     2,     1,     2,     2,     1,     2,     2,     1,
 
527
       2,     2,     1,     2,     2,     1,     2,     2,     1,     1,
 
528
       0,     1
 
529
};
 
530
 
 
531
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
 
532
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
 
533
   means the default is an error.  */
 
534
static const unsigned char yydefact[] =
 
535
{
 
536
       2,     0,     1,    18,    39,    16,    42,    45,     0,    36,
 
537
      48,     0,    49,    33,    15,     3,     4,     5,     7,     6,
 
538
       8,    30,     9,    19,    25,    38,    41,    44,    35,    47,
 
539
      32,    20,    37,    40,    10,    43,    27,    34,    46,     0,
 
540
      31,     0,     0,    17,    29,     0,    24,    28,    23,    50,
 
541
      21,    26,    51,    12,     0,    11,     0,    50,    22,    14,
 
542
      13
 
543
};
 
544
 
 
545
/* YYDEFGOTO[NTERM-NUM]. */
 
546
static const yysigned_char yydefgoto[] =
 
547
{
 
548
      -1,     1,    15,    16,    17,    18,    19,    20,    21,    22,
 
549
      55
 
550
};
 
551
 
 
552
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 
553
   STATE-NUM.  */
 
554
#define YYPACT_NINF -20
 
555
static const yysigned_char yypact[] =
 
556
{
 
557
     -20,     0,   -20,   -19,   -20,   -20,   -20,   -20,   -13,   -20,
 
558
     -20,    30,    15,   -20,    14,   -20,   -20,   -20,   -20,   -20,
 
559
     -20,    19,   -20,   -20,     4,   -20,   -20,   -20,   -20,   -20,
 
560
     -20,   -20,   -20,   -20,   -20,   -20,    -6,   -20,   -20,    16,
 
561
     -20,    17,    23,   -20,   -20,    24,   -20,   -20,   -20,    27,
 
562
      28,   -20,   -20,   -20,    29,   -20,    32,    -8,   -20,   -20,
 
563
     -20
 
564
};
 
565
 
 
566
/* YYPGOTO[NTERM-NUM].  */
 
567
static const yysigned_char yypgoto[] =
 
568
{
 
569
     -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,
 
570
      -7
 
571
};
 
572
 
 
573
/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
 
574
   positive, shift that token.  If negative, reduce the rule which
 
575
   number is the opposite.  If zero, do what YYDEFACT says.
 
576
   If YYTABLE_NINF, syntax error.  */
 
577
#define YYTABLE_NINF -1
 
578
static const unsigned char yytable[] =
 
579
{
 
580
       2,    23,    52,    24,     3,     4,     5,    59,     6,    46,
 
581
      47,     7,     8,     9,    10,    11,    12,    13,    14,    31,
 
582
      32,    43,    44,    33,    45,    34,    35,    36,    37,    38,
 
583
      39,    48,    40,    49,    41,    25,    42,    52,    26,    50,
 
584
      51,    27,    53,    28,    29,    57,    54,    30,    58,    56,
 
585
      60
 
586
};
 
587
 
 
588
static const unsigned char yycheck[] =
 
589
{
 
590
       0,    20,    10,    16,     4,     5,     6,    15,     8,    15,
 
591
      16,    11,    12,    13,    14,    15,    16,    17,    18,     4,
 
592
       5,     7,     3,     8,    20,    10,    11,    12,    13,    14,
 
593
      15,    15,    17,    16,    19,     5,    21,    10,     8,    16,
 
594
      16,    11,    15,    13,    14,    16,    19,    17,    16,    21,
 
595
      57
 
596
};
 
597
 
 
598
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
 
599
   symbol of state STATE-NUM.  */
 
600
static const unsigned char yystos[] =
 
601
{
 
602
       0,    23,     0,     4,     5,     6,     8,    11,    12,    13,
 
603
      14,    15,    16,    17,    18,    24,    25,    26,    27,    28,
 
604
      29,    30,    31,    20,    16,     5,     8,    11,    13,    14,
 
605
      17,     4,     5,     8,    10,    11,    12,    13,    14,    15,
 
606
      17,    19,    21,     7,     3,    20,    15,    16,    15,    16,
 
607
      16,    16,    10,    15,    19,    32,    21,    16,    16,    15,
 
608
      32
 
609
};
 
610
 
 
611
#define yyerrok         (yyerrstatus = 0)
 
612
#define yyclearin       (yychar = YYEMPTY)
 
613
#define YYEMPTY         (-2)
 
614
#define YYEOF           0
 
615
 
 
616
#define YYACCEPT        goto yyacceptlab
 
617
#define YYABORT         goto yyabortlab
 
618
#define YYERROR         goto yyerrorlab
 
619
 
 
620
 
 
621
/* Like YYERROR except do call yyerror.  This remains here temporarily
 
622
   to ease the transition to the new meaning of YYERROR, for GCC.
 
623
   Once GCC version 2 has supplanted version 1, this can go.  */
 
624
 
 
625
#define YYFAIL          goto yyerrlab
 
626
 
 
627
#define YYRECOVERING()  (!!yyerrstatus)
 
628
 
 
629
#define YYBACKUP(Token, Value)                                  \
 
630
do                                                              \
 
631
  if (yychar == YYEMPTY && yylen == 1)                          \
 
632
    {                                                           \
 
633
      yychar = (Token);                                         \
 
634
      yylval = (Value);                                         \
 
635
      yytoken = YYTRANSLATE (yychar);                           \
 
636
      YYPOPSTACK;                                               \
 
637
      goto yybackup;                                            \
 
638
    }                                                           \
 
639
  else                                                          \
 
640
    {                                                           \
 
641
      yyerror (yyInput, yy, YY_("syntax error: cannot back up")); \
 
642
      YYERROR;                                                  \
 
643
    }                                                           \
 
644
while (0)
 
645
 
 
646
 
 
647
#define YYTERROR        1
 
648
#define YYERRCODE       256
 
649
 
 
650
 
 
651
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
 
652
   If N is 0, then set CURRENT to the empty location which ends
 
653
   the previous symbol: RHS[0] (always defined).  */
 
654
 
 
655
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
 
656
#ifndef YYLLOC_DEFAULT
 
657
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 
658
    do                                                                  \
 
659
      if (N)                                                            \
 
660
        {                                                               \
 
661
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 
662
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 
663
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 
664
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 
665
        }                                                               \
 
666
      else                                                              \
 
667
        {                                                               \
 
668
          (Current).first_line   = (Current).last_line   =              \
 
669
            YYRHSLOC (Rhs, 0).last_line;                                \
 
670
          (Current).first_column = (Current).last_column =              \
 
671
            YYRHSLOC (Rhs, 0).last_column;                              \
 
672
        }                                                               \
 
673
    while (0)
 
674
#endif
 
675
 
 
676
 
 
677
/* YY_LOCATION_PRINT -- Print the location on the stream.
 
678
   This macro was not mandated originally: define only if we know
 
679
   we won't break user code: when these are the locations we know.  */
 
680
 
 
681
#ifndef YY_LOCATION_PRINT
 
682
# if YYLTYPE_IS_TRIVIAL
 
683
#  define YY_LOCATION_PRINT(File, Loc)                  \
 
684
     fprintf (File, "%d.%d-%d.%d",                      \
 
685
              (Loc).first_line, (Loc).first_column,     \
 
686
              (Loc).last_line,  (Loc).last_column)
 
687
# else
 
688
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 
689
# endif
 
690
#endif
 
691
 
 
692
 
 
693
/* YYLEX -- calling `yylex' with the right arguments.  */
 
694
 
 
695
#ifdef YYLEX_PARAM
 
696
# define YYLEX yylex (&yylval, YYLEX_PARAM)
 
697
#else
 
698
# define YYLEX yylex (&yylval, yyInput)
 
699
#endif
 
700
 
 
701
/* Enable debugging if requested.  */
 
702
#if YYDEBUG
 
703
 
 
704
# ifndef YYFPRINTF
 
705
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
 
706
#  define YYFPRINTF fprintf
 
707
# endif
 
708
 
 
709
# define YYDPRINTF(Args)                        \
 
710
do {                                            \
 
711
  if (yydebug)                                  \
 
712
    YYFPRINTF Args;                             \
 
713
} while (0)
 
714
 
 
715
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)          \
 
716
do {                                                            \
 
717
  if (yydebug)                                                  \
 
718
    {                                                           \
 
719
      YYFPRINTF (stderr, "%s ", Title);                         \
 
720
      yysymprint (stderr,                                       \
 
721
                  Type, Value); \
 
722
      YYFPRINTF (stderr, "\n");                                 \
 
723
    }                                                           \
 
724
} while (0)
 
725
 
 
726
/*------------------------------------------------------------------.
 
727
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
 
728
| TOP (included).                                                   |
 
729
`------------------------------------------------------------------*/
 
730
 
 
731
#if defined (__STDC__) || defined (__cplusplus)
 
732
static void
 
733
yy_stack_print (short int *bottom, short int *top)
 
734
#else
 
735
static void
 
736
yy_stack_print (bottom, top)
 
737
    short int *bottom;
 
738
    short int *top;
 
739
#endif
 
740
{
 
741
  YYFPRINTF (stderr, "Stack now");
 
742
  for (/* Nothing. */; bottom <= top; ++bottom)
 
743
    YYFPRINTF (stderr, " %d", *bottom);
 
744
  YYFPRINTF (stderr, "\n");
 
745
}
 
746
 
 
747
# define YY_STACK_PRINT(Bottom, Top)                            \
 
748
do {                                                            \
 
749
  if (yydebug)                                                  \
 
750
    yy_stack_print ((Bottom), (Top));                           \
 
751
} while (0)
 
752
 
 
753
 
 
754
/*------------------------------------------------.
 
755
| Report that the YYRULE is going to be reduced.  |
 
756
`------------------------------------------------*/
 
757
 
 
758
#if defined (__STDC__) || defined (__cplusplus)
 
759
static void
 
760
yy_reduce_print (int yyrule)
 
761
#else
 
762
static void
 
763
yy_reduce_print (yyrule)
 
764
    int yyrule;
 
765
#endif
 
766
{
 
767
  int yyi;
 
768
  unsigned long int yylno = yyrline[yyrule];
 
769
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
 
770
             yyrule - 1, yylno);
 
771
  /* Print the symbols being reduced, and their result.  */
 
772
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
 
773
    YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
 
774
  YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
 
775
}
 
776
 
 
777
# define YY_REDUCE_PRINT(Rule)          \
 
778
do {                                    \
 
779
  if (yydebug)                          \
 
780
    yy_reduce_print (Rule);             \
 
781
} while (0)
 
782
 
 
783
/* Nonzero means print parse trace.  It is left uninitialized so that
 
784
   multiple parsers can coexist.  */
 
785
int yydebug;
 
786
#else /* !YYDEBUG */
 
787
# define YYDPRINTF(Args)
 
788
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
 
789
# define YY_STACK_PRINT(Bottom, Top)
 
790
# define YY_REDUCE_PRINT(Rule)
 
791
#endif /* !YYDEBUG */
 
792
 
 
793
 
 
794
/* YYINITDEPTH -- initial size of the parser's stacks.  */
 
795
#ifndef YYINITDEPTH
 
796
# define YYINITDEPTH 200
 
797
#endif
 
798
 
 
799
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
 
800
   if the built-in stack extension method is used).
 
801
 
 
802
   Do not make this value too large; the results are undefined if
 
803
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
 
804
   evaluated with infinite-precision integer arithmetic.  */
 
805
 
 
806
#ifndef YYMAXDEPTH
 
807
# define YYMAXDEPTH 10000
 
808
#endif
 
809
 
 
810
 
 
811
 
 
812
#if YYERROR_VERBOSE
 
813
 
 
814
# ifndef yystrlen
 
815
#  if defined (__GLIBC__) && defined (_STRING_H)
 
816
#   define yystrlen strlen
 
817
#  else
 
818
/* Return the length of YYSTR.  */
 
819
static YYSIZE_T
 
820
#   if defined (__STDC__) || defined (__cplusplus)
 
821
yystrlen (const char *yystr)
 
822
#   else
 
823
yystrlen (yystr)
 
824
     const char *yystr;
 
825
#   endif
 
826
{
 
827
  const char *yys = yystr;
 
828
 
 
829
  while (*yys++ != '\0')
 
830
    continue;
 
831
 
 
832
  return yys - yystr - 1;
 
833
}
 
834
#  endif
 
835
# endif
 
836
 
 
837
# ifndef yystpcpy
 
838
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
 
839
#   define yystpcpy stpcpy
 
840
#  else
 
841
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
 
842
   YYDEST.  */
 
843
static char *
 
844
#   if defined (__STDC__) || defined (__cplusplus)
 
845
yystpcpy (char *yydest, const char *yysrc)
 
846
#   else
 
847
yystpcpy (yydest, yysrc)
 
848
     char *yydest;
 
849
     const char *yysrc;
 
850
#   endif
 
851
{
 
852
  char *yyd = yydest;
 
853
  const char *yys = yysrc;
 
854
 
 
855
  while ((*yyd++ = *yys++) != '\0')
 
856
    continue;
 
857
 
 
858
  return yyd - 1;
 
859
}
 
860
#  endif
 
861
# endif
 
862
 
 
863
# ifndef yytnamerr
 
864
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
 
865
   quotes and backslashes, so that it's suitable for yyerror.  The
 
866
   heuristic is that double-quoting is unnecessary unless the string
 
867
   contains an apostrophe, a comma, or backslash (other than
 
868
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
 
869
   null, do not copy; instead, return the length of what the result
 
870
   would have been.  */
 
871
static YYSIZE_T
 
872
yytnamerr (char *yyres, const char *yystr)
 
873
{
 
874
  if (*yystr == '"')
 
875
    {
 
876
      size_t yyn = 0;
 
877
      char const *yyp = yystr;
 
878
 
 
879
      for (;;)
 
880
        switch (*++yyp)
 
881
          {
 
882
          case '\'':
 
883
          case ',':
 
884
            goto do_not_strip_quotes;
 
885
 
 
886
          case '\\':
 
887
            if (*++yyp != '\\')
 
888
              goto do_not_strip_quotes;
 
889
            /* Fall through.  */
 
890
          default:
 
891
            if (yyres)
 
892
              yyres[yyn] = *yyp;
 
893
            yyn++;
 
894
            break;
 
895
 
 
896
          case '"':
 
897
            if (yyres)
 
898
              yyres[yyn] = '\0';
 
899
            return yyn;
 
900
          }
 
901
    do_not_strip_quotes: ;
 
902
    }
 
903
 
 
904
  if (! yyres)
 
905
    return yystrlen (yystr);
 
906
 
 
907
  return yystpcpy (yyres, yystr) - yyres;
 
908
}
 
909
# endif
 
910
 
 
911
#endif /* YYERROR_VERBOSE */
 
912
 
 
913
 
 
914
 
 
915
#if YYDEBUG
 
916
/*--------------------------------.
 
917
| Print this symbol on YYOUTPUT.  |
 
918
`--------------------------------*/
 
919
 
 
920
#if defined (__STDC__) || defined (__cplusplus)
 
921
static void
 
922
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
 
923
#else
 
924
static void
 
925
yysymprint (yyoutput, yytype, yyvaluep)
 
926
    FILE *yyoutput;
 
927
    int yytype;
 
928
    YYSTYPE *yyvaluep;
 
929
#endif
 
930
{
 
931
  /* Pacify ``unused variable'' warnings.  */
 
932
  (void) yyvaluep;
 
933
 
 
934
  if (yytype < YYNTOKENS)
 
935
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
 
936
  else
 
937
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
938
 
 
939
 
 
940
# ifdef YYPRINT
 
941
  if (yytype < YYNTOKENS)
 
942
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 
943
# endif
 
944
  switch (yytype)
 
945
    {
 
946
      default:
 
947
        break;
 
948
    }
 
949
  YYFPRINTF (yyoutput, ")");
 
950
}
 
951
 
 
952
#endif /* ! YYDEBUG */
 
953
/*-----------------------------------------------.
 
954
| Release the memory associated to this symbol.  |
 
955
`-----------------------------------------------*/
 
956
 
 
957
#if defined (__STDC__) || defined (__cplusplus)
 
958
static void
 
959
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
 
960
#else
 
961
static void
 
962
yydestruct (yymsg, yytype, yyvaluep)
 
963
    const char *yymsg;
 
964
    int yytype;
 
965
    YYSTYPE *yyvaluep;
 
966
#endif
 
967
{
 
968
  /* Pacify ``unused variable'' warnings.  */
 
969
  (void) yyvaluep;
 
970
 
 
971
  if (!yymsg)
 
972
    yymsg = "Deleting";
 
973
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
 
974
 
 
975
  switch (yytype)
 
976
    {
 
977
 
 
978
      default:
 
979
        break;
 
980
    }
 
981
}
 
982
 
 
983
 
 
984
/* Prevent warnings from -Wmissing-prototypes.  */
 
985
 
 
986
#ifdef YYPARSE_PARAM
 
987
# if defined (__STDC__) || defined (__cplusplus)
 
988
int yyparse (void *YYPARSE_PARAM);
 
989
# else
 
990
int yyparse ();
 
991
# endif
 
992
#else /* ! YYPARSE_PARAM */
 
993
#if defined (__STDC__) || defined (__cplusplus)
 
994
int yyparse (const char **yyInput, struct global *yy);
 
995
#else
 
996
int yyparse ();
 
997
#endif
 
998
#endif /* ! YYPARSE_PARAM */
 
999
 
 
1000
 
 
1001
 
 
1002
 
 
1003
 
 
1004
 
 
1005
/*----------.
 
1006
| yyparse.  |
 
1007
`----------*/
 
1008
 
 
1009
#ifdef YYPARSE_PARAM
 
1010
# if defined (__STDC__) || defined (__cplusplus)
 
1011
int yyparse (void *YYPARSE_PARAM)
 
1012
# else
 
1013
int yyparse (YYPARSE_PARAM)
 
1014
  void *YYPARSE_PARAM;
 
1015
# endif
 
1016
#else /* ! YYPARSE_PARAM */
 
1017
#if defined (__STDC__) || defined (__cplusplus)
 
1018
int
 
1019
yyparse (const char **yyInput, struct global *yy)
 
1020
#else
 
1021
int
 
1022
yyparse (yyInput, yy)
 
1023
    const char **yyInput;
 
1024
    struct global *yy;
 
1025
#endif
 
1026
#endif
 
1027
{
 
1028
  /* The look-ahead symbol.  */
 
1029
int yychar;
 
1030
 
 
1031
/* The semantic value of the look-ahead symbol.  */
 
1032
YYSTYPE yylval;
 
1033
 
 
1034
/* Number of syntax errors so far.  */
 
1035
int yynerrs;
 
1036
 
 
1037
  int yystate;
 
1038
  int yyn;
 
1039
  int yyresult;
 
1040
  /* Number of tokens to shift before error messages enabled.  */
 
1041
  int yyerrstatus;
 
1042
  /* Look-ahead token as an internal (translated) token number.  */
 
1043
  int yytoken = 0;
 
1044
 
 
1045
  /* Three stacks and their tools:
 
1046
     `yyss': related to states,
 
1047
     `yyvs': related to semantic values,
 
1048
     `yyls': related to locations.
 
1049
 
 
1050
     Refer to the stacks thru separate pointers, to allow yyoverflow
 
1051
     to reallocate them elsewhere.  */
 
1052
 
 
1053
  /* The state stack.  */
 
1054
  short int yyssa[YYINITDEPTH];
 
1055
  short int *yyss = yyssa;
 
1056
  short int *yyssp;
 
1057
 
 
1058
  /* The semantic value stack.  */
 
1059
  YYSTYPE yyvsa[YYINITDEPTH];
 
1060
  YYSTYPE *yyvs = yyvsa;
 
1061
  YYSTYPE *yyvsp;
 
1062
 
 
1063
 
 
1064
 
 
1065
#define YYPOPSTACK   (yyvsp--, yyssp--)
 
1066
 
 
1067
  YYSIZE_T yystacksize = YYINITDEPTH;
 
1068
 
 
1069
  /* The variables used to return semantic value and location from the
 
1070
     action routines.  */
 
1071
  YYSTYPE yyval;
 
1072
 
 
1073
 
 
1074
  /* When reducing, the number of symbols on the RHS of the reduced
 
1075
     rule.  */
 
1076
  int yylen;
 
1077
 
 
1078
  YYDPRINTF ((stderr, "Starting parse\n"));
 
1079
 
 
1080
  yystate = 0;
 
1081
  yyerrstatus = 0;
 
1082
  yynerrs = 0;
 
1083
  yychar = YYEMPTY;             /* Cause a token to be read.  */
 
1084
 
 
1085
  /* Initialize stack pointers.
 
1086
     Waste one element of value and location stack
 
1087
     so that they stay on the same level as the state stack.
 
1088
     The wasted elements are never initialized.  */
 
1089
 
 
1090
  yyssp = yyss;
 
1091
  yyvsp = yyvs;
 
1092
 
 
1093
  goto yysetstate;
 
1094
 
 
1095
/*------------------------------------------------------------.
 
1096
| yynewstate -- Push a new state, which is found in yystate.  |
 
1097
`------------------------------------------------------------*/
 
1098
 yynewstate:
 
1099
  /* In all cases, when you get here, the value and location stacks
 
1100
     have just been pushed. so pushing a state here evens the stacks.
 
1101
     */
 
1102
  yyssp++;
 
1103
 
 
1104
 yysetstate:
 
1105
  *yyssp = yystate;
 
1106
 
 
1107
  if (yyss + yystacksize - 1 <= yyssp)
 
1108
    {
 
1109
      /* Get the current used size of the three stacks, in elements.  */
 
1110
      YYSIZE_T yysize = yyssp - yyss + 1;
 
1111
 
 
1112
#ifdef yyoverflow
 
1113
      {
 
1114
        /* Give user a chance to reallocate the stack. Use copies of
 
1115
           these so that the &'s don't force the real ones into
 
1116
           memory.  */
 
1117
        YYSTYPE *yyvs1 = yyvs;
 
1118
        short int *yyss1 = yyss;
 
1119
 
 
1120
 
 
1121
        /* Each stack pointer address is followed by the size of the
 
1122
           data in use in that stack, in bytes.  This used to be a
 
1123
           conditional around just the two extra args, but that might
 
1124
           be undefined if yyoverflow is a macro.  */
 
1125
        yyoverflow (YY_("memory exhausted"),
 
1126
                    &yyss1, yysize * sizeof (*yyssp),
 
1127
                    &yyvs1, yysize * sizeof (*yyvsp),
 
1128
 
 
1129
                    &yystacksize);
 
1130
 
 
1131
        yyss = yyss1;
 
1132
        yyvs = yyvs1;
 
1133
      }
 
1134
#else /* no yyoverflow */
 
1135
# ifndef YYSTACK_RELOCATE
 
1136
      goto yyexhaustedlab;
 
1137
# else
 
1138
      /* Extend the stack our own way.  */
 
1139
      if (YYMAXDEPTH <= yystacksize)
 
1140
        goto yyexhaustedlab;
 
1141
      yystacksize *= 2;
 
1142
      if (YYMAXDEPTH < yystacksize)
 
1143
        yystacksize = YYMAXDEPTH;
 
1144
 
 
1145
      {
 
1146
        short int *yyss1 = yyss;
 
1147
        union yyalloc *yyptr =
 
1148
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
 
1149
        if (! yyptr)
 
1150
          goto yyexhaustedlab;
 
1151
        YYSTACK_RELOCATE (yyss);
 
1152
        YYSTACK_RELOCATE (yyvs);
 
1153
 
 
1154
#  undef YYSTACK_RELOCATE
 
1155
        if (yyss1 != yyssa)
 
1156
          YYSTACK_FREE (yyss1);
 
1157
      }
 
1158
# endif
 
1159
#endif /* no yyoverflow */
 
1160
 
 
1161
      yyssp = yyss + yysize - 1;
 
1162
      yyvsp = yyvs + yysize - 1;
 
1163
 
 
1164
 
 
1165
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
 
1166
                  (unsigned long int) yystacksize));
 
1167
 
 
1168
      if (yyss + yystacksize - 1 <= yyssp)
 
1169
        YYABORT;
 
1170
    }
 
1171
 
 
1172
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
 
1173
 
 
1174
  goto yybackup;
 
1175
 
 
1176
/*-----------.
 
1177
| yybackup.  |
 
1178
`-----------*/
 
1179
yybackup:
 
1180
 
 
1181
/* Do appropriate processing given the current state.  */
 
1182
/* Read a look-ahead token if we need one and don't already have one.  */
 
1183
/* yyresume: */
 
1184
 
 
1185
  /* First try to decide what to do without reference to look-ahead token.  */
 
1186
 
 
1187
  yyn = yypact[yystate];
 
1188
  if (yyn == YYPACT_NINF)
 
1189
    goto yydefault;
 
1190
 
 
1191
  /* Not known => get a look-ahead token if don't already have one.  */
 
1192
 
 
1193
  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
 
1194
  if (yychar == YYEMPTY)
 
1195
    {
 
1196
      YYDPRINTF ((stderr, "Reading a token: "));
 
1197
      yychar = YYLEX;
 
1198
    }
 
1199
 
 
1200
  if (yychar <= YYEOF)
 
1201
    {
 
1202
      yychar = yytoken = YYEOF;
 
1203
      YYDPRINTF ((stderr, "Now at end of input.\n"));
 
1204
    }
 
1205
  else
 
1206
    {
 
1207
      yytoken = YYTRANSLATE (yychar);
 
1208
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
 
1209
    }
 
1210
 
 
1211
  /* If the proper action on seeing token YYTOKEN is to reduce or to
 
1212
     detect an error, take that action.  */
 
1213
  yyn += yytoken;
 
1214
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
 
1215
    goto yydefault;
 
1216
  yyn = yytable[yyn];
 
1217
  if (yyn <= 0)
 
1218
    {
 
1219
      if (yyn == 0 || yyn == YYTABLE_NINF)
 
1220
        goto yyerrlab;
 
1221
      yyn = -yyn;
 
1222
      goto yyreduce;
 
1223
    }
 
1224
 
 
1225
  if (yyn == YYFINAL)
 
1226
    YYACCEPT;
 
1227
 
 
1228
  /* Shift the look-ahead token.  */
 
1229
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
1230
 
 
1231
  /* Discard the token being shifted unless it is eof.  */
 
1232
  if (yychar != YYEOF)
 
1233
    yychar = YYEMPTY;
 
1234
 
 
1235
  *++yyvsp = yylval;
 
1236
 
 
1237
 
 
1238
  /* Count tokens shifted since error; after three, turn off error
 
1239
     status.  */
 
1240
  if (yyerrstatus)
 
1241
    yyerrstatus--;
 
1242
 
 
1243
  yystate = yyn;
 
1244
  goto yynewstate;
 
1245
 
 
1246
 
 
1247
/*-----------------------------------------------------------.
 
1248
| yydefault -- do the default action for the current state.  |
 
1249
`-----------------------------------------------------------*/
 
1250
yydefault:
 
1251
  yyn = yydefact[yystate];
 
1252
  if (yyn == 0)
 
1253
    goto yyerrlab;
 
1254
  goto yyreduce;
 
1255
 
 
1256
 
 
1257
/*-----------------------------.
 
1258
| yyreduce -- Do a reduction.  |
 
1259
`-----------------------------*/
 
1260
yyreduce:
 
1261
  /* yyn is the number of a rule to reduce with.  */
 
1262
  yylen = yyr2[yyn];
 
1263
 
 
1264
  /* If YYLEN is nonzero, implement the default value of the action:
 
1265
     `$$ = $1'.
 
1266
 
 
1267
     Otherwise, the following line sets YYVAL to garbage.
 
1268
     This behavior is undocumented and Bison
 
1269
     users should not rely upon it.  Assigning to YYVAL
 
1270
     unconditionally makes the parser a bit smaller, and it avoids a
 
1271
     GCC warning that YYVAL may be used uninitialized.  */
 
1272
  yyval = yyvsp[1-yylen];
 
1273
 
 
1274
 
 
1275
  YY_REDUCE_PRINT (yyn);
 
1276
  switch (yyn)
 
1277
    {
 
1278
        case 4:
 
1279
#line 122 "lib/getdate.y"
 
1280
    {
 
1281
            yy->HaveTime++;
 
1282
        }
 
1283
    break;
 
1284
 
 
1285
  case 5:
 
1286
#line 125 "lib/getdate.y"
 
1287
    {
 
1288
            yy->HaveZone++;
 
1289
        }
 
1290
    break;
 
1291
 
 
1292
  case 6:
 
1293
#line 128 "lib/getdate.y"
 
1294
    {
 
1295
            yy->HaveDate++;
 
1296
        }
 
1297
    break;
 
1298
 
 
1299
  case 7:
 
1300
#line 131 "lib/getdate.y"
 
1301
    {
 
1302
            yy->HaveDay++;
 
1303
        }
 
1304
    break;
 
1305
 
 
1306
  case 8:
 
1307
#line 134 "lib/getdate.y"
 
1308
    {
 
1309
            yy->HaveRel++;
 
1310
        }
 
1311
    break;
 
1312
 
 
1313
  case 10:
 
1314
#line 140 "lib/getdate.y"
 
1315
    {
 
1316
            yy->Hour = (yyvsp[-1].Number);
 
1317
            yy->Minutes = 0;
 
1318
            yy->Seconds = 0;
 
1319
            yy->Meridian = (yyvsp[0].Meridian);
 
1320
        }
 
1321
    break;
 
1322
 
 
1323
  case 11:
 
1324
#line 146 "lib/getdate.y"
 
1325
    {
 
1326
            yy->Hour = (yyvsp[-3].Number);
 
1327
            yy->Minutes = (yyvsp[-1].Number);
 
1328
            yy->Seconds = 0;
 
1329
            yy->Meridian = (yyvsp[0].Meridian);
 
1330
        }
 
1331
    break;
 
1332
 
 
1333
  case 12:
 
1334
#line 152 "lib/getdate.y"
 
1335
    {
 
1336
            yy->Hour = (yyvsp[-3].Number);
 
1337
            yy->Minutes = (yyvsp[-1].Number);
 
1338
            yy->Meridian = MER24;
 
1339
            yy->HaveZone++;
 
1340
            yy->Timezone = ((yyvsp[0].Number) < 0
 
1341
                          ? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60
 
1342
                          : - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60));
 
1343
        }
 
1344
    break;
 
1345
 
 
1346
  case 13:
 
1347
#line 161 "lib/getdate.y"
 
1348
    {
 
1349
            yy->Hour = (yyvsp[-5].Number);
 
1350
            yy->Minutes = (yyvsp[-3].Number);
 
1351
            yy->Seconds = (yyvsp[-1].Number);
 
1352
            yy->Meridian = (yyvsp[0].Meridian);
 
1353
        }
 
1354
    break;
 
1355
 
 
1356
  case 14:
 
1357
#line 167 "lib/getdate.y"
 
1358
    {
 
1359
            yy->Hour = (yyvsp[-5].Number);
 
1360
            yy->Minutes = (yyvsp[-3].Number);
 
1361
            yy->Seconds = (yyvsp[-1].Number);
 
1362
            yy->Meridian = MER24;
 
1363
            yy->HaveZone++;
 
1364
            yy->Timezone = ((yyvsp[0].Number) < 0
 
1365
                          ? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60
 
1366
                          : - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60));
 
1367
        }
 
1368
    break;
 
1369
 
 
1370
  case 15:
 
1371
#line 179 "lib/getdate.y"
 
1372
    {
 
1373
            yy->Timezone = (yyvsp[0].Number);
 
1374
        }
 
1375
    break;
 
1376
 
 
1377
  case 16:
 
1378
#line 182 "lib/getdate.y"
 
1379
    {
 
1380
            yy->Timezone = (yyvsp[0].Number) - 60;
 
1381
        }
 
1382
    break;
 
1383
 
 
1384
  case 17:
 
1385
#line 186 "lib/getdate.y"
 
1386
    {
 
1387
            yy->Timezone = (yyvsp[-1].Number) - 60;
 
1388
        }
 
1389
    break;
 
1390
 
 
1391
  case 18:
 
1392
#line 191 "lib/getdate.y"
 
1393
    {
 
1394
            yy->DayOrdinal = 1;
 
1395
            yy->DayNumber = (yyvsp[0].Number);
 
1396
        }
 
1397
    break;
 
1398
 
 
1399
  case 19:
 
1400
#line 195 "lib/getdate.y"
 
1401
    {
 
1402
            yy->DayOrdinal = 1;
 
1403
            yy->DayNumber = (yyvsp[-1].Number);
 
1404
        }
 
1405
    break;
 
1406
 
 
1407
  case 20:
 
1408
#line 199 "lib/getdate.y"
 
1409
    {
 
1410
            yy->DayOrdinal = (yyvsp[-1].Number);
 
1411
            yy->DayNumber = (yyvsp[0].Number);
 
1412
        }
 
1413
    break;
 
1414
 
 
1415
  case 21:
 
1416
#line 205 "lib/getdate.y"
 
1417
    {
 
1418
            yy->Month = (yyvsp[-2].Number);
 
1419
            yy->Day = (yyvsp[0].Number);
 
1420
        }
 
1421
    break;
 
1422
 
 
1423
  case 22:
 
1424
#line 209 "lib/getdate.y"
 
1425
    {
 
1426
          /* Interpret as YY->YY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
 
1427
             The goal in recognizing YY->YY/MM/DD is solely to support legacy
 
1428
             machine-generated dates like those in an RCS log listing.  If
 
1429
             you want portability, use the ISO 8601 format.  */
 
1430
          if ((yyvsp[-4].Number) >= 1000)
 
1431
            {
 
1432
              yy->Year = (yyvsp[-4].Number);
 
1433
              yy->Month = (yyvsp[-2].Number);
 
1434
              yy->Day = (yyvsp[0].Number);
 
1435
            }
 
1436
          else
 
1437
            {
 
1438
              yy->Month = (yyvsp[-4].Number);
 
1439
              yy->Day = (yyvsp[-2].Number);
 
1440
              yy->Year = (yyvsp[0].Number);
 
1441
            }
 
1442
        }
 
1443
    break;
 
1444
 
 
1445
  case 23:
 
1446
#line 227 "lib/getdate.y"
 
1447
    {
 
1448
            /* ISO 8601 format.  yy->yy-mm-dd.  */
 
1449
            yy->Year = (yyvsp[-2].Number);
 
1450
            yy->Month = -(yyvsp[-1].Number);
 
1451
            yy->Day = -(yyvsp[0].Number);
 
1452
        }
 
1453
    break;
 
1454
 
 
1455
  case 24:
 
1456
#line 233 "lib/getdate.y"
 
1457
    {
 
1458
            /* e.g. 17-JUN-1992.  */
 
1459
            yy->Day = (yyvsp[-2].Number);
 
1460
            yy->Month = (yyvsp[-1].Number);
 
1461
            yy->Year = -(yyvsp[0].Number);
 
1462
        }
 
1463
    break;
 
1464
 
 
1465
  case 25:
 
1466
#line 239 "lib/getdate.y"
 
1467
    {
 
1468
            yy->Month = (yyvsp[-1].Number);
 
1469
            yy->Day = (yyvsp[0].Number);
 
1470
        }
 
1471
    break;
 
1472
 
 
1473
  case 26:
 
1474
#line 243 "lib/getdate.y"
 
1475
    {
 
1476
            yy->Month = (yyvsp[-3].Number);
 
1477
            yy->Day = (yyvsp[-2].Number);
 
1478
            yy->Year = (yyvsp[0].Number);
 
1479
        }
 
1480
    break;
 
1481
 
 
1482
  case 27:
 
1483
#line 248 "lib/getdate.y"
 
1484
    {
 
1485
            yy->Month = (yyvsp[0].Number);
 
1486
            yy->Day = (yyvsp[-1].Number);
 
1487
        }
 
1488
    break;
 
1489
 
 
1490
  case 28:
 
1491
#line 252 "lib/getdate.y"
 
1492
    {
 
1493
            yy->Month = (yyvsp[-1].Number);
 
1494
            yy->Day = (yyvsp[-2].Number);
 
1495
            yy->Year = (yyvsp[0].Number);
 
1496
        }
 
1497
    break;
 
1498
 
 
1499
  case 29:
 
1500
#line 259 "lib/getdate.y"
 
1501
    {
 
1502
            yy->RelSeconds = -yy->RelSeconds;
 
1503
            yy->RelMinutes = -yy->RelMinutes;
 
1504
            yy->RelHour = -yy->RelHour;
 
1505
            yy->RelDay = -yy->RelDay;
 
1506
            yy->RelMonth = -yy->RelMonth;
 
1507
            yy->RelYear = -yy->RelYear;
 
1508
        }
 
1509
    break;
 
1510
 
 
1511
  case 31:
 
1512
#line 270 "lib/getdate.y"
 
1513
    {
 
1514
            yy->RelYear += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1515
        }
 
1516
    break;
 
1517
 
 
1518
  case 32:
 
1519
#line 273 "lib/getdate.y"
 
1520
    {
 
1521
            yy->RelYear += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1522
        }
 
1523
    break;
 
1524
 
 
1525
  case 33:
 
1526
#line 276 "lib/getdate.y"
 
1527
    {
 
1528
            yy->RelYear++;
 
1529
        }
 
1530
    break;
 
1531
 
 
1532
  case 34:
 
1533
#line 279 "lib/getdate.y"
 
1534
    {
 
1535
            yy->RelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1536
        }
 
1537
    break;
 
1538
 
 
1539
  case 35:
 
1540
#line 282 "lib/getdate.y"
 
1541
    {
 
1542
            yy->RelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1543
        }
 
1544
    break;
 
1545
 
 
1546
  case 36:
 
1547
#line 285 "lib/getdate.y"
 
1548
    {
 
1549
            yy->RelMonth++;
 
1550
        }
 
1551
    break;
 
1552
 
 
1553
  case 37:
 
1554
#line 288 "lib/getdate.y"
 
1555
    {
 
1556
            yy->RelDay += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1557
        }
 
1558
    break;
 
1559
 
 
1560
  case 38:
 
1561
#line 291 "lib/getdate.y"
 
1562
    {
 
1563
            yy->RelDay += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1564
        }
 
1565
    break;
 
1566
 
 
1567
  case 39:
 
1568
#line 294 "lib/getdate.y"
 
1569
    {
 
1570
            yy->RelDay++;
 
1571
        }
 
1572
    break;
 
1573
 
 
1574
  case 40:
 
1575
#line 297 "lib/getdate.y"
 
1576
    {
 
1577
            yy->RelHour += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1578
        }
 
1579
    break;
 
1580
 
 
1581
  case 41:
 
1582
#line 300 "lib/getdate.y"
 
1583
    {
 
1584
            yy->RelHour += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1585
        }
 
1586
    break;
 
1587
 
 
1588
  case 42:
 
1589
#line 303 "lib/getdate.y"
 
1590
    {
 
1591
            yy->RelHour++;
 
1592
        }
 
1593
    break;
 
1594
 
 
1595
  case 43:
 
1596
#line 306 "lib/getdate.y"
 
1597
    {
 
1598
            yy->RelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1599
        }
 
1600
    break;
 
1601
 
 
1602
  case 44:
 
1603
#line 309 "lib/getdate.y"
 
1604
    {
 
1605
            yy->RelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1606
        }
 
1607
    break;
 
1608
 
 
1609
  case 45:
 
1610
#line 312 "lib/getdate.y"
 
1611
    {
 
1612
            yy->RelMinutes++;
 
1613
        }
 
1614
    break;
 
1615
 
 
1616
  case 46:
 
1617
#line 315 "lib/getdate.y"
 
1618
    {
 
1619
            yy->RelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1620
        }
 
1621
    break;
 
1622
 
 
1623
  case 47:
 
1624
#line 318 "lib/getdate.y"
 
1625
    {
 
1626
            yy->RelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
 
1627
        }
 
1628
    break;
 
1629
 
 
1630
  case 48:
 
1631
#line 321 "lib/getdate.y"
 
1632
    {
 
1633
            yy->RelSeconds++;
 
1634
        }
 
1635
    break;
 
1636
 
 
1637
  case 49:
 
1638
#line 327 "lib/getdate.y"
 
1639
    {
 
1640
            if (yy->HaveTime && yy->HaveDate && !yy->HaveRel)
 
1641
              yy->Year = (yyvsp[0].Number);
 
1642
            else
 
1643
              {
 
1644
                if ((yyvsp[0].Number)>10000)
 
1645
                  {
 
1646
                    yy->HaveDate++;
 
1647
                    yy->Day= ((yyvsp[0].Number))%100;
 
1648
                    yy->Month= ((yyvsp[0].Number)/100)%100;
 
1649
                    yy->Year = (yyvsp[0].Number)/10000;
 
1650
                  }
 
1651
                else
 
1652
                  {
 
1653
                    yy->HaveTime++;
 
1654
                    if ((yyvsp[0].Number) < 100)
 
1655
                      {
 
1656
                        yy->Hour = (yyvsp[0].Number);
 
1657
                        yy->Minutes = 0;
 
1658
                      }
 
1659
                    else
 
1660
                      {
 
1661
                        yy->Hour = (yyvsp[0].Number) / 100;
 
1662
                        yy->Minutes = (yyvsp[0].Number) % 100;
 
1663
                      }
 
1664
                    yy->Seconds = 0;
 
1665
                    yy->Meridian = MER24;
 
1666
                  }
 
1667
              }
 
1668
          }
 
1669
    break;
 
1670
 
 
1671
  case 50:
 
1672
#line 360 "lib/getdate.y"
 
1673
    {
 
1674
            (yyval.Meridian) = MER24;
 
1675
          }
 
1676
    break;
 
1677
 
 
1678
  case 51:
 
1679
#line 364 "lib/getdate.y"
 
1680
    {
 
1681
            (yyval.Meridian) = (yyvsp[0].Meridian);
 
1682
          }
 
1683
    break;
 
1684
 
 
1685
 
 
1686
      default: break;
 
1687
    }
 
1688
 
 
1689
/* Line 1126 of yacc.c.  */
 
1690
#line 1691 "lib/getdate.c"
 
1691
 
 
1692
  yyvsp -= yylen;
 
1693
  yyssp -= yylen;
 
1694
 
 
1695
 
 
1696
  YY_STACK_PRINT (yyss, yyssp);
 
1697
 
 
1698
  *++yyvsp = yyval;
 
1699
 
 
1700
 
 
1701
  /* Now `shift' the result of the reduction.  Determine what state
 
1702
     that goes to, based on the state we popped back to and the rule
 
1703
     number reduced by.  */
 
1704
 
 
1705
  yyn = yyr1[yyn];
 
1706
 
 
1707
  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
 
1708
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
 
1709
    yystate = yytable[yystate];
 
1710
  else
 
1711
    yystate = yydefgoto[yyn - YYNTOKENS];
 
1712
 
 
1713
  goto yynewstate;
 
1714
 
 
1715
 
 
1716
/*------------------------------------.
 
1717
| yyerrlab -- here on detecting error |
 
1718
`------------------------------------*/
 
1719
yyerrlab:
 
1720
  /* If not already recovering from an error, report this error.  */
 
1721
  if (!yyerrstatus)
 
1722
    {
 
1723
      ++yynerrs;
 
1724
#if YYERROR_VERBOSE
 
1725
      yyn = yypact[yystate];
 
1726
 
 
1727
      if (YYPACT_NINF < yyn && yyn < YYLAST)
 
1728
        {
 
1729
          int yytype = YYTRANSLATE (yychar);
 
1730
          YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
 
1731
          YYSIZE_T yysize = yysize0;
 
1732
          YYSIZE_T yysize1;
 
1733
          int yysize_overflow = 0;
 
1734
          char *yymsg = 0;
 
1735
#         define YYERROR_VERBOSE_ARGS_MAXIMUM 5
 
1736
          char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
 
1737
          int yyx;
 
1738
 
 
1739
#if 0
 
1740
          /* This is so xgettext sees the translatable formats that are
 
1741
             constructed on the fly.  */
 
1742
          YY_("syntax error, unexpected %s");
 
1743
          YY_("syntax error, unexpected %s, expecting %s");
 
1744
          YY_("syntax error, unexpected %s, expecting %s or %s");
 
1745
          YY_("syntax error, unexpected %s, expecting %s or %s or %s");
 
1746
          YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
 
1747
#endif
 
1748
          char *yyfmt;
 
1749
          char const *yyf;
 
1750
          static char const yyunexpected[] = "syntax error, unexpected %s";
 
1751
          static char const yyexpecting[] = ", expecting %s";
 
1752
          static char const yyor[] = " or %s";
 
1753
          char yyformat[sizeof yyunexpected
 
1754
                        + sizeof yyexpecting - 1
 
1755
                        + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
 
1756
                           * (sizeof yyor - 1))];
 
1757
          char const *yyprefix = yyexpecting;
 
1758
 
 
1759
          /* Start YYX at -YYN if negative to avoid negative indexes in
 
1760
             YYCHECK.  */
 
1761
          int yyxbegin = yyn < 0 ? -yyn : 0;
 
1762
 
 
1763
          /* Stay within bounds of both yycheck and yytname.  */
 
1764
          int yychecklim = YYLAST - yyn;
 
1765
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 
1766
          int yycount = 1;
 
1767
 
 
1768
          yyarg[0] = yytname[yytype];
 
1769
          yyfmt = yystpcpy (yyformat, yyunexpected);
 
1770
 
 
1771
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 
1772
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
 
1773
              {
 
1774
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
 
1775
                  {
 
1776
                    yycount = 1;
 
1777
                    yysize = yysize0;
 
1778
                    yyformat[sizeof yyunexpected - 1] = '\0';
 
1779
                    break;
 
1780
                  }
 
1781
                yyarg[yycount++] = yytname[yyx];
 
1782
                yysize1 = yysize + yytnamerr (0, yytname[yyx]);
 
1783
                yysize_overflow |= yysize1 < yysize;
 
1784
                yysize = yysize1;
 
1785
                yyfmt = yystpcpy (yyfmt, yyprefix);
 
1786
                yyprefix = yyor;
 
1787
              }
 
1788
 
 
1789
          yyf = YY_(yyformat);
 
1790
          yysize1 = yysize + yystrlen (yyf);
 
1791
          yysize_overflow |= yysize1 < yysize;
 
1792
          yysize = yysize1;
 
1793
 
 
1794
          if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
 
1795
            yymsg = (char *) YYSTACK_ALLOC (yysize);
 
1796
          if (yymsg)
 
1797
            {
 
1798
              /* Avoid sprintf, as that infringes on the user's name space.
 
1799
                 Don't have undefined behavior even if the translation
 
1800
                 produced a string with the wrong number of "%s"s.  */
 
1801
              char *yyp = yymsg;
 
1802
              int yyi = 0;
 
1803
              while ((*yyp = *yyf))
 
1804
                {
 
1805
                  if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
 
1806
                    {
 
1807
                      yyp += yytnamerr (yyp, yyarg[yyi++]);
 
1808
                      yyf += 2;
 
1809
                    }
 
1810
                  else
 
1811
                    {
 
1812
                      yyp++;
 
1813
                      yyf++;
 
1814
                    }
 
1815
                }
 
1816
              yyerror (yyInput, yy, yymsg);
 
1817
              YYSTACK_FREE (yymsg);
 
1818
            }
 
1819
          else
 
1820
            {
 
1821
              yyerror (yyInput, yy, YY_("syntax error"));
 
1822
              goto yyexhaustedlab;
 
1823
            }
 
1824
        }
 
1825
      else
 
1826
#endif /* YYERROR_VERBOSE */
 
1827
        yyerror (yyInput, yy, YY_("syntax error"));
 
1828
    }
 
1829
 
 
1830
 
 
1831
 
 
1832
  if (yyerrstatus == 3)
 
1833
    {
 
1834
      /* If just tried and failed to reuse look-ahead token after an
 
1835
         error, discard it.  */
 
1836
 
 
1837
      if (yychar <= YYEOF)
 
1838
        {
 
1839
          /* Return failure if at end of input.  */
 
1840
          if (yychar == YYEOF)
 
1841
            YYABORT;
 
1842
        }
 
1843
      else
 
1844
        {
 
1845
          yydestruct ("Error: discarding", yytoken, &yylval);
 
1846
          yychar = YYEMPTY;
 
1847
        }
 
1848
    }
 
1849
 
 
1850
  /* Else will try to reuse look-ahead token after shifting the error
 
1851
     token.  */
 
1852
  goto yyerrlab1;
 
1853
 
 
1854
 
 
1855
/*---------------------------------------------------.
 
1856
| yyerrorlab -- error raised explicitly by YYERROR.  |
 
1857
`---------------------------------------------------*/
 
1858
yyerrorlab:
 
1859
 
 
1860
  /* Pacify compilers like GCC when the user code never invokes
 
1861
     YYERROR and the label yyerrorlab therefore never appears in user
 
1862
     code.  */
 
1863
  if (0)
 
1864
     goto yyerrorlab;
 
1865
 
 
1866
yyvsp -= yylen;
 
1867
  yyssp -= yylen;
 
1868
  yystate = *yyssp;
 
1869
  goto yyerrlab1;
 
1870
 
 
1871
 
 
1872
/*-------------------------------------------------------------.
 
1873
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
 
1874
`-------------------------------------------------------------*/
 
1875
yyerrlab1:
 
1876
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
 
1877
 
 
1878
  for (;;)
 
1879
    {
 
1880
      yyn = yypact[yystate];
 
1881
      if (yyn != YYPACT_NINF)
 
1882
        {
 
1883
          yyn += YYTERROR;
 
1884
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
 
1885
            {
 
1886
              yyn = yytable[yyn];
 
1887
              if (0 < yyn)
 
1888
                break;
 
1889
            }
 
1890
        }
 
1891
 
 
1892
      /* Pop the current state because it cannot handle the error token.  */
 
1893
      if (yyssp == yyss)
 
1894
        YYABORT;
 
1895
 
 
1896
 
 
1897
      yydestruct ("Error: popping", yystos[yystate], yyvsp);
 
1898
      YYPOPSTACK;
 
1899
      yystate = *yyssp;
 
1900
      YY_STACK_PRINT (yyss, yyssp);
 
1901
    }
 
1902
 
 
1903
  if (yyn == YYFINAL)
 
1904
    YYACCEPT;
 
1905
 
 
1906
  *++yyvsp = yylval;
 
1907
 
 
1908
 
 
1909
  /* Shift the error token. */
 
1910
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
1911
 
 
1912
  yystate = yyn;
 
1913
  goto yynewstate;
 
1914
 
 
1915
 
 
1916
/*-------------------------------------.
 
1917
| yyacceptlab -- YYACCEPT comes here.  |
 
1918
`-------------------------------------*/
 
1919
yyacceptlab:
 
1920
  yyresult = 0;
 
1921
  goto yyreturn;
 
1922
 
 
1923
/*-----------------------------------.
 
1924
| yyabortlab -- YYABORT comes here.  |
 
1925
`-----------------------------------*/
 
1926
yyabortlab:
 
1927
  yyresult = 1;
 
1928
  goto yyreturn;
 
1929
 
 
1930
#ifndef yyoverflow
 
1931
/*-------------------------------------------------.
 
1932
| yyexhaustedlab -- memory exhaustion comes here.  |
 
1933
`-------------------------------------------------*/
 
1934
yyexhaustedlab:
 
1935
  yyerror (yyInput, yy, YY_("memory exhausted"));
 
1936
  yyresult = 2;
 
1937
  /* Fall through.  */
 
1938
#endif
 
1939
 
 
1940
yyreturn:
 
1941
  if (yychar != YYEOF && yychar != YYEMPTY)
 
1942
     yydestruct ("Cleanup: discarding lookahead",
 
1943
                 yytoken, &yylval);
 
1944
  while (yyssp != yyss)
 
1945
    {
 
1946
      yydestruct ("Cleanup: popping",
 
1947
                  yystos[*yyssp], yyvsp);
 
1948
      YYPOPSTACK;
 
1949
    }
 
1950
#ifndef yyoverflow
 
1951
  if (yyss != yyssa)
 
1952
    YYSTACK_FREE (yyss);
 
1953
#endif
 
1954
  return yyresult;
 
1955
}
 
1956
 
 
1957
 
 
1958
#line 369 "lib/getdate.y"
 
1959
 
 
1960
 
 
1961
/* Month and day table. */
 
1962
static TABLE const MonthDayTable[] = {
 
1963
    { "january",        tMONTH,  1 },
 
1964
    { "february",       tMONTH,  2 },
 
1965
    { "march",          tMONTH,  3 },
 
1966
    { "april",          tMONTH,  4 },
 
1967
    { "may",            tMONTH,  5 },
 
1968
    { "june",           tMONTH,  6 },
 
1969
    { "july",           tMONTH,  7 },
 
1970
    { "august",         tMONTH,  8 },
 
1971
    { "september",      tMONTH,  9 },
 
1972
    { "sept",           tMONTH,  9 },
 
1973
    { "october",        tMONTH, 10 },
 
1974
    { "november",       tMONTH, 11 },
 
1975
    { "december",       tMONTH, 12 },
 
1976
    { "sunday",         tDAY, 0 },
 
1977
    { "monday",         tDAY, 1 },
 
1978
    { "tuesday",        tDAY, 2 },
 
1979
    { "tues",           tDAY, 2 },
 
1980
    { "wednesday",      tDAY, 3 },
 
1981
    { "wednes",         tDAY, 3 },
 
1982
    { "thursday",       tDAY, 4 },
 
1983
    { "thur",           tDAY, 4 },
 
1984
    { "thurs",          tDAY, 4 },
 
1985
    { "friday",         tDAY, 5 },
 
1986
    { "saturday",       tDAY, 6 },
 
1987
    { NULL, 0, 0 }
 
1988
};
 
1989
 
 
1990
/* Time units table. */
 
1991
static TABLE const UnitsTable[] = {
 
1992
    { "year",           tYEAR_UNIT,     1 },
 
1993
    { "month",          tMONTH_UNIT,    1 },
 
1994
    { "fortnight",      tDAY_UNIT,      14 },
 
1995
    { "week",           tDAY_UNIT,      7 },
 
1996
    { "day",            tDAY_UNIT,      1 },
 
1997
    { "hour",           tHOUR_UNIT,     1 },
 
1998
    { "minute",         tMINUTE_UNIT,   1 },
 
1999
    { "min",            tMINUTE_UNIT,   1 },
 
2000
    { "second",         tSEC_UNIT,      1 },
 
2001
    { "sec",            tSEC_UNIT,      1 },
 
2002
    { NULL, 0, 0 }
 
2003
};
 
2004
 
 
2005
/* Assorted relative-time words. */
 
2006
static TABLE const OtherTable[] = {
 
2007
    { "tomorrow",       tMINUTE_UNIT,   1 * 24 * 60 },
 
2008
    { "yesterday",      tMINUTE_UNIT,   -1 * 24 * 60 },
 
2009
    { "today",          tMINUTE_UNIT,   0 },
 
2010
    { "now",            tMINUTE_UNIT,   0 },
 
2011
    { "last",           tUNUMBER,       -1 },
 
2012
    { "this",           tMINUTE_UNIT,   0 },
 
2013
    { "next",           tUNUMBER,       2 },
 
2014
    { "first",          tUNUMBER,       1 },
 
2015
/*  { "second",         tUNUMBER,       2 }, */
 
2016
    { "third",          tUNUMBER,       3 },
 
2017
    { "fourth",         tUNUMBER,       4 },
 
2018
    { "fifth",          tUNUMBER,       5 },
 
2019
    { "sixth",          tUNUMBER,       6 },
 
2020
    { "seventh",        tUNUMBER,       7 },
 
2021
    { "eighth",         tUNUMBER,       8 },
 
2022
    { "ninth",          tUNUMBER,       9 },
 
2023
    { "tenth",          tUNUMBER,       10 },
 
2024
    { "eleventh",       tUNUMBER,       11 },
 
2025
    { "twelfth",        tUNUMBER,       12 },
 
2026
    { "ago",            tAGO,   1 },
 
2027
    { NULL, 0, 0 }
 
2028
};
 
2029
 
 
2030
/* The timezone table. */
 
2031
static TABLE const TimezoneTable[] = {
 
2032
    { "gmt",    tZONE,     HOUR ( 0) }, /* Greenwich Mean */
 
2033
    { "ut",     tZONE,     HOUR ( 0) }, /* Universal (Coordinated) */
 
2034
    { "utc",    tZONE,     HOUR ( 0) },
 
2035
    { "wet",    tZONE,     HOUR ( 0) }, /* Western European */
 
2036
    { "bst",    tDAYZONE,  HOUR ( 0) }, /* British Summer */
 
2037
    { "wat",    tZONE,     HOUR ( 1) }, /* West Africa */
 
2038
    { "at",     tZONE,     HOUR ( 2) }, /* Azores */
 
2039
    { "ast",    tZONE,     HOUR ( 4) }, /* Atlantic Standard */
 
2040
    { "adt",    tDAYZONE,  HOUR ( 4) }, /* Atlantic Daylight */
 
2041
    { "est",    tZONE,     HOUR ( 5) }, /* Eastern Standard */
 
2042
    { "edt",    tDAYZONE,  HOUR ( 5) }, /* Eastern Daylight */
 
2043
    { "cst",    tZONE,     HOUR ( 6) }, /* Central Standard */
 
2044
    { "cdt",    tDAYZONE,  HOUR ( 6) }, /* Central Daylight */
 
2045
    { "mst",    tZONE,     HOUR ( 7) }, /* Mountain Standard */
 
2046
    { "mdt",    tDAYZONE,  HOUR ( 7) }, /* Mountain Daylight */
 
2047
    { "pst",    tZONE,     HOUR ( 8) }, /* Pacific Standard */
 
2048
    { "pdt",    tDAYZONE,  HOUR ( 8) }, /* Pacific Daylight */
 
2049
    { "yst",    tZONE,     HOUR ( 9) }, /* Yukon Standard */
 
2050
    { "ydt",    tDAYZONE,  HOUR ( 9) }, /* Yukon Daylight */
 
2051
    { "hst",    tZONE,     HOUR (10) }, /* Hawaii Standard */
 
2052
    { "hdt",    tDAYZONE,  HOUR (10) }, /* Hawaii Daylight */
 
2053
    { "cat",    tZONE,     HOUR (10) }, /* Central Alaska */
 
2054
    { "ahst",   tZONE,     HOUR (10) }, /* Alaska-Hawaii Standard */
 
2055
    { "nt",     tZONE,     HOUR (11) }, /* Nome */
 
2056
    { "idlw",   tZONE,     HOUR (12) }, /* International Date Line West */
 
2057
    { "cet",    tZONE,     -HOUR (1) }, /* Central European */
 
2058
    { "met",    tZONE,     -HOUR (1) }, /* Middle European */
 
2059
    { "mewt",   tZONE,     -HOUR (1) }, /* Middle European Winter */
 
2060
    { "mest",   tDAYZONE,  -HOUR (1) }, /* Middle European Summer */
 
2061
    { "mesz",   tDAYZONE,  -HOUR (1) }, /* Middle European Summer */
 
2062
    { "swt",    tZONE,     -HOUR (1) }, /* Swedish Winter */
 
2063
    { "sst",    tDAYZONE,  -HOUR (1) }, /* Swedish Summer */
 
2064
    { "fwt",    tZONE,     -HOUR (1) }, /* French Winter */
 
2065
    { "fst",    tDAYZONE,  -HOUR (1) }, /* French Summer */
 
2066
    { "eet",    tZONE,     -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
 
2067
    { "bt",     tZONE,     -HOUR (3) }, /* Baghdad, USSR Zone 2 */
 
2068
    { "zp4",    tZONE,     -HOUR (4) }, /* USSR Zone 3 */
 
2069
    { "zp5",    tZONE,     -HOUR (5) }, /* USSR Zone 4 */
 
2070
    { "zp6",    tZONE,     -HOUR (6) }, /* USSR Zone 5 */
 
2071
    { "wast",   tZONE,     -HOUR (7) }, /* West Australian Standard */
 
2072
    { "wadt",   tDAYZONE,  -HOUR (7) }, /* West Australian Daylight */
 
2073
    { "cct",    tZONE,     -HOUR (8) }, /* China Coast, USSR Zone 7 */
 
2074
    { "jst",    tZONE,     -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
 
2075
    { "east",   tZONE,     -HOUR (10) },        /* Eastern Australian Standard */
 
2076
    { "eadt",   tDAYZONE,  -HOUR (10) },        /* Eastern Australian Daylight */
 
2077
    { "gst",    tZONE,     -HOUR (10) },        /* Guam Standard, USSR Zone 9 */
 
2078
    { "nzt",    tZONE,     -HOUR (12) },        /* New Zealand */
 
2079
    { "nzst",   tZONE,     -HOUR (12) },        /* New Zealand Standard */
 
2080
    { "nzdt",   tDAYZONE,  -HOUR (12) },        /* New Zealand Daylight */
 
2081
    { "idle",   tZONE,     -HOUR (12) },        /* International Date Line East */
 
2082
    {  NULL, 0, 0  }
 
2083
};
 
2084
 
 
2085
/* Military timezone table. */
 
2086
static TABLE const MilitaryTable[] = {
 
2087
    { "a",      tZONE,  HOUR (  1) },
 
2088
    { "b",      tZONE,  HOUR (  2) },
 
2089
    { "c",      tZONE,  HOUR (  3) },
 
2090
    { "d",      tZONE,  HOUR (  4) },
 
2091
    { "e",      tZONE,  HOUR (  5) },
 
2092
    { "f",      tZONE,  HOUR (  6) },
 
2093
    { "g",      tZONE,  HOUR (  7) },
 
2094
    { "h",      tZONE,  HOUR (  8) },
 
2095
    { "i",      tZONE,  HOUR (  9) },
 
2096
    { "k",      tZONE,  HOUR ( 10) },
 
2097
    { "l",      tZONE,  HOUR ( 11) },
 
2098
    { "m",      tZONE,  HOUR ( 12) },
 
2099
    { "n",      tZONE,  HOUR (- 1) },
 
2100
    { "o",      tZONE,  HOUR (- 2) },
 
2101
    { "p",      tZONE,  HOUR (- 3) },
 
2102
    { "q",      tZONE,  HOUR (- 4) },
 
2103
    { "r",      tZONE,  HOUR (- 5) },
 
2104
    { "s",      tZONE,  HOUR (- 6) },
 
2105
    { "t",      tZONE,  HOUR (- 7) },
 
2106
    { "u",      tZONE,  HOUR (- 8) },
 
2107
    { "v",      tZONE,  HOUR (- 9) },
 
2108
    { "w",      tZONE,  HOUR (-10) },
 
2109
    { "x",      tZONE,  HOUR (-11) },
 
2110
    { "y",      tZONE,  HOUR (-12) },
 
2111
    { "z",      tZONE,  HOUR (  0) },
 
2112
    { NULL, 0, 0 }
 
2113
};
 
2114
 
 
2115
 
 
2116
 
 
2117
 
 
2118
/* ARGSUSED */
 
2119
static int
 
2120
yyerror (const char **yyInput, struct global *yy, char *s)
 
2121
{
 
2122
  (void)yyInput;
 
2123
  (void)yy;
 
2124
  (void)s;
 
2125
  return 0;
 
2126
}
 
2127
 
 
2128
static int
 
2129
ToHour (int Hours, MERIDIAN Meridian)
 
2130
{
 
2131
  switch (Meridian)
 
2132
    {
 
2133
    case MER24:
 
2134
      if (Hours < 0 || Hours > 23)
 
2135
        return -1;
 
2136
      return Hours;
 
2137
    case MERam:
 
2138
      if (Hours < 1 || Hours > 12)
 
2139
        return -1;
 
2140
      if (Hours == 12)
 
2141
        Hours = 0;
 
2142
      return Hours;
 
2143
    case MERpm:
 
2144
      if (Hours < 1 || Hours > 12)
 
2145
        return -1;
 
2146
      if (Hours == 12)
 
2147
        Hours = 0;
 
2148
      return Hours + 12;
 
2149
    default:
 
2150
      abort ();
 
2151
    }
 
2152
  /* NOTREACHED */
 
2153
}
 
2154
 
 
2155
static int
 
2156
ToYear (int Year)
 
2157
{
 
2158
  if (Year < 0)
 
2159
    Year = -Year;
 
2160
 
 
2161
  /* XPG4 suggests that years 00-68 map to 2000-2068, and
 
2162
     years 69-99 map to 1969-1999.  */
 
2163
  if (Year < 69)
 
2164
    Year += 2000;
 
2165
  else if (Year < 100)
 
2166
    Year += 1900;
 
2167
 
 
2168
  return Year;
 
2169
}
 
2170
 
 
2171
static int
 
2172
LookupWord (YYSTYPE *lvalp, char *buff)
 
2173
{
 
2174
  register char *p;
 
2175
  register char *q;
 
2176
  register const TABLE *tp;
 
2177
  int i;
 
2178
  int abbrev;
 
2179
 
 
2180
  /* Make it lowercase. */
 
2181
  for (p = buff; *p; p++)
 
2182
    if (isupper ((unsigned char)*p))
 
2183
      *p = tolower (*p);
 
2184
 
 
2185
  if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
 
2186
    {
 
2187
      lvalp->Meridian = MERam;
 
2188
      return tMERIDIAN;
 
2189
    }
 
2190
  if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
 
2191
    {
 
2192
      lvalp->Meridian = MERpm;
 
2193
      return tMERIDIAN;
 
2194
    }
 
2195
 
 
2196
  /* See if we have an abbreviation for a month. */
 
2197
  if (strlen (buff) == 3)
 
2198
    abbrev = 1;
 
2199
  else if (strlen (buff) == 4 && buff[3] == '.')
 
2200
    {
 
2201
      abbrev = 1;
 
2202
      buff[3] = '\0';
 
2203
    }
 
2204
  else
 
2205
    abbrev = 0;
 
2206
 
 
2207
  for (tp = MonthDayTable; tp->name; tp++)
 
2208
    {
 
2209
      if (abbrev)
 
2210
        {
 
2211
          if (strncmp (buff, tp->name, 3) == 0)
 
2212
            {
 
2213
              lvalp->Number = tp->value;
 
2214
              return tp->type;
 
2215
            }
 
2216
        }
 
2217
      else if (strcmp (buff, tp->name) == 0)
 
2218
        {
 
2219
          lvalp->Number = tp->value;
 
2220
          return tp->type;
 
2221
        }
 
2222
    }
 
2223
 
 
2224
  for (tp = TimezoneTable; tp->name; tp++)
 
2225
    if (strcmp (buff, tp->name) == 0)
 
2226
      {
 
2227
        lvalp->Number = tp->value;
 
2228
        return tp->type;
 
2229
      }
 
2230
 
 
2231
  if (strcmp (buff, "dst") == 0)
 
2232
    return tDST;
 
2233
 
 
2234
  for (tp = UnitsTable; tp->name; tp++)
 
2235
    if (strcmp (buff, tp->name) == 0)
 
2236
      {
 
2237
        lvalp->Number = tp->value;
 
2238
        return tp->type;
 
2239
      }
 
2240
 
 
2241
  /* Strip off any plural and try the units table again. */
 
2242
  i = strlen (buff) - 1;
 
2243
  if (buff[i] == 's')
 
2244
    {
 
2245
      buff[i] = '\0';
 
2246
      for (tp = UnitsTable; tp->name; tp++)
 
2247
        if (strcmp (buff, tp->name) == 0)
 
2248
          {
 
2249
            lvalp->Number = tp->value;
 
2250
            return tp->type;
 
2251
          }
 
2252
      buff[i] = 's';            /* Put back for "this" in OtherTable. */
 
2253
    }
 
2254
 
 
2255
  for (tp = OtherTable; tp->name; tp++)
 
2256
    if (strcmp (buff, tp->name) == 0)
 
2257
      {
 
2258
        lvalp->Number = tp->value;
 
2259
        return tp->type;
 
2260
      }
 
2261
 
 
2262
  /* Military timezones. */
 
2263
  if (buff[1] == '\0' && isalpha ((unsigned char)*buff))
 
2264
    {
 
2265
      for (tp = MilitaryTable; tp->name; tp++)
 
2266
        if (strcmp (buff, tp->name) == 0)
 
2267
          {
 
2268
            lvalp->Number = tp->value;
 
2269
            return tp->type;
 
2270
          }
 
2271
    }
 
2272
 
 
2273
  /* Drop out any periods and try the timezone table again. */
 
2274
  for (i = 0, p = q = buff; *q; q++)
 
2275
    if (*q != '.')
 
2276
      *p++ = *q;
 
2277
    else
 
2278
      i++;
 
2279
  *p = '\0';
 
2280
  if (i)
 
2281
    for (tp = TimezoneTable; tp->name; tp++)
 
2282
      if (strcmp (buff, tp->name) == 0)
 
2283
        {
 
2284
          lvalp->Number = tp->value;
 
2285
          return tp->type;
 
2286
        }
 
2287
 
 
2288
  return tID;
 
2289
}
 
2290
 
 
2291
static int
 
2292
yylex (YYSTYPE *lvalp, const char **yyInput)
 
2293
{
 
2294
  register char c;
 
2295
  register char *p;
 
2296
  char buff[20];
 
2297
  int Count;
 
2298
  int sign;
 
2299
 
 
2300
  for (;;)
 
2301
    {
 
2302
      while (isspace ((unsigned char)**yyInput))
 
2303
        (*yyInput)++;
 
2304
 
 
2305
      if (ISDIGIT (c = **yyInput) || c == '-' || c == '+')
 
2306
        {
 
2307
          if (c == '-' || c == '+')
 
2308
            {
 
2309
              sign = c == '-' ? -1 : 1;
 
2310
              if (!ISDIGIT (*++*yyInput))
 
2311
                /* skip the '-' sign */
 
2312
                continue;
 
2313
            }
 
2314
          else
 
2315
            sign = 0;
 
2316
          for (lvalp->Number = 0; ISDIGIT (c = *(*yyInput)++);)
 
2317
            lvalp->Number = 10 * lvalp->Number + c - '0';
 
2318
          (*yyInput)--;
 
2319
          if (sign < 0)
 
2320
            lvalp->Number = -lvalp->Number;
 
2321
          return sign ? tSNUMBER : tUNUMBER;
 
2322
        }
 
2323
      if (isalpha ((unsigned char)c))
 
2324
        {
 
2325
          for (p = buff; (c = *(*yyInput)++, isalpha ((unsigned char)c))
 
2326
                 || c == '.';)
 
2327
            if (p < &buff[sizeof buff - 1])
 
2328
              *p++ = c;
 
2329
          *p = '\0';
 
2330
          (*yyInput)--;
 
2331
          return LookupWord (lvalp, buff);
 
2332
        }
 
2333
      if (c != '(')
 
2334
        return *(*yyInput)++;
 
2335
      Count = 0;
 
2336
      do
 
2337
        {
 
2338
          c = *(*yyInput)++;
 
2339
          if (c == '\0')
 
2340
            return c;
 
2341
          if (c == '(')
 
2342
            Count++;
 
2343
          else if (c == ')')
 
2344
            Count--;
 
2345
        }
 
2346
      while (Count > 0);
 
2347
    }
 
2348
}
 
2349
 
 
2350
#define TM_YEAR_ORIGIN 1900
 
2351
 
 
2352
/* Yield A - B, measured in seconds.  */
 
2353
static long
 
2354
difftm (struct tm *a, struct tm *b)
 
2355
{
 
2356
  int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
 
2357
  int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
 
2358
  long days = (
 
2359
  /* difference in day of year */
 
2360
                a->tm_yday - b->tm_yday
 
2361
  /* + intervening leap days */
 
2362
                + ((ay >> 2) - (by >> 2))
 
2363
                - (ay / 100 - by / 100)
 
2364
                + ((ay / 100 >> 2) - (by / 100 >> 2))
 
2365
  /* + difference in years * 365 */
 
2366
                + (long) (ay - by) * 365
 
2367
  );
 
2368
  return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
 
2369
                + (a->tm_min - b->tm_min))
 
2370
          + (a->tm_sec - b->tm_sec));
 
2371
}
 
2372
 
 
2373
time_t
 
2374
lu_get_date (const char *p, const time_t *now)
 
2375
{
 
2376
  struct tm tm, tm0, *tmp;
 
2377
  struct global yy;
 
2378
  time_t Start;
 
2379
 
 
2380
  Start = now ? *now : time ((time_t *) NULL);
 
2381
  tmp = localtime (&Start);
 
2382
  memset (&yy, 0, sizeof(yy));
 
2383
  yy.Year = tmp->tm_year + TM_YEAR_ORIGIN;
 
2384
  yy.Month = tmp->tm_mon + 1;
 
2385
  yy.Day = tmp->tm_mday;
 
2386
  yy.Hour = tmp->tm_hour;
 
2387
  yy.Minutes = tmp->tm_min;
 
2388
  yy.Seconds = tmp->tm_sec;
 
2389
  yy.Meridian = MER24;
 
2390
  yy.RelSeconds = 0;
 
2391
  yy.RelMinutes = 0;
 
2392
  yy.RelHour = 0;
 
2393
  yy.RelDay = 0;
 
2394
  yy.RelMonth = 0;
 
2395
  yy.RelYear = 0;
 
2396
  yy.HaveDate = 0;
 
2397
  yy.HaveDay = 0;
 
2398
  yy.HaveRel = 0;
 
2399
  yy.HaveTime = 0;
 
2400
  yy.HaveZone = 0;
 
2401
 
 
2402
  if (yyparse (&p, &yy)
 
2403
      || yy.HaveTime > 1 || yy.HaveZone > 1 || yy.HaveDate > 1 || yy.HaveDay > 1)
 
2404
    return -1;
 
2405
 
 
2406
  tm.tm_year = ToYear (yy.Year) - TM_YEAR_ORIGIN + yy.RelYear;
 
2407
  tm.tm_mon = yy.Month - 1 + yy.RelMonth;
 
2408
  tm.tm_mday = yy.Day + yy.RelDay;
 
2409
  if (yy.HaveTime || (yy.HaveRel && !yy.HaveDate && !yy.HaveDay))
 
2410
    {
 
2411
      tm.tm_hour = ToHour (yy.Hour, yy.Meridian);
 
2412
      if (tm.tm_hour < 0)
 
2413
        return -1;
 
2414
      tm.tm_min = yy.Minutes;
 
2415
      tm.tm_sec = yy.Seconds;
 
2416
    }
 
2417
  else
 
2418
    {
 
2419
      tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
 
2420
    }
 
2421
  tm.tm_hour += yy.RelHour;
 
2422
  tm.tm_min += yy.RelMinutes;
 
2423
  tm.tm_sec += yy.RelSeconds;
 
2424
  tm.tm_isdst = -1;
 
2425
  tm0 = tm;
 
2426
 
 
2427
  Start = mktime (&tm);
 
2428
 
 
2429
  if (Start == (time_t) -1)
 
2430
    {
 
2431
 
 
2432
      /* Guard against falsely reporting errors near the time_t boundaries
 
2433
         when parsing times in other time zones.  For example, if the min
 
2434
         time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
 
2435
         of UTC, then the min localtime value is 1970-01-01 08:00:00; if
 
2436
         we apply mktime to 1970-01-01 00:00:00 we will get an error, so
 
2437
         we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
 
2438
         zone by 24 hours to compensate.  This algorithm assumes that
 
2439
         there is no DST transition within a day of the time_t boundaries.  */
 
2440
      if (yy.HaveZone)
 
2441
        {
 
2442
          tm = tm0;
 
2443
          if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
 
2444
            {
 
2445
              tm.tm_mday++;
 
2446
              yy.Timezone -= 24 * 60;
 
2447
            }
 
2448
          else
 
2449
            {
 
2450
              tm.tm_mday--;
 
2451
              yy.Timezone += 24 * 60;
 
2452
            }
 
2453
          Start = mktime (&tm);
 
2454
        }
 
2455
 
 
2456
      if (Start == (time_t) -1)
 
2457
        return Start;
 
2458
    }
 
2459
 
 
2460
  if (yy.HaveDay && !yy.HaveDate)
 
2461
    {
 
2462
      tm.tm_mday += ((yy.DayNumber - tm.tm_wday + 7) % 7
 
2463
                     + 7 * (yy.DayOrdinal - (0 < yy.DayOrdinal)));
 
2464
      Start = mktime (&tm);
 
2465
      if (Start == (time_t) -1)
 
2466
        return Start;
 
2467
    }
 
2468
 
 
2469
  if (yy.HaveZone)
 
2470
    {
 
2471
      long delta = yy.Timezone * 60L + difftm (&tm, gmtime (&Start));
 
2472
      if ((Start + delta < Start) != (delta < 0))
 
2473
        return -1;              /* time_t overflow */
 
2474
      Start += delta;
 
2475
    }
 
2476
 
 
2477
  return Start;
 
2478
}
 
2479
 
 
2480
#if     defined (TEST)
 
2481
 
 
2482
/* ARGSUSED */
 
2483
int
 
2484
main (ac, av)
 
2485
     int ac;
 
2486
     char *av[];
 
2487
{
 
2488
  char buff[MAX_BUFF_LEN + 1];
 
2489
  time_t d;
 
2490
 
 
2491
  (void) printf ("Enter date, or blank line to exit.\n\t> ");
 
2492
  (void) fflush (stdout);
 
2493
 
 
2494
  buff[MAX_BUFF_LEN] = 0;
 
2495
  while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
 
2496
    {
 
2497
      d = lu_get_date (buff, (time_t *) NULL);
 
2498
      if (d == -1)
 
2499
        (void) printf ("Bad format - couldn't convert.\n");
 
2500
      else
 
2501
        (void) printf ("%s", ctime (&d));
 
2502
      (void) printf ("\t> ");
 
2503
      (void) fflush (stdout);
 
2504
    }
 
2505
  exit (0);
 
2506
  /* NOTREACHED */
 
2507
}
 
2508
#endif /* defined (TEST) */
 
2509
 
 
2510