modules/getdate.c

説明を見る。
00001 /* A Bison parser, made by GNU Bison 1.875a.  */
00002 
00003 /* Skeleton parser for Yacc-like parsing with Bison,
00004    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2, or (at your option)
00009    any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.  */
00020 
00021 /* As a special exception, when this file is copied by Bison into a
00022    Bison output file, you may use that output file without restriction.
00023    This special exception was added by the Free Software Foundation
00024    in version 1.24 of Bison.  */
00025 
00026 /* Written by Richard Stallman by simplifying the original so called
00027    ``semantic'' parser.  */
00028 
00029 /* All symbols defined below should begin with yy or YY, to avoid
00030    infringing on user name space.  This should be done even for local
00031    variables, as they might otherwise be expanded by user macros.
00032    There are some unavoidable exceptions within include files to
00033    define necessary library symbols; they are noted "INFRINGES ON
00034    USER NAME SPACE" below.  */
00035 
00036 /* Identify Bison output.  */
00037 #define YYBISON 1
00038 
00039 /* Skeleton name.  */
00040 #define YYSKELETON_NAME "yacc.c"
00041 
00042 /* Pure parsers.  */
00043 #define YYPURE 1
00044 
00045 /* Using locations.  */
00046 #define YYLSP_NEEDED 0
00047 
00048 
00049 
00050 /* Tokens.  */
00051 #ifndef YYTOKENTYPE
00052 # define YYTOKENTYPE
00053    /* Put the tokens into the symbol table, so that GDB and other debuggers
00054       know about them.  */
00055    enum yytokentype {
00056      tAGO = 258,
00057      tDST = 259,
00058      tDAY = 260,
00059      tDAY_UNIT = 261,
00060      tDAYZONE = 262,
00061      tHOUR_UNIT = 263,
00062      tLOCAL_ZONE = 264,
00063      tMERIDIAN = 265,
00064      tMINUTE_UNIT = 266,
00065      tMONTH = 267,
00066      tMONTH_UNIT = 268,
00067      tSEC_UNIT = 269,
00068      tYEAR_UNIT = 270,
00069      tZONE = 271,
00070      tSNUMBER = 272,
00071      tUNUMBER = 273
00072    };
00073 #endif
00074 #define tAGO 258
00075 #define tDST 259
00076 #define tDAY 260
00077 #define tDAY_UNIT 261
00078 #define tDAYZONE 262
00079 #define tHOUR_UNIT 263
00080 #define tLOCAL_ZONE 264
00081 #define tMERIDIAN 265
00082 #define tMINUTE_UNIT 266
00083 #define tMONTH 267
00084 #define tMONTH_UNIT 268
00085 #define tSEC_UNIT 269
00086 #define tYEAR_UNIT 270
00087 #define tZONE 271
00088 #define tSNUMBER 272
00089 #define tUNUMBER 273
00090 
00091 
00092 
00093 
00094 /* Copy the first part of user declarations.  */
00095 #line 1 "getdate.y"
00096 
00097 /* Parse a string into an internal time stamp.
00098    Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
00099 
00100    This program is free software; you can redistribute it and/or modify
00101    it under the terms of the GNU General Public License as published by
00102    the Free Software Foundation; either version 2, or (at your option)
00103    any later version.
00104 
00105    This program is distributed in the hope that it will be useful,
00106    but WITHOUT ANY WARRANTY; without even the implied warranty of
00107    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00108    GNU General Public License for more details.
00109 
00110    You should have received a copy of the GNU General Public License
00111    along with this program; if not, write to the Free Software Foundation,
00112    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00113 
00114 /* Originally written by Steven M. Bellovin <smb@research.att.com> while
00115    at the University of North Carolina at Chapel Hill.  Later tweaked by
00116    a couple of people on Usenet.  Completely overhauled by Rich $alz
00117    <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
00118 
00119    Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do
00120    the right thing about local DST.  Unlike previous versions, this
00121    version is reentrant.  */
00122 
00123 #ifdef HAVE_CONFIG_H
00124 # include <config.h>
00125 # ifdef HAVE_ALLOCA_H
00126 #  include <alloca.h>
00127 # endif
00128 #endif
00129 
00130 /* Since the code of getdate.y is not included in the Emacs executable
00131    itself, there is no need to #define static in this file.  Even if
00132    the code were included in the Emacs executable, it probably
00133    wouldn't do any harm to #undef it here; this will only cause
00134    problems if we try to write to a static variable, which I don't
00135    think this code needs to do.  */
00136 #ifdef emacs
00137 # undef static
00138 #endif
00139 
00140 #include <ctype.h>
00141 #include <string.h>
00142 
00143 #if HAVE_STDLIB_H
00144 # include <stdlib.h> /* for `free'; used by Bison 1.27 */
00145 #endif
00146 
00147 #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
00148 # define IN_CTYPE_DOMAIN(c) 1
00149 #else
00150 # define IN_CTYPE_DOMAIN(c) isascii (c)
00151 #endif
00152 
00153 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
00154 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
00155 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
00156 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
00157 
00158 /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
00159    - Its arg may be any int or unsigned int; it need not be an unsigned char.
00160    - It's guaranteed to evaluate its argument exactly once.
00161    - It's typically faster.
00162    POSIX says that only '0' through '9' are digits.  Prefer ISDIGIT to
00163    ISDIGIT_LOCALE unless it's important to use the locale's definition
00164    of `digit' even when the host does not conform to POSIX.  */
00165 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
00166 
00167 #if STDC_HEADERS || HAVE_STRING_H
00168 # include <string.h>
00169 #endif
00170 
00171 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
00172 # define __attribute__(x)
00173 #endif
00174 
00175 #ifndef ATTRIBUTE_UNUSED
00176 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
00177 #endif
00178 
00179 #define EPOCH_YEAR 1970
00180 #define TM_YEAR_BASE 1900
00181 
00182 #define HOUR(x) ((x) * 60)
00183 
00184 /* An integer value, and the number of digits in its textual
00185    representation.  */
00186 typedef struct
00187 {
00188   int value;
00189   int digits;
00190 } textint;
00191 
00192 /* An entry in the lexical lookup table.  */
00193 typedef struct
00194 {
00195   char const *name;
00196   int type;
00197   int value;
00198 } table;
00199 
00200 /* Meridian: am, pm, or 24-hour style.  */
00201 enum { MERam, MERpm, MER24 };
00202 
00203 /* Information passed to and from the parser.  */
00204 typedef struct
00205 {
00206   /* The input string remaining to be parsed. */
00207   const char *input;
00208 
00209   /* N, if this is the Nth Tuesday.  */
00210   int day_ordinal;
00211 
00212   /* Day of week; Sunday is 0.  */
00213   int day_number;
00214 
00215   /* tm_isdst flag for the local zone.  */
00216   int local_isdst;
00217 
00218   /* Time zone, in minutes east of UTC.  */
00219   int time_zone;
00220 
00221   /* Style used for time.  */
00222   int meridian;
00223 
00224   /* Gregorian year, month, day, hour, minutes, and seconds.  */
00225   textint year;
00226   int month;
00227   int day;
00228   int hour;
00229   int minutes;
00230   int seconds;
00231 
00232   /* Relative year, month, day, hour, minutes, and seconds.  */
00233   int rel_year;
00234   int rel_month;
00235   int rel_day;
00236   int rel_hour;
00237   int rel_minutes;
00238   int rel_seconds;
00239 
00240   /* Counts of nonterminals of various flavors parsed so far.  */
00241   int dates_seen;
00242   int days_seen;
00243   int local_zones_seen;
00244   int rels_seen;
00245   int times_seen;
00246   int zones_seen;
00247 
00248   /* Table of local time zone abbrevations, terminated by a null entry.  */
00249   table local_time_zone_table[3];
00250 } parser_control;
00251 
00252 #define PC (* (parser_control *) parm)
00253 #define YYLEX_PARAM parm
00254 #define YYPARSE_PARAM parm
00255 
00256 static int yyerror ();
00257 static int yylex ();
00258 
00259 
00260 
00261 /* Enabling traces.  */
00262 #ifndef YYDEBUG
00263 # define YYDEBUG 0
00264 #endif
00265 
00266 /* Enabling verbose error messages.  */
00267 #ifdef YYERROR_VERBOSE
00268 # undef YYERROR_VERBOSE
00269 # define YYERROR_VERBOSE 1
00270 #else
00271 # define YYERROR_VERBOSE 0
00272 #endif
00273 
00274 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
00275 #line 172 "getdate.y"
00276 typedef union YYSTYPE {
00277   int intval;
00278   textint textintval;
00279 } YYSTYPE;
00280 /* Line 191 of yacc.c.  */
00281 #line 281 "getdate.c"
00282 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
00283 # define YYSTYPE_IS_DECLARED 1
00284 # define YYSTYPE_IS_TRIVIAL 1
00285 #endif
00286 
00287 
00288 
00289 /* Copy the second part of user declarations.  */
00290 
00291 
00292 /* Line 214 of yacc.c.  */
00293 #line 293 "getdate.c"
00294 
00295 #if ! defined (yyoverflow) || YYERROR_VERBOSE
00296 
00297 /* The parser invokes alloca or malloc; define the necessary symbols.  */
00298 
00299 # if YYSTACK_USE_ALLOCA
00300 #  define YYSTACK_ALLOC alloca
00301 # else
00302 #  ifndef YYSTACK_USE_ALLOCA
00303 #   if defined (alloca) || defined (_ALLOCA_H)
00304 #    define YYSTACK_ALLOC alloca
00305 #   else
00306 #    ifdef __GNUC__
00307 #     define YYSTACK_ALLOC __builtin_alloca
00308 #    endif
00309 #   endif
00310 #  endif
00311 # endif
00312 
00313 # ifdef YYSTACK_ALLOC
00314    /* Pacify GCC's `empty if-body' warning. */
00315 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
00316 # else
00317 #  if defined (__STDC__) || defined (__cplusplus)
00318 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00319 #   define YYSIZE_T size_t
00320 #  endif
00321 #  define YYSTACK_ALLOC malloc
00322 #  define YYSTACK_FREE free
00323 # endif
00324 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
00325 
00326 
00327 #if (! defined (yyoverflow) \
00328      && (! defined (__cplusplus) \
00329          || (YYSTYPE_IS_TRIVIAL)))
00330 
00331 /* A type that is properly aligned for any stack member.  */
00332 union yyalloc
00333 {
00334   short yyss;
00335   YYSTYPE yyvs;
00336   };
00337 
00338 /* The size of the maximum gap between one aligned stack and the next.  */
00339 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00340 
00341 /* The size of an array large to enough to hold all stacks, each with
00342    N elements.  */
00343 # define YYSTACK_BYTES(N) \
00344      ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
00345       + YYSTACK_GAP_MAXIMUM)
00346 
00347 /* Copy COUNT objects from FROM to TO.  The source and destination do
00348    not overlap.  */
00349 # ifndef YYCOPY
00350 #  if 1 < __GNUC__
00351 #   define YYCOPY(To, From, Count) \
00352       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00353 #  else
00354 #   define YYCOPY(To, From, Count)              \
00355       do                                        \
00356         {                                       \
00357           register YYSIZE_T yyi;                \
00358           for (yyi = 0; yyi < (Count); yyi++)   \
00359             (To)[yyi] = (From)[yyi];            \
00360         }                                       \
00361       while (0)
00362 #  endif
00363 # endif
00364 
00365 /* Relocate STACK from its old location to the new one.  The
00366    local variables YYSIZE and YYSTACKSIZE give the old and new number of
00367    elements in the stack, and YYPTR gives the new location of the
00368    stack.  Advance YYPTR to a properly aligned location for the next
00369    stack.  */
00370 # define YYSTACK_RELOCATE(Stack)                                        \
00371     do                                                                  \
00372       {                                                                 \
00373         YYSIZE_T yynewbytes;                                            \
00374         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
00375         Stack = &yyptr->Stack;                                          \
00376         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00377         yyptr += yynewbytes / sizeof (*yyptr);                          \
00378       }                                                                 \
00379     while (0)
00380 
00381 #endif
00382 
00383 #if defined (__STDC__) || defined (__cplusplus)
00384    typedef signed char yysigned_char;
00385 #else
00386    typedef short yysigned_char;
00387 #endif
00388 
00389 /* YYFINAL -- State number of the termination state. */
00390 #define YYFINAL  2
00391 /* YYLAST -- Last index in YYTABLE.  */
00392 #define YYLAST   52
00393 
00394 /* YYNTOKENS -- Number of terminals. */
00395 #define YYNTOKENS  22
00396 /* YYNNTS -- Number of nonterminals. */
00397 #define YYNNTS  12
00398 /* YYNRULES -- Number of rules. */
00399 #define YYNRULES  54
00400 /* YYNRULES -- Number of states. */
00401 #define YYNSTATES  64
00402 
00403 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
00404 #define YYUNDEFTOK  2
00405 #define YYMAXUTOK   273
00406 
00407 #define YYTRANSLATE(YYX)                                                \
00408   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00409 
00410 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
00411 static const unsigned char yytranslate[] =
00412 {
00413        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00414        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00415        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00416        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00417        2,     2,     2,     2,    20,     2,     2,    21,     2,     2,
00418        2,     2,     2,     2,     2,     2,     2,     2,    19,     2,
00419        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00420        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00421        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00422        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00423        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00424        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00425        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00426        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00427        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00428        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00429        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00430        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00431        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00432        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00433        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00434        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00435        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00436        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00437        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00438        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
00439        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
00440       15,    16,    17,    18
00441 };
00442 
00443 #if YYDEBUG
00444 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
00445    YYRHS.  */
00446 static const unsigned char yyprhs[] =
00447 {
00448        0,     0,     3,     4,     7,     9,    11,    13,    15,    17,
00449       19,    21,    24,    29,    34,    41,    48,    50,    53,    55,
00450       57,    60,    62,    65,    68,    72,    78,    82,    86,    89,
00451       94,    97,   101,   104,   106,   109,   112,   114,   117,   120,
00452      122,   125,   128,   130,   133,   136,   138,   141,   144,   146,
00453      149,   152,   154,   156,   157
00454 };
00455 
00456 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
00457 static const yysigned_char yyrhs[] =
00458 {
00459       23,     0,    -1,    -1,    23,    24,    -1,    25,    -1,    26,
00460       -1,    27,    -1,    29,    -1,    28,    -1,    30,    -1,    32,
00461       -1,    18,    10,    -1,    18,    19,    18,    33,    -1,    18,
00462       19,    18,    17,    -1,    18,    19,    18,    19,    18,    33,
00463       -1,    18,    19,    18,    19,    18,    17,    -1,     9,    -1,
00464        9,     4,    -1,    16,    -1,     7,    -1,    16,     4,    -1,
00465        5,    -1,     5,    20,    -1,    18,     5,    -1,    18,    21,
00466       18,    -1,    18,    21,    18,    21,    18,    -1,    18,    17,
00467       17,    -1,    18,    12,    17,    -1,    12,    18,    -1,    12,
00468       18,    20,    18,    -1,    18,    12,    -1,    18,    12,    18,
00469       -1,    31,     3,    -1,    31,    -1,    18,    15,    -1,    17,
00470       15,    -1,    15,    -1,    18,    13,    -1,    17,    13,    -1,
00471       13,    -1,    18,     6,    -1,    17,     6,    -1,     6,    -1,
00472       18,     8,    -1,    17,     8,    -1,     8,    -1,    18,    11,
00473       -1,    17,    11,    -1,    11,    -1,    18,    14,    -1,    17,
00474       14,    -1,    14,    -1,    18,    -1,    -1,    10,    -1
00475 };
00476 
00477 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
00478 static const unsigned short yyrline[] =
00479 {
00480        0,   188,   188,   190,   194,   196,   198,   200,   202,   204,
00481      206,   210,   217,   224,   232,   239,   251,   253,   258,   260,
00482      262,   267,   272,   277,   285,   290,   310,   317,   325,   330,
00483      336,   341,   350,   359,   363,   365,   367,   369,   371,   373,
00484      375,   377,   379,   381,   383,   385,   387,   389,   391,   393,
00485      395,   397,   402,   439,   440
00486 };
00487 #endif
00488 
00489 #if YYDEBUG || YYERROR_VERBOSE
00490 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
00491    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
00492 static const char *const yytname[] =
00493 {
00494   "$end", "error", "$undefined", "tAGO", "tDST", "tDAY", "tDAY_UNIT", 
00495   "tDAYZONE", "tHOUR_UNIT", "tLOCAL_ZONE", "tMERIDIAN", "tMINUTE_UNIT", 
00496   "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tYEAR_UNIT", "tZONE", "tSNUMBER", 
00497   "tUNUMBER", "':'", "','", "'/'", "$accept", "spec", "item", "time", 
00498   "local_zone", "zone", "day", "date", "rel", "relunit", "number", 
00499   "o_merid", 0
00500 };
00501 #endif
00502 
00503 # ifdef YYPRINT
00504 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
00505    token YYLEX-NUM.  */
00506 static const unsigned short yytoknum[] =
00507 {
00508        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
00509      265,   266,   267,   268,   269,   270,   271,   272,   273,    58,
00510       44,    47
00511 };
00512 # endif
00513 
00514 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
00515 static const unsigned char yyr1[] =
00516 {
00517        0,    22,    23,    23,    24,    24,    24,    24,    24,    24,
00518       24,    25,    25,    25,    25,    25,    26,    26,    27,    27,
00519       27,    28,    28,    28,    29,    29,    29,    29,    29,    29,
00520       29,    29,    30,    30,    31,    31,    31,    31,    31,    31,
00521       31,    31,    31,    31,    31,    31,    31,    31,    31,    31,
00522       31,    31,    32,    33,    33
00523 };
00524 
00525 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
00526 static const unsigned char yyr2[] =
00527 {
00528        0,     2,     0,     2,     1,     1,     1,     1,     1,     1,
00529        1,     2,     4,     4,     6,     6,     1,     2,     1,     1,
00530        2,     1,     2,     2,     3,     5,     3,     3,     2,     4,
00531        2,     3,     2,     1,     2,     2,     1,     2,     2,     1,
00532        2,     2,     1,     2,     2,     1,     2,     2,     1,     2,
00533        2,     1,     1,     0,     1
00534 };
00535 
00536 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
00537    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
00538    means the default is an error.  */
00539 static const unsigned char yydefact[] =
00540 {
00541        2,     0,     1,    21,    42,    19,    45,    16,    48,     0,
00542       39,    51,    36,    18,     0,    52,     3,     4,     5,     6,
00543        8,     7,     9,    33,    10,    22,    17,    28,    20,    41,
00544       44,    47,    38,    50,    35,    23,    40,    43,    11,    46,
00545       30,    37,    49,    34,     0,     0,     0,    32,     0,    27,
00546       31,    26,    53,    24,    29,    54,    13,     0,    12,     0,
00547       53,    25,    15,    14
00548 };
00549 
00550 /* YYDEFGOTO[NTERM-NUM]. */
00551 static const yysigned_char yydefgoto[] =
00552 {
00553       -1,     1,    16,    17,    18,    19,    20,    21,    22,    23,
00554       24,    58
00555 };
00556 
00557 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
00558    STATE-NUM.  */
00559 #define YYPACT_NINF -17
00560 static const yysigned_char yypact[] =
00561 {
00562      -17,     0,   -17,     1,   -17,   -17,   -17,    19,   -17,   -14,
00563      -17,   -17,   -17,    32,    26,    14,   -17,   -17,   -17,   -17,
00564      -17,   -17,   -17,    27,   -17,   -17,   -17,    22,   -17,   -17,
00565      -17,   -17,   -17,   -17,   -17,   -17,   -17,   -17,   -17,   -17,
00566      -16,   -17,   -17,   -17,    29,    25,    30,   -17,    31,   -17,
00567      -17,   -17,    28,    23,   -17,   -17,   -17,    33,   -17,    34,
00568       -7,   -17,   -17,   -17
00569 };
00570 
00571 /* YYPGOTO[NTERM-NUM].  */
00572 static const yysigned_char yypgoto[] =
00573 {
00574      -17,   -17,   -17,   -17,   -17,   -17,   -17,   -17,   -17,   -17,
00575      -17,   -10
00576 };
00577 
00578 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
00579    positive, shift that token.  If negative, reduce the rule which
00580    number is the opposite.  If zero, do what YYDEFACT says.
00581    If YYTABLE_NINF, syntax error.  */
00582 #define YYTABLE_NINF -1
00583 static const unsigned char yytable[] =
00584 {
00585        2,    49,    50,    55,    27,     3,     4,     5,     6,     7,
00586       62,     8,     9,    10,    11,    12,    13,    14,    15,    35,
00587       36,    25,    37,    26,    38,    39,    40,    41,    42,    43,
00588       47,    44,    29,    45,    30,    46,    28,    31,    55,    32,
00589       33,    34,    48,    52,    59,    56,    51,    57,    53,    54,
00590       63,    60,    61
00591 };
00592 
00593 static const unsigned char yycheck[] =
00594 {
00595        0,    17,    18,    10,    18,     5,     6,     7,     8,     9,
00596       17,    11,    12,    13,    14,    15,    16,    17,    18,     5,
00597        6,    20,     8,     4,    10,    11,    12,    13,    14,    15,
00598        3,    17,     6,    19,     8,    21,     4,    11,    10,    13,
00599       14,    15,    20,    18,    21,    17,    17,    19,    18,    18,
00600       60,    18,    18
00601 };
00602 
00603 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
00604    symbol of state STATE-NUM.  */
00605 static const unsigned char yystos[] =
00606 {
00607        0,    23,     0,     5,     6,     7,     8,     9,    11,    12,
00608       13,    14,    15,    16,    17,    18,    24,    25,    26,    27,
00609       28,    29,    30,    31,    32,    20,     4,    18,     4,     6,
00610        8,    11,    13,    14,    15,     5,     6,     8,    10,    11,
00611       12,    13,    14,    15,    17,    19,    21,     3,    20,    17,
00612       18,    17,    18,    18,    18,    10,    17,    19,    33,    21,
00613       18,    18,    17,    33
00614 };
00615 
00616 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
00617 # define YYSIZE_T __SIZE_TYPE__
00618 #endif
00619 #if ! defined (YYSIZE_T) && defined (size_t)
00620 # define YYSIZE_T size_t
00621 #endif
00622 #if ! defined (YYSIZE_T)
00623 # if defined (__STDC__) || defined (__cplusplus)
00624 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
00625 #  define YYSIZE_T size_t
00626 # endif
00627 #endif
00628 #if ! defined (YYSIZE_T)
00629 # define YYSIZE_T unsigned int
00630 #endif
00631 
00632 #define yyerrok         (yyerrstatus = 0)
00633 #define yyclearin       (yychar = YYEMPTY)
00634 #define YYEMPTY         (-2)
00635 #define YYEOF           0
00636 
00637 #define YYACCEPT        goto yyacceptlab
00638 #define YYABORT         goto yyabortlab
00639 #define YYERROR         goto yyerrlab1
00640 
00641 
00642 /* Like YYERROR except do call yyerror.  This remains here temporarily
00643    to ease the transition to the new meaning of YYERROR, for GCC.
00644    Once GCC version 2 has supplanted version 1, this can go.  */
00645 
00646 #define YYFAIL          goto yyerrlab
00647 
00648 #define YYRECOVERING()  (!!yyerrstatus)
00649 
00650 #define YYBACKUP(Token, Value)                                  \
00651 do                                                              \
00652   if (yychar == YYEMPTY && yylen == 1)                          \
00653     {                                                           \
00654       yychar = (Token);                                         \
00655       yylval = (Value);                                         \
00656       yytoken = YYTRANSLATE (yychar);                           \
00657       YYPOPSTACK;                                               \
00658       goto yybackup;                                            \
00659     }                                                           \
00660   else                                                          \
00661     {                                                           \
00662       yyerror ("syntax error: cannot back up");\
00663       YYERROR;                                                  \
00664     }                                                           \
00665 while (0)
00666 
00667 #define YYTERROR        1
00668 #define YYERRCODE       256
00669 
00670 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
00671    are run).  */
00672 
00673 #ifndef YYLLOC_DEFAULT
00674 # define YYLLOC_DEFAULT(Current, Rhs, N)         \
00675   Current.first_line   = Rhs[1].first_line;      \
00676   Current.first_column = Rhs[1].first_column;    \
00677   Current.last_line    = Rhs[N].last_line;       \
00678   Current.last_column  = Rhs[N].last_column;
00679 #endif
00680 
00681 /* YYLEX -- calling `yylex' with the right arguments.  */
00682 
00683 #ifdef YYLEX_PARAM
00684 # define YYLEX yylex (&yylval, YYLEX_PARAM)
00685 #else
00686 # define YYLEX yylex (&yylval)
00687 #endif
00688 
00689 /* Enable debugging if requested.  */
00690 #if YYDEBUG
00691 
00692 # ifndef YYFPRINTF
00693 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
00694 #  define YYFPRINTF fprintf
00695 # endif
00696 
00697 # define YYDPRINTF(Args)                        \
00698 do {                                            \
00699   if (yydebug)                                  \
00700     YYFPRINTF Args;                             \
00701 } while (0)
00702 
00703 # define YYDSYMPRINT(Args)                      \
00704 do {                                            \
00705   if (yydebug)                                  \
00706     yysymprint Args;                            \
00707 } while (0)
00708 
00709 # define YYDSYMPRINTF(Title, Token, Value, Location)            \
00710 do {                                                            \
00711   if (yydebug)                                                  \
00712     {                                                           \
00713       YYFPRINTF (stderr, "%s ", Title);                         \
00714       yysymprint (stderr,                                       \
00715                   Token, Value);        \
00716       YYFPRINTF (stderr, "\n");                                 \
00717     }                                                           \
00718 } while (0)
00719 
00720 /*------------------------------------------------------------------.
00721 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
00722 | TOP (cinluded).                                                   |
00723 `------------------------------------------------------------------*/
00724 
00725 #if defined (__STDC__) || defined (__cplusplus)
00726 static void
00727 yy_stack_print (short *bottom, short *top)
00728 #else
00729 static void
00730 yy_stack_print (bottom, top)
00731     short *bottom;
00732     short *top;
00733 #endif
00734 {
00735   YYFPRINTF (stderr, "Stack now");
00736   for (/* Nothing. */; bottom <= top; ++bottom)
00737     YYFPRINTF (stderr, " %d", *bottom);
00738   YYFPRINTF (stderr, "\n");
00739 }
00740 
00741 # define YY_STACK_PRINT(Bottom, Top)                            \
00742 do {                                                            \
00743   if (yydebug)                                                  \
00744     yy_stack_print ((Bottom), (Top));                           \
00745 } while (0)
00746 
00747 
00748 /*------------------------------------------------.
00749 | Report that the YYRULE is going to be reduced.  |
00750 `------------------------------------------------*/
00751 
00752 #if defined (__STDC__) || defined (__cplusplus)
00753 static void
00754 yy_reduce_print (int yyrule)
00755 #else
00756 static void
00757 yy_reduce_print (yyrule)
00758     int yyrule;
00759 #endif
00760 {
00761   int yyi;
00762   unsigned int yylineno = yyrline[yyrule];
00763   YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
00764              yyrule - 1, yylineno);
00765   /* Print the symbols being reduced, and their result.  */
00766   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
00767     YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
00768   YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
00769 }
00770 
00771 # define YY_REDUCE_PRINT(Rule)          \
00772 do {                                    \
00773   if (yydebug)                          \
00774     yy_reduce_print (Rule);             \
00775 } while (0)
00776 
00777 /* Nonzero means print parse trace.  It is left uninitialized so that
00778    multiple parsers can coexist.  */
00779 int yydebug;
00780 #else /* !YYDEBUG */
00781 # define YYDPRINTF(Args)
00782 # define YYDSYMPRINT(Args)
00783 # define YYDSYMPRINTF(Title, Token, Value, Location)
00784 # define YY_STACK_PRINT(Bottom, Top)
00785 # define YY_REDUCE_PRINT(Rule)
00786 #endif /* !YYDEBUG */
00787 
00788 
00789 /* YYINITDEPTH -- initial size of the parser's stacks.  */
00790 #ifndef YYINITDEPTH
00791 # define YYINITDEPTH 200
00792 #endif
00793 
00794 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
00795    if the built-in stack extension method is used).
00796 
00797    Do not make this value too large; the results are undefined if
00798    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
00799    evaluated with infinite-precision integer arithmetic.  */
00800 
00801 #if YYMAXDEPTH == 0
00802 # undef YYMAXDEPTH
00803 #endif
00804 
00805 #ifndef YYMAXDEPTH
00806 # define YYMAXDEPTH 10000
00807 #endif
00808 
00809 
00810 
00811 #if YYERROR_VERBOSE
00812 
00813 # ifndef yystrlen
00814 #  if defined (__GLIBC__) && defined (_STRING_H)
00815 #   define yystrlen strlen
00816 #  else
00817 /* Return the length of YYSTR.  */
00818 static YYSIZE_T
00819 #   if defined (__STDC__) || defined (__cplusplus)
00820 yystrlen (const char *yystr)
00821 #   else
00822 yystrlen (yystr)
00823      const char *yystr;
00824 #   endif
00825 {
00826   register const char *yys = yystr;
00827 
00828   while (*yys++ != '\0')
00829     continue;
00830 
00831   return yys - yystr - 1;
00832 }
00833 #  endif
00834 # endif
00835 
00836 # ifndef yystpcpy
00837 #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
00838 #   define yystpcpy stpcpy
00839 #  else
00840 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
00841    YYDEST.  */
00842 static char *
00843 #   if defined (__STDC__) || defined (__cplusplus)
00844 yystpcpy (char *yydest, const char *yysrc)
00845 #   else
00846 yystpcpy (yydest, yysrc)
00847      char *yydest;
00848      const char *yysrc;
00849 #   endif
00850 {
00851   register char *yyd = yydest;
00852   register const char *yys = yysrc;
00853 
00854   while ((*yyd++ = *yys++) != '\0')
00855     continue;
00856 
00857   return yyd - 1;
00858 }
00859 #  endif
00860 # endif
00861 
00862 #endif /* !YYERROR_VERBOSE */
00863 
00864 
00865 
00866 #if YYDEBUG
00867 /*--------------------------------.
00868 | Print this symbol on YYOUTPUT.  |
00869 `--------------------------------*/
00870 
00871 #if defined (__STDC__) || defined (__cplusplus)
00872 static void
00873 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
00874 #else
00875 static void
00876 yysymprint (yyoutput, yytype, yyvaluep)
00877     FILE *yyoutput;
00878     int yytype;
00879     YYSTYPE *yyvaluep;
00880 #endif
00881 {
00882   /* Pacify ``unused variable'' warnings.  */
00883   (void) yyvaluep;
00884 
00885   if (yytype < YYNTOKENS)
00886     {
00887       YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00888 # ifdef YYPRINT
00889       YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00890 # endif
00891     }
00892   else
00893     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00894 
00895   switch (yytype)
00896     {
00897       default:
00898         break;
00899     }
00900   YYFPRINTF (yyoutput, ")");
00901 }
00902 
00903 #endif /* ! YYDEBUG */
00904 /*-----------------------------------------------.
00905 | Release the memory associated to this symbol.  |
00906 `-----------------------------------------------*/
00907 
00908 #if defined (__STDC__) || defined (__cplusplus)
00909 static void
00910 yydestruct (int yytype, YYSTYPE *yyvaluep)
00911 #else
00912 static void
00913 yydestruct (yytype, yyvaluep)
00914     int yytype;
00915     YYSTYPE *yyvaluep;
00916 #endif
00917 {
00918   /* Pacify ``unused variable'' warnings.  */
00919   (void) yyvaluep;
00920 
00921   switch (yytype)
00922     {
00923 
00924       default:
00925         break;
00926     }
00927 }
00928 
00929 
00930 /* Prevent warnings from -Wmissing-prototypes.  */
00931 
00932 #ifdef YYPARSE_PARAM
00933 # if defined (__STDC__) || defined (__cplusplus)
00934 int yyparse (void *YYPARSE_PARAM);
00935 # else
00936 int yyparse ();
00937 # endif
00938 #else /* ! YYPARSE_PARAM */
00939 #if defined (__STDC__) || defined (__cplusplus)
00940 int yyparse (void);
00941 #else
00942 int yyparse ();
00943 #endif
00944 #endif /* ! YYPARSE_PARAM */
00945 
00946 
00947 
00948 
00949 
00950 
00951 /*----------.
00952 | yyparse.  |
00953 `----------*/
00954 
00955 #ifdef YYPARSE_PARAM
00956 # if defined (__STDC__) || defined (__cplusplus)
00957 int yyparse (void *YYPARSE_PARAM)
00958 # else
00959 int yyparse (YYPARSE_PARAM)
00960   void *YYPARSE_PARAM;
00961 # endif
00962 #else /* ! YYPARSE_PARAM */
00963 #if defined (__STDC__) || defined (__cplusplus)
00964 int
00965 yyparse (void)
00966 #else
00967 int
00968 yyparse ()
00969 
00970 #endif
00971 #endif
00972 {
00973   /* The lookahead symbol.  */
00974 int yychar;
00975 
00976 /* The semantic value of the lookahead symbol.  */
00977 YYSTYPE yylval;
00978 
00979 /* Number of syntax errors so far.  */
00980 int yynerrs;
00981 
00982   register int yystate;
00983   register int yyn;
00984   int yyresult;
00985   /* Number of tokens to shift before error messages enabled.  */
00986   int yyerrstatus;
00987   /* Lookahead token as an internal (translated) token number.  */
00988   int yytoken = 0;
00989 
00990   /* Three stacks and their tools:
00991      `yyss': related to states,
00992      `yyvs': related to semantic values,
00993      `yyls': related to locations.
00994 
00995      Refer to the stacks thru separate pointers, to allow yyoverflow
00996      to reallocate them elsewhere.  */
00997 
00998   /* The state stack.  */
00999   short yyssa[YYINITDEPTH];
01000   short *yyss = yyssa;
01001   register short *yyssp;
01002 
01003   /* The semantic value stack.  */
01004   YYSTYPE yyvsa[YYINITDEPTH];
01005   YYSTYPE *yyvs = yyvsa;
01006   register YYSTYPE *yyvsp;
01007 
01008 
01009 
01010 #define YYPOPSTACK   (yyvsp--, yyssp--)
01011 
01012   YYSIZE_T yystacksize = YYINITDEPTH;
01013 
01014   /* The variables used to return semantic value and location from the
01015      action routines.  */
01016   YYSTYPE yyval;
01017 
01018 
01019   /* When reducing, the number of symbols on the RHS of the reduced
01020      rule.  */
01021   int yylen;
01022 
01023   YYDPRINTF ((stderr, "Starting parse\n"));
01024 
01025   yystate = 0;
01026   yyerrstatus = 0;
01027   yynerrs = 0;
01028   yychar = YYEMPTY;             /* Cause a token to be read.  */
01029 
01030   /* Initialize stack pointers.
01031      Waste one element of value and location stack
01032      so that they stay on the same level as the state stack.
01033      The wasted elements are never initialized.  */
01034 
01035   yyssp = yyss;
01036   yyvsp = yyvs;
01037 
01038   goto yysetstate;
01039 
01040 /*------------------------------------------------------------.
01041 | yynewstate -- Push a new state, which is found in yystate.  |
01042 `------------------------------------------------------------*/
01043  yynewstate:
01044   /* In all cases, when you get here, the value and location stacks
01045      have just been pushed. so pushing a state here evens the stacks.
01046      */
01047   yyssp++;
01048 
01049  yysetstate:
01050   *yyssp = yystate;
01051 
01052   if (yyss + yystacksize - 1 <= yyssp)
01053     {
01054       /* Get the current used size of the three stacks, in elements.  */
01055       YYSIZE_T yysize = yyssp - yyss + 1;
01056 
01057 #ifdef yyoverflow
01058       {
01059         /* Give user a chance to reallocate the stack. Use copies of
01060            these so that the &'s don't force the real ones into
01061            memory.  */
01062         YYSTYPE *yyvs1 = yyvs;
01063         short *yyss1 = yyss;
01064 
01065 
01066         /* Each stack pointer address is followed by the size of the
01067            data in use in that stack, in bytes.  This used to be a
01068            conditional around just the two extra args, but that might
01069            be undefined if yyoverflow is a macro.  */
01070         yyoverflow ("parser stack overflow",
01071                     &yyss1, yysize * sizeof (*yyssp),
01072                     &yyvs1, yysize * sizeof (*yyvsp),
01073 
01074                     &yystacksize);
01075 
01076         yyss = yyss1;
01077         yyvs = yyvs1;
01078       }
01079 #else /* no yyoverflow */
01080 # ifndef YYSTACK_RELOCATE
01081       goto yyoverflowlab;
01082 # else
01083       /* Extend the stack our own way.  */
01084       if (YYMAXDEPTH <= yystacksize)
01085         goto yyoverflowlab;
01086       yystacksize *= 2;
01087       if (YYMAXDEPTH < yystacksize)
01088         yystacksize = YYMAXDEPTH;
01089 
01090       {
01091         short *yyss1 = yyss;
01092         union yyalloc *yyptr =
01093           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01094         if (! yyptr)
01095           goto yyoverflowlab;
01096         YYSTACK_RELOCATE (yyss);
01097         YYSTACK_RELOCATE (yyvs);
01098 
01099 #  undef YYSTACK_RELOCATE
01100         if (yyss1 != yyssa)
01101           YYSTACK_FREE (yyss1);
01102       }
01103 # endif
01104 #endif /* no yyoverflow */
01105 
01106       yyssp = yyss + yysize - 1;
01107       yyvsp = yyvs + yysize - 1;
01108 
01109 
01110       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01111                   (unsigned long int) yystacksize));
01112 
01113       if (yyss + yystacksize - 1 <= yyssp)
01114         YYABORT;
01115     }
01116 
01117   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01118 
01119   goto yybackup;
01120 
01121 /*-----------.
01122 | yybackup.  |
01123 `-----------*/
01124 yybackup:
01125 
01126 /* Do appropriate processing given the current state.  */
01127 /* Read a lookahead token if we need one and don't already have one.  */
01128 /* yyresume: */
01129 
01130   /* First try to decide what to do without reference to lookahead token.  */
01131 
01132   yyn = yypact[yystate];
01133   if (yyn == YYPACT_NINF)
01134     goto yydefault;
01135 
01136   /* Not known => get a lookahead token if don't already have one.  */
01137 
01138   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
01139   if (yychar == YYEMPTY)
01140     {
01141       YYDPRINTF ((stderr, "Reading a token: "));
01142       yychar = YYLEX;
01143     }
01144 
01145   if (yychar <= YYEOF)
01146     {
01147       yychar = yytoken = YYEOF;
01148       YYDPRINTF ((stderr, "Now at end of input.\n"));
01149     }
01150   else
01151     {
01152       yytoken = YYTRANSLATE (yychar);
01153       YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
01154     }
01155 
01156   /* If the proper action on seeing token YYTOKEN is to reduce or to
01157      detect an error, take that action.  */
01158   yyn += yytoken;
01159   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01160     goto yydefault;
01161   yyn = yytable[yyn];
01162   if (yyn <= 0)
01163     {
01164       if (yyn == 0 || yyn == YYTABLE_NINF)
01165         goto yyerrlab;
01166       yyn = -yyn;
01167       goto yyreduce;
01168     }
01169 
01170   if (yyn == YYFINAL)
01171     YYACCEPT;
01172 
01173   /* Shift the lookahead token.  */
01174   YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
01175 
01176   /* Discard the token being shifted unless it is eof.  */
01177   if (yychar != YYEOF)
01178     yychar = YYEMPTY;
01179 
01180   *++yyvsp = yylval;
01181 
01182 
01183   /* Count tokens shifted since error; after three, turn off error
01184      status.  */
01185   if (yyerrstatus)
01186     yyerrstatus--;
01187 
01188   yystate = yyn;
01189   goto yynewstate;
01190 
01191 
01192 /*-----------------------------------------------------------.
01193 | yydefault -- do the default action for the current state.  |
01194 `-----------------------------------------------------------*/
01195 yydefault:
01196   yyn = yydefact[yystate];
01197   if (yyn == 0)
01198     goto yyerrlab;
01199   goto yyreduce;
01200 
01201 
01202 /*-----------------------------.
01203 | yyreduce -- Do a reduction.  |
01204 `-----------------------------*/
01205 yyreduce:
01206   /* yyn is the number of a rule to reduce with.  */
01207   yylen = yyr2[yyn];
01208 
01209   /* If YYLEN is nonzero, implement the default value of the action:
01210      `$$ = $1'.
01211 
01212      Otherwise, the following line sets YYVAL to garbage.
01213      This behavior is undocumented and Bison
01214      users should not rely upon it.  Assigning to YYVAL
01215      unconditionally makes the parser a bit smaller, and it avoids a
01216      GCC warning that YYVAL may be used uninitialized.  */
01217   yyval = yyvsp[1-yylen];
01218 
01219 
01220   YY_REDUCE_PRINT (yyn);
01221   switch (yyn)
01222     {
01223         case 4:
01224 #line 195 "getdate.y"
01225     { PC.times_seen++; }
01226     break;
01227 
01228   case 5:
01229 #line 197 "getdate.y"
01230     { PC.local_zones_seen++; }
01231     break;
01232 
01233   case 6:
01234 #line 199 "getdate.y"
01235     { PC.zones_seen++; }
01236     break;
01237 
01238   case 7:
01239 #line 201 "getdate.y"
01240     { PC.dates_seen++; }
01241     break;
01242 
01243   case 8:
01244 #line 203 "getdate.y"
01245     { PC.days_seen++; }
01246     break;
01247 
01248   case 9:
01249 #line 205 "getdate.y"
01250     { PC.rels_seen++; }
01251     break;
01252 
01253   case 11:
01254 #line 211 "getdate.y"
01255     {
01256         PC.hour = yyvsp[-1].textintval.value;
01257         PC.minutes = 0;
01258         PC.seconds = 0;
01259         PC.meridian = yyvsp[0].intval;
01260       }
01261     break;
01262 
01263   case 12:
01264 #line 218 "getdate.y"
01265     {
01266         PC.hour = yyvsp[-3].textintval.value;
01267         PC.minutes = yyvsp[-1].textintval.value;
01268         PC.seconds = 0;
01269         PC.meridian = yyvsp[0].intval;
01270       }
01271     break;
01272 
01273   case 13:
01274 #line 225 "getdate.y"
01275     {
01276         PC.hour = yyvsp[-3].textintval.value;
01277         PC.minutes = yyvsp[-1].textintval.value;
01278         PC.meridian = MER24;
01279         PC.zones_seen++;
01280         PC.time_zone = yyvsp[0].textintval.value % 100 + (yyvsp[0].textintval.value / 100) * 60;
01281       }
01282     break;
01283 
01284   case 14:
01285 #line 233 "getdate.y"
01286     {
01287         PC.hour = yyvsp[-5].textintval.value;
01288         PC.minutes = yyvsp[-3].textintval.value;
01289         PC.seconds = yyvsp[-1].textintval.value;
01290         PC.meridian = yyvsp[0].intval;
01291       }
01292     break;
01293 
01294   case 15:
01295 #line 240 "getdate.y"
01296     {
01297         PC.hour = yyvsp[-5].textintval.value;
01298         PC.minutes = yyvsp[-3].textintval.value;
01299         PC.seconds = yyvsp[-1].textintval.value;
01300         PC.meridian = MER24;
01301         PC.zones_seen++;
01302         PC.time_zone = yyvsp[0].textintval.value % 100 + (yyvsp[0].textintval.value / 100) * 60;
01303       }
01304     break;
01305 
01306   case 16:
01307 #line 252 "getdate.y"
01308     { PC.local_isdst = yyvsp[0].intval; }
01309     break;
01310 
01311   case 17:
01312 #line 254 "getdate.y"
01313     { PC.local_isdst = yyvsp[-1].intval < 0 ? 1 : yyvsp[-1].intval + 1; }
01314     break;
01315 
01316   case 18:
01317 #line 259 "getdate.y"
01318     { PC.time_zone = yyvsp[0].intval; }
01319     break;
01320 
01321   case 19:
01322 #line 261 "getdate.y"
01323     { PC.time_zone = yyvsp[0].intval + 60; }
01324     break;
01325 
01326   case 20:
01327 #line 263 "getdate.y"
01328     { PC.time_zone = yyvsp[-1].intval + 60; }
01329     break;
01330 
01331   case 21:
01332 #line 268 "getdate.y"
01333     {
01334         PC.day_ordinal = 1;
01335         PC.day_number = yyvsp[0].intval;
01336       }
01337     break;
01338 
01339   case 22:
01340 #line 273 "getdate.y"
01341     {
01342         PC.day_ordinal = 1;
01343         PC.day_number = yyvsp[-1].intval;
01344       }
01345     break;
01346 
01347   case 23:
01348 #line 278 "getdate.y"
01349     {
01350         PC.day_ordinal = yyvsp[-1].textintval.value;
01351         PC.day_number = yyvsp[0].intval;
01352       }
01353     break;
01354 
01355   case 24:
01356 #line 286 "getdate.y"
01357     {
01358         PC.month = yyvsp[-2].textintval.value;
01359         PC.day = yyvsp[0].textintval.value;
01360       }
01361     break;
01362 
01363   case 25:
01364 #line 291 "getdate.y"
01365     {
01366         /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
01367            otherwise as MM/DD/YY.
01368            The goal in recognizing YYYY/MM/DD is solely to support legacy
01369            machine-generated dates like those in an RCS log listing.  If
01370            you want portability, use the ISO 8601 format.  */
01371         if (4 <= yyvsp[-4].textintval.digits)
01372           {
01373             PC.year = yyvsp[-4].textintval;
01374             PC.month = yyvsp[-2].textintval.value;
01375             PC.day = yyvsp[0].textintval.value;
01376           }
01377         else
01378           {
01379             PC.month = yyvsp[-4].textintval.value;
01380             PC.day = yyvsp[-2].textintval.value;
01381             PC.year = yyvsp[0].textintval;
01382           }
01383       }
01384     break;
01385 
01386   case 26:
01387 #line 311 "getdate.y"
01388     {
01389         /* ISO 8601 format.  YYYY-MM-DD.  */
01390         PC.year = yyvsp[-2].textintval;
01391         PC.month = -yyvsp[-1].textintval.value;
01392         PC.day = -yyvsp[0].textintval.value;
01393       }
01394     break;
01395 
01396   case 27:
01397 #line 318 "getdate.y"
01398     {
01399         /* e.g. 17-JUN-1992.  */
01400         PC.day = yyvsp[-2].textintval.value;
01401         PC.month = yyvsp[-1].intval;
01402         PC.year.value = -yyvsp[0].textintval.value;
01403         PC.year.digits = yyvsp[0].textintval.digits;
01404       }
01405     break;
01406 
01407   case 28:
01408 #line 326 "getdate.y"
01409     {
01410         PC.month = yyvsp[-1].intval;
01411         PC.day = yyvsp[0].textintval.value;
01412       }
01413     break;
01414 
01415   case 29:
01416 #line 331 "getdate.y"
01417     {
01418         PC.month = yyvsp[-3].intval;
01419         PC.day = yyvsp[-2].textintval.value;
01420         PC.year = yyvsp[0].textintval;
01421       }
01422     break;
01423 
01424   case 30:
01425 #line 337 "getdate.y"
01426     {
01427         PC.day = yyvsp[-1].textintval.value;
01428         PC.month = yyvsp[0].intval;
01429       }
01430     break;
01431 
01432   case 31:
01433 #line 342 "getdate.y"
01434     {
01435         PC.day = yyvsp[-2].textintval.value;
01436         PC.month = yyvsp[-1].intval;
01437         PC.year = yyvsp[0].textintval;
01438       }
01439     break;
01440 
01441   case 32:
01442 #line 351 "getdate.y"
01443     {
01444         PC.rel_seconds = -PC.rel_seconds;
01445         PC.rel_minutes = -PC.rel_minutes;
01446         PC.rel_hour = -PC.rel_hour;
01447         PC.rel_day = -PC.rel_day;
01448         PC.rel_month = -PC.rel_month;
01449         PC.rel_year = -PC.rel_year;
01450       }
01451     break;
01452 
01453   case 34:
01454 #line 364 "getdate.y"
01455     { PC.rel_year += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01456     break;
01457 
01458   case 35:
01459 #line 366 "getdate.y"
01460     { PC.rel_year += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01461     break;
01462 
01463   case 36:
01464 #line 368 "getdate.y"
01465     { PC.rel_year += yyvsp[0].intval; }
01466     break;
01467 
01468   case 37:
01469 #line 370 "getdate.y"
01470     { PC.rel_month += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01471     break;
01472 
01473   case 38:
01474 #line 372 "getdate.y"
01475     { PC.rel_month += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01476     break;
01477 
01478   case 39:
01479 #line 374 "getdate.y"
01480     { PC.rel_month += yyvsp[0].intval; }
01481     break;
01482 
01483   case 40:
01484 #line 376 "getdate.y"
01485     { PC.rel_day += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01486     break;
01487 
01488   case 41:
01489 #line 378 "getdate.y"
01490     { PC.rel_day += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01491     break;
01492 
01493   case 42:
01494 #line 380 "getdate.y"
01495     { PC.rel_day += yyvsp[0].intval; }
01496     break;
01497 
01498   case 43:
01499 #line 382 "getdate.y"
01500     { PC.rel_hour += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01501     break;
01502 
01503   case 44:
01504 #line 384 "getdate.y"
01505     { PC.rel_hour += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01506     break;
01507 
01508   case 45:
01509 #line 386 "getdate.y"
01510     { PC.rel_hour += yyvsp[0].intval; }
01511     break;
01512 
01513   case 46:
01514 #line 388 "getdate.y"
01515     { PC.rel_minutes += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01516     break;
01517 
01518   case 47:
01519 #line 390 "getdate.y"
01520     { PC.rel_minutes += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01521     break;
01522 
01523   case 48:
01524 #line 392 "getdate.y"
01525     { PC.rel_minutes += yyvsp[0].intval; }
01526     break;
01527 
01528   case 49:
01529 #line 394 "getdate.y"
01530     { PC.rel_seconds += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01531     break;
01532 
01533   case 50:
01534 #line 396 "getdate.y"
01535     { PC.rel_seconds += yyvsp[-1].textintval.value * yyvsp[0].intval; }
01536     break;
01537 
01538   case 51:
01539 #line 398 "getdate.y"
01540     { PC.rel_seconds += yyvsp[0].intval; }
01541     break;
01542 
01543   case 52:
01544 #line 403 "getdate.y"
01545     {
01546         if (PC.dates_seen
01547             && ! PC.rels_seen && (PC.times_seen || 2 < yyvsp[0].textintval.digits))
01548           PC.year = yyvsp[0].textintval;
01549         else
01550           {
01551             if (4 < yyvsp[0].textintval.digits)
01552               {
01553                 PC.dates_seen++;
01554                 PC.day = yyvsp[0].textintval.value % 100;
01555                 PC.month = (yyvsp[0].textintval.value / 100) % 100;
01556                 PC.year.value = yyvsp[0].textintval.value / 10000;
01557                 PC.year.digits = yyvsp[0].textintval.digits - 4;
01558               }
01559             else
01560               {
01561                 PC.times_seen++;
01562                 if (yyvsp[0].textintval.digits <= 2)
01563                   {
01564                     PC.hour = yyvsp[0].textintval.value;
01565                     PC.minutes = 0;
01566                   }
01567                 else
01568                   {
01569                     PC.hour = yyvsp[0].textintval.value / 100;
01570                     PC.minutes = yyvsp[0].textintval.value % 100;
01571                   }
01572                 PC.seconds = 0;
01573                 PC.meridian = MER24;
01574               }
01575           }
01576       }
01577     break;
01578 
01579   case 53:
01580 #line 439 "getdate.y"
01581     { yyval.intval = MER24; }
01582     break;
01583 
01584   case 54:
01585 #line 441 "getdate.y"
01586     { yyval.intval = yyvsp[0].intval; }
01587     break;
01588 
01589 
01590     }
01591 
01592 /* Line 999 of yacc.c.  */
01593 #line 1593 "getdate.c"
01594 
01595   yyvsp -= yylen;
01596   yyssp -= yylen;
01597 
01598 
01599   YY_STACK_PRINT (yyss, yyssp);
01600 
01601   *++yyvsp = yyval;
01602 
01603 
01604   /* Now `shift' the result of the reduction.  Determine what state
01605      that goes to, based on the state we popped back to and the rule
01606      number reduced by.  */
01607 
01608   yyn = yyr1[yyn];
01609 
01610   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
01611   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01612     yystate = yytable[yystate];
01613   else
01614     yystate = yydefgoto[yyn - YYNTOKENS];
01615 
01616   goto yynewstate;
01617 
01618 
01619 /*------------------------------------.
01620 | yyerrlab -- here on detecting error |
01621 `------------------------------------*/
01622 yyerrlab:
01623   /* If not already recovering from an error, report this error.  */
01624   if (!yyerrstatus)
01625     {
01626       ++yynerrs;
01627 #if YYERROR_VERBOSE
01628       yyn = yypact[yystate];
01629 
01630       if (YYPACT_NINF < yyn && yyn < YYLAST)
01631         {
01632           YYSIZE_T yysize = 0;
01633           int yytype = YYTRANSLATE (yychar);
01634           char *yymsg;
01635           int yyx, yycount;
01636 
01637           yycount = 0;
01638           /* Start YYX at -YYN if negative to avoid negative indexes in
01639              YYCHECK.  */
01640           for (yyx = yyn < 0 ? -yyn : 0;
01641                yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
01642             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01643               yysize += yystrlen (yytname[yyx]) + 15, yycount++;
01644           yysize += yystrlen ("syntax error, unexpected ") + 1;
01645           yysize += yystrlen (yytname[yytype]);
01646           yymsg = (char *) YYSTACK_ALLOC (yysize);
01647           if (yymsg != 0)
01648             {
01649               char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
01650               yyp = yystpcpy (yyp, yytname[yytype]);
01651 
01652               if (yycount < 5)
01653                 {
01654                   yycount = 0;
01655                   for (yyx = yyn < 0 ? -yyn : 0;
01656                        yyx < (int) (sizeof (yytname) / sizeof (char *));
01657                        yyx++)
01658                     if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01659                       {
01660                         const char *yyq = ! yycount ? ", expecting " : " or ";
01661                         yyp = yystpcpy (yyp, yyq);
01662                         yyp = yystpcpy (yyp, yytname[yyx]);
01663                         yycount++;
01664                       }
01665                 }
01666               yyerror (yymsg);
01667               YYSTACK_FREE (yymsg);
01668             }
01669           else
01670             yyerror ("syntax error; also virtual memory exhausted");
01671         }
01672       else
01673 #endif /* YYERROR_VERBOSE */
01674         yyerror ("syntax error");
01675     }
01676 
01677 
01678 
01679   if (yyerrstatus == 3)
01680     {
01681       /* If just tried and failed to reuse lookahead token after an
01682          error, discard it.  */
01683 
01684       /* Return failure if at end of input.  */
01685       if (yychar == YYEOF)
01686         {
01687           /* Pop the error token.  */
01688           YYPOPSTACK;
01689           /* Pop the rest of the stack.  */
01690           while (yyss < yyssp)
01691             {
01692               YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
01693               yydestruct (yystos[*yyssp], yyvsp);
01694               YYPOPSTACK;
01695             }
01696           YYABORT;
01697         }
01698 
01699       YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
01700       yydestruct (yytoken, &yylval);
01701       yychar = YYEMPTY;
01702 
01703     }
01704 
01705   /* Else will try to reuse lookahead token after shifting the error
01706      token.  */
01707   goto yyerrlab1;
01708 
01709 
01710 /*----------------------------------------------------.
01711 | yyerrlab1 -- error raised explicitly by an action.  |
01712 `----------------------------------------------------*/
01713 yyerrlab1:
01714   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
01715 
01716   for (;;)
01717     {
01718       yyn = yypact[yystate];
01719       if (yyn != YYPACT_NINF)
01720         {
01721           yyn += YYTERROR;
01722           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
01723             {
01724               yyn = yytable[yyn];
01725               if (0 < yyn)
01726                 break;
01727             }
01728         }
01729 
01730       /* Pop the current state because it cannot handle the error token.  */
01731       if (yyssp == yyss)
01732         YYABORT;
01733 
01734       YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
01735       yydestruct (yystos[yystate], yyvsp);
01736       yyvsp--;
01737       yystate = *--yyssp;
01738 
01739       YY_STACK_PRINT (yyss, yyssp);
01740     }
01741 
01742   if (yyn == YYFINAL)
01743     YYACCEPT;
01744 
01745   YYDPRINTF ((stderr, "Shifting error token, "));
01746 
01747   *++yyvsp = yylval;
01748 
01749 
01750   yystate = yyn;
01751   goto yynewstate;
01752 
01753 
01754 /*-------------------------------------.
01755 | yyacceptlab -- YYACCEPT comes here.  |
01756 `-------------------------------------*/
01757 yyacceptlab:
01758   yyresult = 0;
01759   goto yyreturn;
01760 
01761 /*-----------------------------------.
01762 | yyabortlab -- YYABORT comes here.  |
01763 `-----------------------------------*/
01764 yyabortlab:
01765   yyresult = 1;
01766   goto yyreturn;
01767 
01768 #ifndef yyoverflow
01769 /*----------------------------------------------.
01770 | yyoverflowlab -- parser overflow comes here.  |
01771 `----------------------------------------------*/
01772 yyoverflowlab:
01773   yyerror ("parser stack overflow");
01774   yyresult = 2;
01775   /* Fall through.  */
01776 #endif
01777 
01778 yyreturn:
01779 #ifndef yyoverflow
01780   if (yyss != yyssa)
01781     YYSTACK_FREE (yyss);
01782 #endif
01783   return yyresult;
01784 }
01785 
01786 
01787 #line 444 "getdate.y"
01788 
01789 
01790 /* Include this file down here because bison inserts code above which
01791    may define-away `const'.  We want the prototype for get_date to have
01792    the same signature as the function definition.  */
01793 #include "modules/getdate.h"
01794 
01795 #ifndef gmtime
01796 struct tm *gmtime ();
01797 #endif
01798 #ifndef localtime
01799 struct tm *localtime ();
01800 #endif
01801 #ifndef mktime
01802 time_t mktime ();
01803 #endif
01804 
01805 static table const meridian_table[] =
01806 {
01807   { "AM",   tMERIDIAN, MERam },
01808   { "A.M.", tMERIDIAN, MERam },
01809   { "PM",   tMERIDIAN, MERpm },
01810   { "P.M.", tMERIDIAN, MERpm },
01811   { 0, 0, 0 }
01812 };
01813 
01814 static table const dst_table[] =
01815 {
01816   { "DST", tDST, 0 }
01817 };
01818 
01819 static table const month_and_day_table[] =
01820 {
01821   { "JANUARY",  tMONTH,  1 },
01822   { "FEBRUARY", tMONTH,  2 },
01823   { "MARCH",    tMONTH,  3 },
01824   { "APRIL",    tMONTH,  4 },
01825   { "MAY",      tMONTH,  5 },
01826   { "JUNE",     tMONTH,  6 },
01827   { "JULY",     tMONTH,  7 },
01828   { "AUGUST",   tMONTH,  8 },
01829   { "SEPTEMBER",tMONTH,  9 },
01830   { "SEPT",     tMONTH,  9 },
01831   { "OCTOBER",  tMONTH, 10 },
01832   { "NOVEMBER", tMONTH, 11 },
01833   { "DECEMBER", tMONTH, 12 },
01834   { "SUNDAY",   tDAY,    0 },
01835   { "MONDAY",   tDAY,    1 },
01836   { "TUESDAY",  tDAY,    2 },
01837   { "TUES",     tDAY,    2 },
01838   { "WEDNESDAY",tDAY,    3 },
01839   { "WEDNES",   tDAY,    3 },
01840   { "THURSDAY", tDAY,    4 },
01841   { "THUR",     tDAY,    4 },
01842   { "THURS",    tDAY,    4 },
01843   { "FRIDAY",   tDAY,    5 },
01844   { "SATURDAY", tDAY,    6 },
01845   { 0, 0, 0 }
01846 };
01847 
01848 static table const time_units_table[] =
01849 {
01850   { "YEAR",     tYEAR_UNIT,      1 },
01851   { "MONTH",    tMONTH_UNIT,     1 },
01852   { "FORTNIGHT",tDAY_UNIT,      14 },
01853   { "WEEK",     tDAY_UNIT,       7 },
01854   { "DAY",      tDAY_UNIT,       1 },
01855   { "HOUR",     tHOUR_UNIT,      1 },
01856   { "MINUTE",   tMINUTE_UNIT,    1 },
01857   { "MIN",      tMINUTE_UNIT,    1 },
01858   { "SECOND",   tSEC_UNIT,       1 },
01859   { "SEC",      tSEC_UNIT,       1 },
01860   { 0, 0, 0 }
01861 };
01862 
01863 /* Assorted relative-time words. */
01864 static table const relative_time_table[] =
01865 {
01866   { "TOMORROW", tMINUTE_UNIT,   24 * 60 },
01867   { "YESTERDAY",tMINUTE_UNIT,   - (24 * 60) },
01868   { "TODAY",    tMINUTE_UNIT,    0 },
01869   { "NOW",      tMINUTE_UNIT,    0 },
01870   { "LAST",     tUNUMBER,       -1 },
01871   { "THIS",     tUNUMBER,        0 },
01872   { "NEXT",     tUNUMBER,        1 },
01873   { "FIRST",    tUNUMBER,        1 },
01874 /*{ "SECOND",   tUNUMBER,        2 }, */
01875   { "THIRD",    tUNUMBER,        3 },
01876   { "FOURTH",   tUNUMBER,        4 },
01877   { "FIFTH",    tUNUMBER,        5 },
01878   { "SIXTH",    tUNUMBER,        6 },
01879   { "SEVENTH",  tUNUMBER,        7 },
01880   { "EIGHTH",   tUNUMBER,        8 },
01881   { "NINTH",    tUNUMBER,        9 },
01882   { "TENTH",    tUNUMBER,       10 },
01883   { "ELEVENTH", tUNUMBER,       11 },
01884   { "TWELFTH",  tUNUMBER,       12 },
01885   { "AGO",      tAGO,            1 },
01886   { 0, 0, 0 }
01887 };
01888 
01889 /* The time zone table.  This table is necessarily incomplete, as time
01890    zone abbreviations are ambiguous; e.g. Australians interpret "EST"
01891    as Eastern time in Australia, not as US Eastern Standard Time.
01892    You cannot rely on getdate to handle arbitrary time zone
01893    abbreviations; use numeric abbreviations like `-0500' instead.  */
01894 static table const time_zone_table[] =
01895 {
01896   { "GMT",      tZONE,     HOUR ( 0) }, /* Greenwich Mean */
01897   { "UT",       tZONE,     HOUR ( 0) }, /* Universal (Coordinated) */
01898   { "UTC",      tZONE,     HOUR ( 0) },
01899   { "WET",      tZONE,     HOUR ( 0) }, /* Western European */
01900   { "WEST",     tDAYZONE,  HOUR ( 0) }, /* Western European Summer */
01901   { "BST",      tDAYZONE,  HOUR ( 0) }, /* British Summer */
01902   { "ART",      tZONE,    -HOUR ( 3) }, /* Argentina */
01903   { "BRT",      tZONE,    -HOUR ( 3) }, /* Brazil */
01904   { "BRST",     tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */
01905   { "NST",      tZONE,   -(HOUR ( 3) + 30) },   /* Newfoundland Standard */
01906   { "NDT",      tDAYZONE,-(HOUR ( 3) + 30) },   /* Newfoundland Daylight */
01907   { "AST",      tZONE,    -HOUR ( 4) }, /* Atlantic Standard */
01908   { "ADT",      tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */
01909   { "CLT",      tZONE,    -HOUR ( 4) }, /* Chile */
01910   { "CLST",     tDAYZONE, -HOUR ( 4) }, /* Chile Summer */
01911   { "EST",      tZONE,    -HOUR ( 5) }, /* Eastern Standard */
01912   { "EDT",      tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */
01913   { "CST",      tZONE,    -HOUR ( 6) }, /* Central Standard */
01914   { "CDT",      tDAYZONE, -HOUR ( 6) }, /* Central Daylight */
01915   { "MST",      tZONE,    -HOUR ( 7) }, /* Mountain Standard */
01916   { "MDT",      tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */
01917   { "PST",      tZONE,    -HOUR ( 8) }, /* Pacific Standard */
01918   { "PDT",      tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */
01919   { "AKST",     tZONE,    -HOUR ( 9) }, /* Alaska Standard */
01920   { "AKDT",     tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */
01921   { "HST",      tZONE,    -HOUR (10) }, /* Hawaii Standard */
01922   { "HAST",     tZONE,    -HOUR (10) }, /* Hawaii-Aleutian Standard */
01923   { "HADT",     tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */
01924   { "SST",      tZONE,    -HOUR (12) }, /* Samoa Standard */
01925   { "WAT",      tZONE,     HOUR ( 1) }, /* West Africa */
01926   { "CET",      tZONE,     HOUR ( 1) }, /* Central European */
01927   { "CEST",     tDAYZONE,  HOUR ( 1) }, /* Central European Summer */
01928   { "MET",      tZONE,     HOUR ( 1) }, /* Middle European */
01929   { "MEZ",      tZONE,     HOUR ( 1) }, /* Middle European */
01930   { "MEST",     tDAYZONE,  HOUR ( 1) }, /* Middle European Summer */
01931   { "MESZ",     tDAYZONE,  HOUR ( 1) }, /* Middle European Summer */
01932   { "EET",      tZONE,     HOUR ( 2) }, /* Eastern European */
01933   { "EEST",     tDAYZONE,  HOUR ( 2) }, /* Eastern European Summer */
01934   { "CAT",      tZONE,     HOUR ( 2) }, /* Central Africa */
01935   { "SAST",     tZONE,     HOUR ( 2) }, /* South Africa Standard */
01936   { "EAT",      tZONE,     HOUR ( 3) }, /* East Africa */
01937   { "MSK",      tZONE,     HOUR ( 3) }, /* Moscow */
01938   { "MSD",      tDAYZONE,  HOUR ( 3) }, /* Moscow Daylight */
01939   { "IST",      tZONE,    (HOUR ( 5) + 30) },   /* India Standard */
01940   { "SGT",      tZONE,     HOUR ( 8) }, /* Singapore */
01941   { "KST",      tZONE,     HOUR ( 9) }, /* Korea Standard */
01942   { "JST",      tZONE,     HOUR ( 9) }, /* Japan Standard */
01943   { "GST",      tZONE,     HOUR (10) }, /* Guam Standard */
01944   { "NZST",     tZONE,     HOUR (12) }, /* New Zealand Standard */
01945   { "NZDT",     tDAYZONE,  HOUR (12) }, /* New Zealand Daylight */
01946   { 0, 0, 0  }
01947 };
01948 
01949 /* Military time zone table. */
01950 static table const military_table[] =
01951 {
01952   { "A", tZONE, -HOUR ( 1) },
01953   { "B", tZONE, -HOUR ( 2) },
01954   { "C", tZONE, -HOUR ( 3) },
01955   { "D", tZONE, -HOUR ( 4) },
01956   { "E", tZONE, -HOUR ( 5) },
01957   { "F", tZONE, -HOUR ( 6) },
01958   { "G", tZONE, -HOUR ( 7) },
01959   { "H", tZONE, -HOUR ( 8) },
01960   { "I", tZONE, -HOUR ( 9) },
01961   { "K", tZONE, -HOUR (10) },
01962   { "L", tZONE, -HOUR (11) },
01963   { "M", tZONE, -HOUR (12) },
01964   { "N", tZONE,  HOUR ( 1) },
01965   { "O", tZONE,  HOUR ( 2) },
01966   { "P", tZONE,  HOUR ( 3) },
01967   { "Q", tZONE,  HOUR ( 4) },
01968   { "R", tZONE,  HOUR ( 5) },
01969   { "S", tZONE,  HOUR ( 6) },
01970   { "T", tZONE,  HOUR ( 7) },
01971   { "U", tZONE,  HOUR ( 8) },
01972   { "V", tZONE,  HOUR ( 9) },
01973   { "W", tZONE,  HOUR (10) },
01974   { "X", tZONE,  HOUR (11) },
01975   { "Y", tZONE,  HOUR (12) },
01976   { "Z", tZONE,  HOUR ( 0) },
01977   { 0, 0, 0 }
01978 };
01979 
01980 
01981 
01982 static int
01983 to_hour (int hours, int meridian)
01984 {
01985   switch (meridian)
01986     {
01987     case MER24:
01988       return 0 <= hours && hours < 24 ? hours : -1;
01989     case MERam:
01990       return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
01991     case MERpm:
01992       return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
01993     default:
01994       abort ();
01995     }
01996   /* NOTREACHED */
01997     return 0;
01998 }
01999 
02000 static int
02001 to_year (textint textyear)
02002 {
02003   int year = textyear.value;
02004 
02005   if (year < 0)
02006     year = -year;
02007 
02008   /* XPG4 suggests that years 00-68 map to 2000-2068, and
02009      years 69-99 map to 1969-1999.  */
02010   if (textyear.digits == 2)
02011     year += year < 69 ? 2000 : 1900;
02012 
02013   return year;
02014 }
02015 
02016 static table const *
02017 lookup_zone (parser_control const *pc, char const *name)
02018 {
02019   table const *tp;
02020 
02021   /* Try local zone abbreviations first; they're more likely to be right.  */
02022   for (tp = pc->local_time_zone_table; tp->name; tp++)
02023     if (strcmp (name, tp->name) == 0)
02024       return tp;
02025 
02026   for (tp = time_zone_table; tp->name; tp++)
02027     if (strcmp (name, tp->name) == 0)
02028       return tp;
02029 
02030   return 0;
02031 }
02032 
02033 #if ! HAVE_TM_GMTOFF
02034 /* Yield the difference between *A and *B,
02035    measured in seconds, ignoring leap seconds.
02036    The body of this function is taken directly from the GNU C Library;
02037    see src/strftime.c.  */
02038 static int
02039 tm_diff (struct tm const *a, struct tm const *b)
02040 {
02041   /* Compute intervening leap days correctly even if year is negative.
02042      Take care to avoid int overflow in leap day calculations,
02043      but it's OK to assume that A and B are close to each other.  */
02044   int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3);
02045   int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
02046   int a100 = a4 / 25 - (a4 % 25 < 0);
02047   int b100 = b4 / 25 - (b4 % 25 < 0);
02048   int a400 = a100 >> 2;
02049   int b400 = b100 >> 2;
02050   int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
02051   int years = a->tm_year - b->tm_year;
02052   int days = (365 * years + intervening_leap_days
02053               + (a->tm_yday - b->tm_yday));
02054   return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
02055                 + (a->tm_min - b->tm_min))
02056           + (a->tm_sec - b->tm_sec));
02057 }
02058 #endif /* ! HAVE_TM_GMTOFF */
02059 
02060 static table const *
02061 lookup_word (parser_control const *pc, char *word)
02062 {
02063   char *p;
02064   char *q;
02065   size_t wordlen;
02066   table const *tp;
02067   int i;
02068   int abbrev;
02069 
02070   /* Make it uppercase.  */
02071   for (p = word; *p; p++)
02072     if (ISLOWER ((unsigned char) *p))
02073       *p = toupper ((unsigned char) *p);
02074 
02075   for (tp = meridian_table; tp->name; tp++)
02076     if (strcmp (word, tp->name) == 0)
02077       return tp;
02078 
02079   /* See if we have an abbreviation for a month. */
02080   wordlen = strlen (word);
02081   abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.');
02082 
02083   for (tp = month_and_day_table; tp->name; tp++)
02084     if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0)
02085       return tp;
02086 
02087   if ((tp = lookup_zone (pc, word)))
02088     return tp;
02089 
02090   if (strcmp (word, dst_table[0].name) == 0)
02091     return dst_table;
02092 
02093   for (tp = time_units_table; tp->name; tp++)
02094     if (strcmp (word, tp->name) == 0)
02095       return tp;
02096 
02097   /* Strip off any plural and try the units table again. */
02098   if (word[wordlen - 1] == 'S')
02099     {
02100       word[wordlen - 1] = '\0';
02101       for (tp = time_units_table; tp->name; tp++)
02102         if (strcmp (word, tp->name) == 0)
02103           return tp;
02104       word[wordlen - 1] = 'S';  /* For "this" in relative_time_table.  */
02105     }
02106 
02107   for (tp = relative_time_table; tp->name; tp++)
02108     if (strcmp (word, tp->name) == 0)
02109       return tp;
02110 
02111   /* Military time zones. */
02112   if (wordlen == 1)
02113     for (tp = military_table; tp->name; tp++)
02114       if (word[0] == tp->name[0])
02115         return tp;
02116 
02117   /* Drop out any periods and try the time zone table again. */
02118   for (i = 0, p = q = word; (*p = *q); q++)
02119     if (*q == '.')
02120       i = 1;
02121     else
02122       p++;
02123   if (i && (tp = lookup_zone (pc, word)))
02124     return tp;
02125 
02126   return 0;
02127 }
02128 
02129 static int
02130 yylex (YYSTYPE *lvalp, parser_control *pc)
02131 {
02132   unsigned char c;
02133   int count;
02134 
02135   for (;;)
02136     {
02137       while (c = *pc->input, ISSPACE (c))
02138         pc->input++;
02139 
02140       if (ISDIGIT (c) || c == '-' || c == '+')
02141         {
02142           char const *p;
02143           int sign;
02144           int value;
02145           if (c == '-' || c == '+')
02146             {
02147               sign = c == '-' ? -1 : 1;
02148               c = *++pc->input;
02149               if (! ISDIGIT (c))
02150                 /* skip the '-' sign */
02151                 continue;
02152             }
02153           else
02154             sign = 0;
02155           p = pc->input;
02156           value = 0;
02157           do
02158             {
02159               value = 10 * value + c - '0';
02160               c = *++p;
02161             }
02162           while (ISDIGIT (c));
02163           lvalp->textintval.value = sign < 0 ? -value : value;
02164           lvalp->textintval.digits = p - pc->input;
02165           pc->input = p;
02166           return sign ? tSNUMBER : tUNUMBER;
02167         }
02168 
02169       if (ISALPHA (c))
02170         {
02171           char buff[20];
02172           char *p = buff;
02173           table const *tp;
02174 
02175           do
02176             {
02177               if (p < buff + sizeof buff - 1)
02178                 *p++ = c;
02179               c = *++pc->input;
02180             }
02181           while (ISALPHA (c) || c == '.');
02182 
02183           *p = '\0';
02184           tp = lookup_word (pc, buff);
02185           if (! tp)
02186             return '?';
02187           lvalp->intval = tp->value;
02188           return tp->type;
02189         }
02190 
02191       if (c != '(')
02192         return *pc->input++;
02193       count = 0;
02194       do
02195         {
02196           c = *pc->input++;
02197           if (c == '\0')
02198             return c;
02199           if (c == '(')
02200             count++;
02201           else if (c == ')')
02202             count--;
02203         }
02204       while (count > 0);
02205     }
02206 }
02207 
02208 /* Do nothing if the parser reports an error.  */
02209 static int
02210 yyerror (char *s ATTRIBUTE_UNUSED)
02211 {
02212   return 0;
02213 }
02214 
02215 /* Parse a date/time string P.  Return the corresponding time_t value,
02216    or (time_t) -1 if there is an error.  P can be an incomplete or
02217    relative time specification; if so, use *NOW as the basis for the
02218    returned time.  */
02219 time_t
02220 get_date (const char *p, const time_t *now)
02221 {
02222   time_t Start = now ? *now : time (0);
02223   struct tm *tmp = localtime (&Start);
02224   struct tm tm;
02225   struct tm tm0;
02226   parser_control pc;
02227 
02228   if (! tmp)
02229     return -1;
02230 
02231   pc.input = p;
02232   pc.year.value = tmp->tm_year + TM_YEAR_BASE;
02233   pc.year.digits = 4;
02234   pc.month = tmp->tm_mon + 1;
02235   pc.day = tmp->tm_mday;
02236   pc.hour = tmp->tm_hour;
02237   pc.minutes = tmp->tm_min;
02238   pc.seconds = tmp->tm_sec;
02239   tm.tm_isdst = tmp->tm_isdst;
02240 
02241   pc.meridian = MER24;
02242   pc.rel_seconds = 0;
02243   pc.rel_minutes = 0;
02244   pc.rel_hour = 0;
02245   pc.rel_day = 0;
02246   pc.rel_month = 0;
02247   pc.rel_year = 0;
02248   pc.dates_seen = 0;
02249   pc.days_seen = 0;
02250   pc.rels_seen = 0;
02251   pc.times_seen = 0;
02252   pc.local_zones_seen = 0;
02253   pc.zones_seen = 0;
02254 
02255 #if HAVE_STRUCT_TM_TM_ZONE
02256   pc.local_time_zone_table[0].name = tmp->tm_zone;
02257   pc.local_time_zone_table[0].type = tLOCAL_ZONE;
02258   pc.local_time_zone_table[0].value = tmp->tm_isdst;
02259   pc.local_time_zone_table[1].name = 0;
02260 
02261   /* Probe the names used in the next three calendar quarters, looking
02262      for a tm_isdst different from the one we already have.  */
02263   {
02264     int quarter;
02265     for (quarter = 1; quarter <= 3; quarter++)
02266       {
02267         time_t probe = Start + quarter * (90 * 24 * 60 * 60);
02268         struct tm *probe_tm = localtime (&probe);
02269         if (probe_tm && probe_tm->tm_zone
02270             && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
02271           {
02272               {
02273                 pc.local_time_zone_table[1].name = probe_tm->tm_zone;
02274                 pc.local_time_zone_table[1].type = tLOCAL_ZONE;
02275                 pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
02276                 pc.local_time_zone_table[2].name = 0;
02277               }
02278             break;
02279           }
02280       }
02281   }
02282 #else
02283 #if HAVE_TZNAME
02284   {
02285 # ifndef tzname
02286     extern char *tzname[];
02287 # endif
02288     int i;
02289     for (i = 0; i < 2; i++)
02290       {
02291         pc.local_time_zone_table[i].name = tzname[i];
02292         pc.local_time_zone_table[i].type = tLOCAL_ZONE;
02293         pc.local_time_zone_table[i].value = i;
02294       }
02295     pc.local_time_zone_table[i].name = 0;
02296   }
02297 #else
02298   pc.local_time_zone_table[0].name = 0;
02299 #endif
02300 #endif
02301 
02302   if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
02303       && ! strcmp (pc.local_time_zone_table[0].name,
02304                    pc.local_time_zone_table[1].name))
02305     {
02306       /* This locale uses the same abbrevation for standard and
02307          daylight times.  So if we see that abbreviation, we don't
02308          know whether it's daylight time.  */
02309       pc.local_time_zone_table[0].value = -1;
02310       pc.local_time_zone_table[1].name = 0;
02311     }
02312 
02313   if (yyparse (&pc) != 0
02314       || 1 < pc.times_seen || 1 < pc.dates_seen || 1 < pc.days_seen
02315       || 1 < (pc.local_zones_seen + pc.zones_seen)
02316       || (pc.local_zones_seen && 1 < pc.local_isdst))
02317     return -1;
02318 
02319   tm.tm_year = to_year (pc.year) - TM_YEAR_BASE + pc.rel_year;
02320   tm.tm_mon = pc.month - 1 + pc.rel_month;
02321   tm.tm_mday = pc.day + pc.rel_day;
02322   if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
02323     {
02324       tm.tm_hour = to_hour (pc.hour, pc.meridian);
02325       if (tm.tm_hour < 0)
02326         return -1;
02327       tm.tm_min = pc.minutes;
02328       tm.tm_sec = pc.seconds;
02329     }
02330   else
02331     {
02332       tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
02333     }
02334 
02335   /* Let mktime deduce tm_isdst if we have an absolute time stamp,
02336      or if the relative time stamp mentions days, months, or years.  */
02337   if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day
02338       | pc.rel_month | pc.rel_year)
02339     tm.tm_isdst = -1;
02340 
02341   /* But if the input explicitly specifies local time with or without
02342      DST, give mktime that information.  */
02343   if (pc.local_zones_seen)
02344     tm.tm_isdst = pc.local_isdst;
02345 
02346   tm0 = tm;
02347 
02348   Start = mktime (&tm);
02349 
02350   if (Start == (time_t) -1)
02351     {
02352 
02353       /* Guard against falsely reporting errors near the time_t boundaries
02354          when parsing times in other time zones.  For example, if the min
02355          time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
02356          of UTC, then the min localtime value is 1970-01-01 08:00:00; if
02357          we apply mktime to 1970-01-01 00:00:00 we will get an error, so
02358          we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
02359          zone by 24 hours to compensate.  This algorithm assumes that
02360          there is no DST transition within a day of the time_t boundaries.  */
02361       if (pc.zones_seen)
02362         {
02363           tm = tm0;
02364           if (tm.tm_year <= EPOCH_YEAR - TM_YEAR_BASE)
02365             {
02366               tm.tm_mday++;
02367               pc.time_zone += 24 * 60;
02368             }
02369           else
02370             {
02371               tm.tm_mday--;
02372               pc.time_zone -= 24 * 60;
02373             }
02374           Start = mktime (&tm);
02375         }
02376 
02377       if (Start == (time_t) -1)
02378         return Start;
02379     }
02380 
02381   if (pc.days_seen && ! pc.dates_seen)
02382     {
02383       tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
02384                      + 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
02385       tm.tm_isdst = -1;
02386       Start = mktime (&tm);
02387       if (Start == (time_t) -1)
02388         return Start;
02389     }
02390 
02391   if (pc.zones_seen)
02392     {
02393       int delta = pc.time_zone * 60;
02394 #ifdef HAVE_TM_GMTOFF
02395       delta -= tm.tm_gmtoff;
02396 #else
02397       struct tm *gmt = gmtime (&Start);
02398       if (! gmt)
02399         return -1;
02400       delta -= tm_diff (&tm, gmt);
02401 #endif
02402       if ((Start < Start - delta) != (delta < 0))
02403         return -1;      /* time_t overflow */
02404       Start -= delta;
02405     }
02406 
02407   /* Add relative hours, minutes, and seconds.  Ignore leap seconds;
02408      i.e. "+ 10 minutes" means 600 seconds, even if one of them is a
02409      leap second.  Typically this is not what the user wants, but it's
02410      too hard to do it the other way, because the time zone indicator
02411      must be applied before relative times, and if mktime is applied
02412      again the time zone will be lost.  */
02413   {
02414     time_t t0 = Start;
02415     long d1 = 60 * 60 * (long) pc.rel_hour;
02416     time_t t1 = t0 + d1;
02417     long d2 = 60 * (long) pc.rel_minutes;
02418     time_t t2 = t1 + d2;
02419     int d3 = pc.rel_seconds;
02420     time_t t3 = t2 + d3;
02421     if ((d1 / (60 * 60) ^ pc.rel_hour)
02422         | (d2 / 60 ^ pc.rel_minutes)
02423         | ((t0 + d1 < t0) ^ (d1 < 0))
02424         | ((t1 + d2 < t1) ^ (d2 < 0))
02425         | ((t2 + d3 < t2) ^ (d3 < 0)))
02426       return -1;
02427     Start = t3;
02428   }
02429 
02430   return Start;
02431 }
02432 
02433 #if TEST
02434 
02435 #include <stdio.h>
02436 
02437 int
02438 main (int ac, char **av)
02439 {
02440   char buff[BUFSIZ];
02441   time_t d;
02442 
02443   printf ("Enter date, or blank line to exit.\n\t> ");
02444   fflush (stdout);
02445 
02446   buff[BUFSIZ - 1] = 0;
02447   while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
02448     {
02449       d = get_date (buff, 0);
02450       if (d == (time_t) -1)
02451         printf ("Bad format - couldn't convert.\n");
02452       else
02453         printf ("%s", ctime (&d));
02454       printf ("\t> ");
02455       fflush (stdout);
02456     }
02457   return 0;
02458 }
02459 #endif /* defined TEST */
02460 
02461 

Sambaに対してSat Aug 29 21:23:06 2009に生成されました。  doxygen 1.4.7