Home | History | Annotate | Line # | Download | only in lib
      1  1.1  christos 
      2  1.2  christos /* A Bison parser, made by GNU Bison 2.4.1.  */
      3  1.1  christos 
      4  1.2  christos /* Skeleton implementation for Bison's Yacc-like parsers in C
      5  1.2  christos 
      6  1.2  christos       Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
      7  1.2  christos    Free Software Foundation, Inc.
      8  1.2  christos 
      9  1.2  christos    This program is free software: you can redistribute it and/or modify
     10  1.1  christos    it under the terms of the GNU General Public License as published by
     11  1.2  christos    the Free Software Foundation, either version 3 of the License, or
     12  1.2  christos    (at your option) any later version.
     13  1.2  christos 
     14  1.1  christos    This program is distributed in the hope that it will be useful,
     15  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  1.1  christos    GNU General Public License for more details.
     18  1.2  christos 
     19  1.2  christos    You should have received a copy of the GNU General Public License
     20  1.2  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     21  1.1  christos 
     22  1.2  christos /* As a special exception, you may create a larger work that contains
     23  1.2  christos    part or all of the Bison parser skeleton and distribute that work
     24  1.2  christos    under terms of your choice, so long as that work isn't itself a
     25  1.2  christos    parser generator using the skeleton or a modified version thereof
     26  1.2  christos    as a parser skeleton.  Alternatively, if you modify or redistribute
     27  1.2  christos    the parser skeleton itself, you may (at your option) remove this
     28  1.2  christos    special exception, which will cause the skeleton and the resulting
     29  1.2  christos    Bison output files to be licensed under the GNU General Public
     30  1.2  christos    License without this special exception.
     31  1.2  christos 
     32  1.2  christos    This special exception was added by the Free Software Foundation in
     33  1.2  christos    version 2.2 of Bison.  */
     34  1.1  christos 
     35  1.2  christos /* C LALR(1) parser skeleton written by Richard Stallman, by
     36  1.2  christos    simplifying the original so-called "semantic" parser.  */
     37  1.1  christos 
     38  1.1  christos /* All symbols defined below should begin with yy or YY, to avoid
     39  1.1  christos    infringing on user name space.  This should be done even for local
     40  1.1  christos    variables, as they might otherwise be expanded by user macros.
     41  1.1  christos    There are some unavoidable exceptions within include files to
     42  1.1  christos    define necessary library symbols; they are noted "INFRINGES ON
     43  1.1  christos    USER NAME SPACE" below.  */
     44  1.1  christos 
     45  1.1  christos /* Identify Bison output.  */
     46  1.1  christos #define YYBISON 1
     47  1.1  christos 
     48  1.2  christos /* Bison version.  */
     49  1.2  christos #define YYBISON_VERSION "2.4.1"
     50  1.2  christos 
     51  1.1  christos /* Skeleton name.  */
     52  1.1  christos #define YYSKELETON_NAME "yacc.c"
     53  1.1  christos 
     54  1.1  christos /* Pure parsers.  */
     55  1.1  christos #define YYPURE 1
     56  1.1  christos 
     57  1.2  christos /* Push parsers.  */
     58  1.2  christos #define YYPUSH 0
     59  1.2  christos 
     60  1.2  christos /* Pull parsers.  */
     61  1.2  christos #define YYPULL 1
     62  1.2  christos 
     63  1.1  christos /* Using locations.  */
     64  1.1  christos #define YYLSP_NEEDED 0
     65  1.1  christos 
     66  1.1  christos 
     67  1.1  christos 
     68  1.2  christos /* Copy the first part of user declarations.  */
     69  1.1  christos 
     70  1.2  christos /* Line 189 of yacc.c  */
     71  1.2  christos #line 1 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
     72  1.1  christos 
     73  1.1  christos /* Parse a string into an internal time stamp.
     74  1.1  christos 
     75  1.1  christos    Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Free Software
     76  1.1  christos    Foundation, Inc.
     77  1.1  christos 
     78  1.1  christos    This program is free software; you can redistribute it and/or modify
     79  1.1  christos    it under the terms of the GNU General Public License as published by
     80  1.1  christos    the Free Software Foundation; either version 2, or (at your option)
     81  1.1  christos    any later version.
     82  1.1  christos 
     83  1.1  christos    This program is distributed in the hope that it will be useful,
     84  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     85  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     86  1.1  christos    GNU General Public License for more details.
     87  1.1  christos 
     88  1.1  christos    You should have received a copy of the GNU General Public License
     89  1.1  christos    along with this program; if not, write to the Free Software Foundation,
     90  1.1  christos    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     91  1.3  christos #include <sys/cdefs.h>
     92  1.3  christos __RCSID("$NetBSD: getdate.c,v 1.3 2016/05/17 14:00:09 christos Exp $");
     93  1.3  christos 
     94  1.1  christos 
     95  1.1  christos /* Originally written by Steven M. Bellovin <smb (at) research.att.com> while
     96  1.1  christos    at the University of North Carolina at Chapel Hill.  Later tweaked by
     97  1.1  christos    a couple of people on Usenet.  Completely overhauled by Rich $alz
     98  1.1  christos    <rsalz (at) bbn.com> and Jim Berets <jberets (at) bbn.com> in August, 1990.
     99  1.1  christos 
    100  1.1  christos    Modified by Paul Eggert <eggert (at) twinsun.com> in August 1999 to do
    101  1.1  christos    the right thing about local DST.  Also modified by Paul Eggert
    102  1.1  christos    <eggert (at) cs.ucla.edu> in February 2004 to support
    103  1.1  christos    nanosecond-resolution time stamps, and in October 2004 to support
    104  1.1  christos    TZ strings in dates.  */
    105  1.1  christos 
    106  1.1  christos /* FIXME: Check for arithmetic overflow in all cases, not just
    107  1.1  christos    some of them.  */
    108  1.1  christos 
    109  1.1  christos #ifdef HAVE_CONFIG_H
    110  1.1  christos # include <config.h>
    111  1.1  christos #endif
    112  1.1  christos 
    113  1.1  christos #include "getdate.h"
    114  1.1  christos 
    115  1.1  christos /* There's no need to extend the stack, so there's no need to involve
    116  1.1  christos    alloca.  */
    117  1.1  christos #define YYSTACK_USE_ALLOCA 0
    118  1.1  christos 
    119  1.1  christos /* Tell Bison how much stack space is needed.  20 should be plenty for
    120  1.1  christos    this grammar, which is not right recursive.  Beware setting it too
    121  1.1  christos    high, since that might cause problems on machines whose
    122  1.1  christos    implementations have lame stack-overflow checking.  */
    123  1.1  christos #define YYMAXDEPTH 20
    124  1.1  christos #define YYINITDEPTH YYMAXDEPTH
    125  1.1  christos 
    126  1.1  christos /* Since the code of getdate.y is not included in the Emacs executable
    127  1.1  christos    itself, there is no need to #define static in this file.  Even if
    128  1.1  christos    the code were included in the Emacs executable, it probably
    129  1.1  christos    wouldn't do any harm to #undef it here; this will only cause
    130  1.1  christos    problems if we try to write to a static variable, which I don't
    131  1.1  christos    think this code needs to do.  */
    132  1.1  christos #ifdef emacs
    133  1.1  christos # undef static
    134  1.1  christos #endif
    135  1.1  christos 
    136  1.1  christos #include <ctype.h>
    137  1.1  christos #include <limits.h>
    138  1.1  christos #include <stdio.h>
    139  1.1  christos #include <stdlib.h>
    140  1.1  christos #include <string.h>
    141  1.1  christos 
    142  1.1  christos #include "setenv.h"
    143  1.1  christos #include "xalloc.h"
    144  1.1  christos 
    145  1.1  christos #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
    146  1.1  christos # define IN_CTYPE_DOMAIN(c) 1
    147  1.1  christos #else
    148  1.1  christos # define IN_CTYPE_DOMAIN(c) isascii (c)
    149  1.1  christos #endif
    150  1.1  christos 
    151  1.1  christos #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
    152  1.1  christos #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
    153  1.1  christos #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
    154  1.1  christos 
    155  1.1  christos /* ISDIGIT differs from isdigit, as follows:
    156  1.1  christos    - Its arg may be any int or unsigned int; it need not be an unsigned char.
    157  1.1  christos    - It's guaranteed to evaluate its argument exactly once.
    158  1.1  christos    - It's typically faster.
    159  1.1  christos    POSIX says that only '0' through '9' are digits.  Prefer ISDIGIT to
    160  1.1  christos    isdigit unless it's important to use the locale's definition
    161  1.1  christos    of `digit' even when the host does not conform to POSIX.  */
    162  1.1  christos #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
    163  1.1  christos 
    164  1.1  christos #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
    165  1.1  christos # define __attribute__(x)
    166  1.1  christos #endif
    167  1.1  christos 
    168  1.1  christos #ifndef ATTRIBUTE_UNUSED
    169  1.1  christos # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
    170  1.1  christos #endif
    171  1.1  christos 
    172  1.1  christos /* Shift A right by B bits portably, by dividing A by 2**B and
    173  1.1  christos    truncating towards minus infinity.  A and B should be free of side
    174  1.1  christos    effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
    175  1.1  christos    INT_BITS is the number of useful bits in an int.  GNU code can
    176  1.1  christos    assume that INT_BITS is at least 32.
    177  1.1  christos 
    178  1.1  christos    ISO C99 says that A >> B is implementation-defined if A < 0.  Some
    179  1.1  christos    implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
    180  1.1  christos    right in the usual way when A < 0, so SHR falls back on division if
    181  1.1  christos    ordinary A >> B doesn't seem to be the usual signed shift.  */
    182  1.1  christos #define SHR(a, b)	\
    183  1.1  christos   (-1 >> 1 == -1	\
    184  1.1  christos    ? (a) >> (b)		\
    185  1.1  christos    : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
    186  1.1  christos 
    187  1.1  christos #define EPOCH_YEAR 1970
    188  1.1  christos #define TM_YEAR_BASE 1900
    189  1.1  christos 
    190  1.1  christos #define HOUR(x) ((x) * 60)
    191  1.1  christos 
    192  1.1  christos /* An integer value, and the number of digits in its textual
    193  1.1  christos    representation.  */
    194  1.1  christos typedef struct
    195  1.1  christos {
    196  1.1  christos   bool negative;
    197  1.1  christos   long int value;
    198  1.1  christos   size_t digits;
    199  1.1  christos } textint;
    200  1.1  christos 
    201  1.1  christos /* An entry in the lexical lookup table.  */
    202  1.1  christos typedef struct
    203  1.1  christos {
    204  1.1  christos   char const *name;
    205  1.1  christos   int type;
    206  1.1  christos   int value;
    207  1.1  christos } table;
    208  1.1  christos 
    209  1.1  christos /* Meridian: am, pm, or 24-hour style.  */
    210  1.1  christos enum { MERam, MERpm, MER24 };
    211  1.1  christos 
    212  1.1  christos enum { BILLION = 1000000000, LOG10_BILLION = 9 };
    213  1.1  christos 
    214  1.1  christos /* Information passed to and from the parser.  */
    215  1.1  christos typedef struct
    216  1.1  christos {
    217  1.1  christos   /* The input string remaining to be parsed. */
    218  1.1  christos   const char *input;
    219  1.1  christos 
    220  1.1  christos   /* N, if this is the Nth Tuesday.  */
    221  1.1  christos   long int day_ordinal;
    222  1.1  christos 
    223  1.1  christos   /* Day of week; Sunday is 0.  */
    224  1.1  christos   int day_number;
    225  1.1  christos 
    226  1.1  christos   /* tm_isdst flag for the local zone.  */
    227  1.1  christos   int local_isdst;
    228  1.1  christos 
    229  1.1  christos   /* Time zone, in minutes east of UTC.  */
    230  1.1  christos   long int time_zone;
    231  1.1  christos 
    232  1.1  christos   /* Style used for time.  */
    233  1.1  christos   int meridian;
    234  1.1  christos 
    235  1.1  christos   /* Gregorian year, month, day, hour, minutes, seconds, and nanoseconds.  */
    236  1.1  christos   textint year;
    237  1.1  christos   long int month;
    238  1.1  christos   long int day;
    239  1.1  christos   long int hour;
    240  1.1  christos   long int minutes;
    241  1.1  christos   struct timespec seconds; /* includes nanoseconds */
    242  1.1  christos 
    243  1.1  christos   /* Relative year, month, day, hour, minutes, seconds, and nanoseconds.  */
    244  1.1  christos   long int rel_year;
    245  1.1  christos   long int rel_month;
    246  1.1  christos   long int rel_day;
    247  1.1  christos   long int rel_hour;
    248  1.1  christos   long int rel_minutes;
    249  1.1  christos   long int rel_seconds;
    250  1.1  christos   long int rel_ns;
    251  1.1  christos 
    252  1.1  christos   /* Presence or counts of nonterminals of various flavors parsed so far.  */
    253  1.1  christos   bool timespec_seen;
    254  1.1  christos   bool rels_seen;
    255  1.1  christos   size_t dates_seen;
    256  1.1  christos   size_t days_seen;
    257  1.1  christos   size_t local_zones_seen;
    258  1.1  christos   size_t dsts_seen;
    259  1.1  christos   size_t times_seen;
    260  1.1  christos   size_t zones_seen;
    261  1.1  christos 
    262  1.1  christos   /* Table of local time zone abbrevations, terminated by a null entry.  */
    263  1.1  christos   table local_time_zone_table[3];
    264  1.1  christos } parser_control;
    265  1.1  christos 
    266  1.1  christos union YYSTYPE;
    267  1.1  christos static int yylex (union YYSTYPE *, parser_control *);
    268  1.1  christos static int yyerror (parser_control *, char *);
    269  1.1  christos static long int time_zone_hhmm (textint, long int);
    270  1.1  christos 
    271  1.1  christos 
    272  1.1  christos 
    273  1.2  christos /* Line 189 of yacc.c  */
    274  1.2  christos #line 272 "getdate.c"
    275  1.2  christos 
    276  1.1  christos /* Enabling traces.  */
    277  1.1  christos #ifndef YYDEBUG
    278  1.1  christos # define YYDEBUG 0
    279  1.1  christos #endif
    280  1.1  christos 
    281  1.1  christos /* Enabling verbose error messages.  */
    282  1.1  christos #ifdef YYERROR_VERBOSE
    283  1.1  christos # undef YYERROR_VERBOSE
    284  1.1  christos # define YYERROR_VERBOSE 1
    285  1.1  christos #else
    286  1.1  christos # define YYERROR_VERBOSE 0
    287  1.1  christos #endif
    288  1.1  christos 
    289  1.2  christos /* Enabling the token table.  */
    290  1.2  christos #ifndef YYTOKEN_TABLE
    291  1.2  christos # define YYTOKEN_TABLE 0
    292  1.2  christos #endif
    293  1.2  christos 
    294  1.2  christos 
    295  1.2  christos /* Tokens.  */
    296  1.2  christos #ifndef YYTOKENTYPE
    297  1.2  christos # define YYTOKENTYPE
    298  1.2  christos    /* Put the tokens into the symbol table, so that GDB and other debuggers
    299  1.2  christos       know about them.  */
    300  1.2  christos    enum yytokentype {
    301  1.2  christos      tAGO = 258,
    302  1.2  christos      tDST = 259,
    303  1.2  christos      tDAY = 260,
    304  1.2  christos      tDAY_UNIT = 261,
    305  1.2  christos      tDAYZONE = 262,
    306  1.2  christos      tHOUR_UNIT = 263,
    307  1.2  christos      tLOCAL_ZONE = 264,
    308  1.2  christos      tMERIDIAN = 265,
    309  1.2  christos      tMINUTE_UNIT = 266,
    310  1.2  christos      tMONTH = 267,
    311  1.2  christos      tMONTH_UNIT = 268,
    312  1.2  christos      tORDINAL = 269,
    313  1.2  christos      tSEC_UNIT = 270,
    314  1.2  christos      tYEAR_UNIT = 271,
    315  1.2  christos      tZONE = 272,
    316  1.2  christos      tSNUMBER = 273,
    317  1.2  christos      tUNUMBER = 274,
    318  1.2  christos      tSDECIMAL_NUMBER = 275,
    319  1.2  christos      tUDECIMAL_NUMBER = 276
    320  1.2  christos    };
    321  1.2  christos #endif
    322  1.2  christos 
    323  1.2  christos 
    324  1.2  christos 
    325  1.2  christos #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
    326  1.2  christos typedef union YYSTYPE
    327  1.2  christos {
    328  1.2  christos 
    329  1.2  christos /* Line 214 of yacc.c  */
    330  1.2  christos #line 209 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
    331  1.2  christos 
    332  1.1  christos   long int intval;
    333  1.1  christos   textint textintval;
    334  1.1  christos   struct timespec timespec;
    335  1.2  christos 
    336  1.2  christos 
    337  1.2  christos 
    338  1.2  christos /* Line 214 of yacc.c  */
    339  1.2  christos #line 337 "getdate.c"
    340  1.1  christos } YYSTYPE;
    341  1.2  christos # define YYSTYPE_IS_TRIVIAL 1
    342  1.1  christos # define yystype YYSTYPE /* obsolescent; will be withdrawn */
    343  1.1  christos # define YYSTYPE_IS_DECLARED 1
    344  1.1  christos #endif
    345  1.1  christos 
    346  1.1  christos 
    347  1.2  christos /* Copy the second part of user declarations.  */
    348  1.2  christos 
    349  1.2  christos 
    350  1.2  christos /* Line 264 of yacc.c  */
    351  1.2  christos #line 349 "getdate.c"
    352  1.2  christos 
    353  1.2  christos #ifdef short
    354  1.2  christos # undef short
    355  1.2  christos #endif
    356  1.2  christos 
    357  1.2  christos #ifdef YYTYPE_UINT8
    358  1.2  christos typedef YYTYPE_UINT8 yytype_uint8;
    359  1.2  christos #else
    360  1.2  christos typedef unsigned char yytype_uint8;
    361  1.2  christos #endif
    362  1.2  christos 
    363  1.2  christos #ifdef YYTYPE_INT8
    364  1.2  christos typedef YYTYPE_INT8 yytype_int8;
    365  1.2  christos #elif (defined __STDC__ || defined __C99__FUNC__ \
    366  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    367  1.2  christos typedef signed char yytype_int8;
    368  1.2  christos #else
    369  1.2  christos typedef short int yytype_int8;
    370  1.2  christos #endif
    371  1.1  christos 
    372  1.2  christos #ifdef YYTYPE_UINT16
    373  1.2  christos typedef YYTYPE_UINT16 yytype_uint16;
    374  1.2  christos #else
    375  1.2  christos typedef unsigned short int yytype_uint16;
    376  1.2  christos #endif
    377  1.1  christos 
    378  1.2  christos #ifdef YYTYPE_INT16
    379  1.2  christos typedef YYTYPE_INT16 yytype_int16;
    380  1.2  christos #else
    381  1.2  christos typedef short int yytype_int16;
    382  1.2  christos #endif
    383  1.1  christos 
    384  1.2  christos #ifndef YYSIZE_T
    385  1.2  christos # ifdef __SIZE_TYPE__
    386  1.2  christos #  define YYSIZE_T __SIZE_TYPE__
    387  1.2  christos # elif defined size_t
    388  1.2  christos #  define YYSIZE_T size_t
    389  1.2  christos # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
    390  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    391  1.2  christos #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
    392  1.2  christos #  define YYSIZE_T size_t
    393  1.2  christos # else
    394  1.2  christos #  define YYSIZE_T unsigned int
    395  1.2  christos # endif
    396  1.2  christos #endif
    397  1.1  christos 
    398  1.2  christos #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
    399  1.1  christos 
    400  1.2  christos #ifndef YY_
    401  1.2  christos # if YYENABLE_NLS
    402  1.2  christos #  if ENABLE_NLS
    403  1.2  christos #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
    404  1.2  christos #   define YY_(msgid) dgettext ("bison-runtime", msgid)
    405  1.2  christos #  endif
    406  1.1  christos # endif
    407  1.2  christos # ifndef YY_
    408  1.2  christos #  define YY_(msgid) msgid
    409  1.1  christos # endif
    410  1.2  christos #endif
    411  1.2  christos 
    412  1.2  christos /* Suppress unused-variable warnings by "using" E.  */
    413  1.2  christos #if ! defined lint || defined __GNUC__
    414  1.2  christos # define YYUSE(e) ((void) (e))
    415  1.2  christos #else
    416  1.2  christos # define YYUSE(e) /* empty */
    417  1.2  christos #endif
    418  1.2  christos 
    419  1.2  christos /* Identity function, used to suppress warnings about constant conditions.  */
    420  1.2  christos #ifndef lint
    421  1.2  christos # define YYID(n) (n)
    422  1.2  christos #else
    423  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
    424  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    425  1.2  christos static int
    426  1.2  christos YYID (int yyi)
    427  1.2  christos #else
    428  1.2  christos static int
    429  1.2  christos YYID (yyi)
    430  1.2  christos     int yyi;
    431  1.2  christos #endif
    432  1.2  christos {
    433  1.2  christos   return yyi;
    434  1.2  christos }
    435  1.2  christos #endif
    436  1.2  christos 
    437  1.2  christos #if ! defined yyoverflow || YYERROR_VERBOSE
    438  1.1  christos 
    439  1.1  christos /* The parser invokes alloca or malloc; define the necessary symbols.  */
    440  1.1  christos 
    441  1.1  christos # ifdef YYSTACK_USE_ALLOCA
    442  1.1  christos #  if YYSTACK_USE_ALLOCA
    443  1.1  christos #   ifdef __GNUC__
    444  1.1  christos #    define YYSTACK_ALLOC __builtin_alloca
    445  1.2  christos #   elif defined __BUILTIN_VA_ARG_INCR
    446  1.2  christos #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
    447  1.2  christos #   elif defined _AIX
    448  1.2  christos #    define YYSTACK_ALLOC __alloca
    449  1.2  christos #   elif defined _MSC_VER
    450  1.2  christos #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
    451  1.2  christos #    define alloca _alloca
    452  1.2  christos #   else
    453  1.2  christos #    define YYSTACK_ALLOC alloca
    454  1.2  christos #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
    455  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    456  1.2  christos #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
    457  1.2  christos #     ifndef _STDLIB_H
    458  1.2  christos #      define _STDLIB_H 1
    459  1.2  christos #     endif
    460  1.2  christos #    endif
    461  1.1  christos #   endif
    462  1.1  christos #  endif
    463  1.1  christos # endif
    464  1.1  christos 
    465  1.1  christos # ifdef YYSTACK_ALLOC
    466  1.2  christos    /* Pacify GCC's `empty if-body' warning.  */
    467  1.2  christos #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
    468  1.2  christos #  ifndef YYSTACK_ALLOC_MAXIMUM
    469  1.2  christos     /* The OS might guarantee only one guard page at the bottom of the stack,
    470  1.2  christos        and a page size can be as small as 4096 bytes.  So we cannot safely
    471  1.2  christos        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
    472  1.2  christos        to allow for a few compiler-allocated temporary stack slots.  */
    473  1.2  christos #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
    474  1.2  christos #  endif
    475  1.1  christos # else
    476  1.2  christos #  define YYSTACK_ALLOC YYMALLOC
    477  1.2  christos #  define YYSTACK_FREE YYFREE
    478  1.2  christos #  ifndef YYSTACK_ALLOC_MAXIMUM
    479  1.2  christos #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
    480  1.2  christos #  endif
    481  1.2  christos #  if (defined __cplusplus && ! defined _STDLIB_H \
    482  1.2  christos        && ! ((defined YYMALLOC || defined malloc) \
    483  1.2  christos 	     && (defined YYFREE || defined free)))
    484  1.1  christos #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
    485  1.2  christos #   ifndef _STDLIB_H
    486  1.2  christos #    define _STDLIB_H 1
    487  1.2  christos #   endif
    488  1.2  christos #  endif
    489  1.2  christos #  ifndef YYMALLOC
    490  1.2  christos #   define YYMALLOC malloc
    491  1.2  christos #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
    492  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    493  1.2  christos void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
    494  1.2  christos #   endif
    495  1.2  christos #  endif
    496  1.2  christos #  ifndef YYFREE
    497  1.2  christos #   define YYFREE free
    498  1.2  christos #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
    499  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    500  1.2  christos void free (void *); /* INFRINGES ON USER NAME SPACE */
    501  1.2  christos #   endif
    502  1.1  christos #  endif
    503  1.1  christos # endif
    504  1.2  christos #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
    505  1.1  christos 
    506  1.1  christos 
    507  1.2  christos #if (! defined yyoverflow \
    508  1.2  christos      && (! defined __cplusplus \
    509  1.2  christos 	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
    510  1.1  christos 
    511  1.1  christos /* A type that is properly aligned for any stack member.  */
    512  1.1  christos union yyalloc
    513  1.1  christos {
    514  1.2  christos   yytype_int16 yyss_alloc;
    515  1.2  christos   YYSTYPE yyvs_alloc;
    516  1.2  christos };
    517  1.1  christos 
    518  1.1  christos /* The size of the maximum gap between one aligned stack and the next.  */
    519  1.1  christos # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
    520  1.1  christos 
    521  1.1  christos /* The size of an array large to enough to hold all stacks, each with
    522  1.1  christos    N elements.  */
    523  1.1  christos # define YYSTACK_BYTES(N) \
    524  1.2  christos      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
    525  1.1  christos       + YYSTACK_GAP_MAXIMUM)
    526  1.1  christos 
    527  1.1  christos /* Copy COUNT objects from FROM to TO.  The source and destination do
    528  1.1  christos    not overlap.  */
    529  1.1  christos # ifndef YYCOPY
    530  1.2  christos #  if defined __GNUC__ && 1 < __GNUC__
    531  1.1  christos #   define YYCOPY(To, From, Count) \
    532  1.1  christos       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
    533  1.1  christos #  else
    534  1.1  christos #   define YYCOPY(To, From, Count)		\
    535  1.1  christos       do					\
    536  1.1  christos 	{					\
    537  1.2  christos 	  YYSIZE_T yyi;				\
    538  1.1  christos 	  for (yyi = 0; yyi < (Count); yyi++)	\
    539  1.1  christos 	    (To)[yyi] = (From)[yyi];		\
    540  1.1  christos 	}					\
    541  1.2  christos       while (YYID (0))
    542  1.1  christos #  endif
    543  1.1  christos # endif
    544  1.1  christos 
    545  1.1  christos /* Relocate STACK from its old location to the new one.  The
    546  1.1  christos    local variables YYSIZE and YYSTACKSIZE give the old and new number of
    547  1.1  christos    elements in the stack, and YYPTR gives the new location of the
    548  1.1  christos    stack.  Advance YYPTR to a properly aligned location for the next
    549  1.1  christos    stack.  */
    550  1.2  christos # define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
    551  1.1  christos     do									\
    552  1.1  christos       {									\
    553  1.1  christos 	YYSIZE_T yynewbytes;						\
    554  1.2  christos 	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
    555  1.2  christos 	Stack = &yyptr->Stack_alloc;					\
    556  1.1  christos 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
    557  1.1  christos 	yyptr += yynewbytes / sizeof (*yyptr);				\
    558  1.1  christos       }									\
    559  1.2  christos     while (YYID (0))
    560  1.1  christos 
    561  1.1  christos #endif
    562  1.1  christos 
    563  1.2  christos /* YYFINAL -- State number of the termination state.  */
    564  1.1  christos #define YYFINAL  12
    565  1.1  christos /* YYLAST -- Last index in YYTABLE.  */
    566  1.2  christos #define YYLAST   92
    567  1.1  christos 
    568  1.2  christos /* YYNTOKENS -- Number of terminals.  */
    569  1.2  christos #define YYNTOKENS  27
    570  1.2  christos /* YYNNTS -- Number of nonterminals.  */
    571  1.2  christos #define YYNNTS  20
    572  1.2  christos /* YYNRULES -- Number of rules.  */
    573  1.2  christos #define YYNRULES  80
    574  1.2  christos /* YYNRULES -- Number of states.  */
    575  1.2  christos #define YYNSTATES  101
    576  1.1  christos 
    577  1.1  christos /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
    578  1.1  christos #define YYUNDEFTOK  2
    579  1.1  christos #define YYMAXUTOK   276
    580  1.1  christos 
    581  1.2  christos #define YYTRANSLATE(YYX)						\
    582  1.1  christos   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
    583  1.1  christos 
    584  1.1  christos /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
    585  1.2  christos static const yytype_uint8 yytranslate[] =
    586  1.1  christos {
    587  1.1  christos        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    588  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    589  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    590  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    591  1.2  christos        2,     2,     2,     2,    25,     2,    23,    26,     2,     2,
    592  1.2  christos        2,     2,     2,     2,     2,     2,     2,     2,    24,     2,
    593  1.1  christos        2,     2,     2,     2,    22,     2,     2,     2,     2,     2,
    594  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    595  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    596  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    597  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    598  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    599  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    600  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    601  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    602  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    603  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    604  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    605  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    606  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    607  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    608  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    609  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    610  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    611  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    612  1.1  christos        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
    613  1.1  christos        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
    614  1.1  christos       15,    16,    17,    18,    19,    20,    21
    615  1.1  christos };
    616  1.1  christos 
    617  1.1  christos #if YYDEBUG
    618  1.1  christos /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    619  1.1  christos    YYRHS.  */
    620  1.2  christos static const yytype_uint8 yyprhs[] =
    621  1.1  christos {
    622  1.1  christos        0,     0,     3,     5,     7,    10,    11,    14,    16,    18,
    623  1.2  christos       20,    22,    24,    26,    28,    30,    36,    39,    44,    50,
    624  1.2  christos       57,    65,    67,    70,    72,    75,    79,    81,    84,    86,
    625  1.2  christos       89,    92,    95,    99,   105,   109,   113,   117,   120,   125,
    626  1.2  christos      128,   132,   135,   137,   140,   143,   145,   148,   151,   153,
    627  1.2  christos      156,   159,   161,   164,   167,   169,   172,   175,   177,   180,
    628  1.2  christos      183,   186,   189,   191,   193,   196,   199,   202,   205,   208,
    629  1.2  christos      211,   213,   215,   217,   219,   221,   223,   225,   226,   229,
    630  1.2  christos      230
    631  1.2  christos };
    632  1.2  christos 
    633  1.2  christos /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
    634  1.2  christos static const yytype_int8 yyrhs[] =
    635  1.2  christos {
    636  1.2  christos       28,     0,    -1,    29,    -1,    30,    -1,    22,    41,    -1,
    637  1.2  christos       -1,    30,    31,    -1,    33,    -1,    34,    -1,    35,    -1,
    638  1.2  christos       37,    -1,    36,    -1,    38,    -1,    32,    -1,    44,    -1,
    639  1.2  christos       21,    23,    21,    23,    21,    -1,    19,    10,    -1,    19,
    640  1.2  christos       24,    19,    46,    -1,    19,    24,    19,    18,    45,    -1,
    641  1.2  christos       19,    24,    19,    24,    43,    46,    -1,    19,    24,    19,
    642  1.2  christos       24,    43,    18,    45,    -1,     9,    -1,     9,     4,    -1,
    643  1.2  christos       17,    -1,    17,    40,    -1,    17,    18,    45,    -1,     7,
    644  1.2  christos       -1,    17,     4,    -1,     5,    -1,     5,    25,    -1,    14,
    645  1.2  christos        5,    -1,    19,     5,    -1,    19,    26,    19,    -1,    19,
    646  1.2  christos       26,    19,    26,    19,    -1,    19,    18,    18,    -1,    19,
    647  1.2  christos       12,    18,    -1,    12,    18,    18,    -1,    12,    19,    -1,
    648  1.2  christos       12,    19,    25,    19,    -1,    19,    12,    -1,    19,    12,
    649  1.2  christos       19,    -1,    39,     3,    -1,    39,    -1,    14,    16,    -1,
    650  1.2  christos       19,    16,    -1,    16,    -1,    14,    13,    -1,    19,    13,
    651  1.2  christos       -1,    13,    -1,    14,     6,    -1,    19,     6,    -1,     6,
    652  1.2  christos       -1,    14,     8,    -1,    19,     8,    -1,     8,    -1,    14,
    653  1.2  christos       11,    -1,    19,    11,    -1,    11,    -1,    14,    15,    -1,
    654  1.2  christos       19,    15,    -1,    20,    15,    -1,    21,    15,    -1,    15,
    655  1.2  christos       -1,    40,    -1,    18,    16,    -1,    18,    13,    -1,    18,
    656  1.2  christos        6,    -1,    18,     8,    -1,    18,    11,    -1,    18,    15,
    657  1.2  christos       -1,    42,    -1,    43,    -1,    20,    -1,    18,    -1,    21,
    658  1.2  christos       -1,    19,    -1,    19,    -1,    -1,    24,    19,    -1,    -1,
    659  1.2  christos       10,    -1
    660  1.1  christos };
    661  1.1  christos 
    662  1.1  christos /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
    663  1.2  christos static const yytype_uint16 yyrline[] =
    664  1.1  christos {
    665  1.1  christos        0,   230,   230,   231,   235,   242,   244,   248,   250,   252,
    666  1.2  christos      254,   256,   258,   260,   266,   269,   296,   304,   312,   322,
    667  1.2  christos      329,   341,   346,   354,   356,   358,   360,   362,   367,   372,
    668  1.2  christos      377,   382,   390,   395,   415,   422,   430,   438,   443,   449,
    669  1.2  christos      454,   463,   473,   477,   479,   481,   483,   485,   487,   489,
    670  1.2  christos      491,   493,   495,   497,   499,   501,   503,   505,   507,   509,
    671  1.2  christos      511,   513,   515,   517,   521,   523,   525,   527,   529,   531,
    672  1.2  christos      535,   535,   538,   539,   544,   545,   550,   588,   589,   595,
    673  1.2  christos      596
    674  1.1  christos };
    675  1.1  christos #endif
    676  1.1  christos 
    677  1.2  christos #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
    678  1.2  christos /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    679  1.2  christos    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
    680  1.1  christos static const char *const yytname[] =
    681  1.1  christos {
    682  1.1  christos   "$end", "error", "$undefined", "tAGO", "tDST", "tDAY", "tDAY_UNIT",
    683  1.1  christos   "tDAYZONE", "tHOUR_UNIT", "tLOCAL_ZONE", "tMERIDIAN", "tMINUTE_UNIT",
    684  1.1  christos   "tMONTH", "tMONTH_UNIT", "tORDINAL", "tSEC_UNIT", "tYEAR_UNIT", "tZONE",
    685  1.1  christos   "tSNUMBER", "tUNUMBER", "tSDECIMAL_NUMBER", "tUDECIMAL_NUMBER", "'@'",
    686  1.2  christos   "'.'", "':'", "','", "'/'", "$accept", "spec", "timespec", "items",
    687  1.2  christos   "item", "cvsstamp", "time", "local_zone", "zone", "day", "date", "rel",
    688  1.2  christos   "relunit", "relunit_snumber", "seconds", "signed_seconds",
    689  1.2  christos   "unsigned_seconds", "number", "o_colon_minutes", "o_merid", 0
    690  1.1  christos };
    691  1.1  christos #endif
    692  1.1  christos 
    693  1.1  christos # ifdef YYPRINT
    694  1.1  christos /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
    695  1.1  christos    token YYLEX-NUM.  */
    696  1.2  christos static const yytype_uint16 yytoknum[] =
    697  1.1  christos {
    698  1.1  christos        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
    699  1.1  christos      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
    700  1.2  christos      275,   276,    64,    46,    58,    44,    47
    701  1.1  christos };
    702  1.1  christos # endif
    703  1.1  christos 
    704  1.1  christos /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
    705  1.2  christos static const yytype_uint8 yyr1[] =
    706  1.1  christos {
    707  1.2  christos        0,    27,    28,    28,    29,    30,    30,    31,    31,    31,
    708  1.2  christos       31,    31,    31,    31,    31,    32,    33,    33,    33,    33,
    709  1.2  christos       33,    34,    34,    35,    35,    35,    35,    35,    36,    36,
    710  1.2  christos       36,    36,    37,    37,    37,    37,    37,    37,    37,    37,
    711  1.2  christos       37,    38,    38,    39,    39,    39,    39,    39,    39,    39,
    712  1.2  christos       39,    39,    39,    39,    39,    39,    39,    39,    39,    39,
    713  1.2  christos       39,    39,    39,    39,    40,    40,    40,    40,    40,    40,
    714  1.2  christos       41,    41,    42,    42,    43,    43,    44,    45,    45,    46,
    715  1.2  christos       46
    716  1.1  christos };
    717  1.1  christos 
    718  1.1  christos /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
    719  1.2  christos static const yytype_uint8 yyr2[] =
    720  1.1  christos {
    721  1.1  christos        0,     2,     1,     1,     2,     0,     2,     1,     1,     1,
    722  1.2  christos        1,     1,     1,     1,     1,     5,     2,     4,     5,     6,
    723  1.2  christos        7,     1,     2,     1,     2,     3,     1,     2,     1,     2,
    724  1.2  christos        2,     2,     3,     5,     3,     3,     3,     2,     4,     2,
    725  1.2  christos        3,     2,     1,     2,     2,     1,     2,     2,     1,     2,
    726  1.2  christos        2,     1,     2,     2,     1,     2,     2,     1,     2,     2,
    727  1.2  christos        2,     2,     1,     1,     2,     2,     2,     2,     2,     2,
    728  1.2  christos        1,     1,     1,     1,     1,     1,     1,     0,     2,     0,
    729  1.2  christos        1
    730  1.1  christos };
    731  1.1  christos 
    732  1.1  christos /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
    733  1.1  christos    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
    734  1.1  christos    means the default is an error.  */
    735  1.2  christos static const yytype_uint8 yydefact[] =
    736  1.1  christos {
    737  1.2  christos        5,     0,     0,     2,     3,    73,    75,    72,    74,     4,
    738  1.2  christos       70,    71,     1,    28,    51,    26,    54,    21,    57,     0,
    739  1.2  christos       48,     0,    62,    45,    23,     0,    76,     0,     0,     6,
    740  1.2  christos       13,     7,     8,     9,    11,    10,    12,    42,    63,    14,
    741  1.2  christos       29,    22,     0,    37,    30,    49,    52,    55,    46,    58,
    742  1.2  christos       43,    27,    77,    24,    66,    67,    68,    65,    69,    64,
    743  1.2  christos       31,    50,    53,    16,    56,    39,    47,    59,    44,     0,
    744  1.2  christos        0,     0,    60,    61,     0,    41,    36,     0,     0,    25,
    745  1.2  christos       35,    40,    34,    79,    32,     0,    38,    78,    80,    77,
    746  1.2  christos        0,    17,     0,     0,    18,    79,    33,    15,    77,    19,
    747  1.2  christos       20
    748  1.1  christos };
    749  1.1  christos 
    750  1.2  christos /* YYDEFGOTO[NTERM-NUM].  */
    751  1.2  christos static const yytype_int8 yydefgoto[] =
    752  1.1  christos {
    753  1.1  christos       -1,     2,     3,     4,    29,    30,    31,    32,    33,    34,
    754  1.2  christos       35,    36,    37,    38,     9,    10,    11,    39,    79,    91
    755  1.1  christos };
    756  1.1  christos 
    757  1.1  christos /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    758  1.1  christos    STATE-NUM.  */
    759  1.2  christos #define YYPACT_NINF -76
    760  1.2  christos static const yytype_int8 yypact[] =
    761  1.1  christos {
    762  1.2  christos      -13,    45,    67,   -76,    23,   -76,   -76,   -76,   -76,   -76,
    763  1.2  christos      -76,   -76,   -76,    47,   -76,   -76,   -76,    69,   -76,     8,
    764  1.2  christos      -76,    40,   -76,   -76,    -2,    46,    -5,    56,    35,   -76,
    765  1.2  christos      -76,   -76,   -76,   -76,   -76,   -76,   -76,    71,   -76,   -76,
    766  1.2  christos      -76,   -76,    57,    52,   -76,   -76,   -76,   -76,   -76,   -76,
    767  1.2  christos      -76,   -76,     9,   -76,   -76,   -76,   -76,   -76,   -76,   -76,
    768  1.2  christos      -76,   -76,   -76,   -76,   -76,    51,   -76,   -76,   -76,    58,
    769  1.2  christos       59,    60,   -76,   -76,    61,   -76,   -76,    62,    64,   -76,
    770  1.2  christos      -76,   -76,   -76,    -6,    54,    63,   -76,   -76,   -76,    65,
    771  1.2  christos       28,   -76,    66,    70,   -76,    50,   -76,   -76,    65,   -76,
    772  1.2  christos      -76
    773  1.1  christos };
    774  1.1  christos 
    775  1.1  christos /* YYPGOTO[NTERM-NUM].  */
    776  1.2  christos static const yytype_int8 yypgoto[] =
    777  1.1  christos {
    778  1.2  christos      -76,   -76,   -76,   -76,   -76,   -76,   -76,   -76,   -76,   -76,
    779  1.2  christos      -76,   -76,   -76,    68,   -76,   -76,    -3,   -76,   -75,   -11
    780  1.1  christos };
    781  1.1  christos 
    782  1.1  christos /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    783  1.1  christos    positive, shift that token.  If negative, reduce the rule which
    784  1.1  christos    number is the opposite.  If zero, do what YYDEFACT says.
    785  1.1  christos    If YYTABLE_NINF, syntax error.  */
    786  1.1  christos #define YYTABLE_NINF -1
    787  1.2  christos static const yytype_uint8 yytable[] =
    788  1.1  christos {
    789  1.2  christos       60,    61,    51,    62,    88,    63,    64,    65,    66,     1,
    790  1.2  christos       67,    68,    89,    69,    94,    54,    52,    55,    90,    70,
    791  1.2  christos       56,    71,    57,   100,    58,    59,    42,    43,    13,    14,
    792  1.2  christos       15,    16,    17,    78,    18,    19,    20,    21,    22,    23,
    793  1.2  christos       24,    25,    26,    27,    28,    44,    45,     6,    46,     8,
    794  1.2  christos       73,    47,    54,    48,    55,    49,    50,    56,    74,    57,
    795  1.2  christos       88,    58,    59,     5,     6,     7,     8,    12,    98,    80,
    796  1.2  christos       81,    72,    40,    41,    75,    76,    82,    77,    83,    84,
    797  1.2  christos       92,    86,    85,    87,    99,    96,    93,    95,     0,    78,
    798  1.2  christos        0,    97,    53
    799  1.2  christos };
    800  1.2  christos 
    801  1.2  christos static const yytype_int8 yycheck[] =
    802  1.2  christos {
    803  1.2  christos        5,     6,     4,     8,    10,    10,    11,    12,    13,    22,
    804  1.2  christos       15,    16,    18,    18,    89,     6,    18,     8,    24,    24,
    805  1.2  christos       11,    26,    13,    98,    15,    16,    18,    19,     5,     6,
    806  1.2  christos        7,     8,     9,    24,    11,    12,    13,    14,    15,    16,
    807  1.2  christos       17,    18,    19,    20,    21,     5,     6,    19,     8,    21,
    808  1.2  christos       15,    11,     6,    13,     8,    15,    16,    11,    23,    13,
    809  1.2  christos       10,    15,    16,    18,    19,    20,    21,     0,    18,    18,
    810  1.2  christos       19,    15,    25,     4,     3,    18,    18,    25,    19,    19,
    811  1.2  christos       26,    19,    21,    19,    95,    19,    23,    90,    -1,    24,
    812  1.2  christos       -1,    21,    24
    813  1.1  christos };
    814  1.1  christos 
    815  1.1  christos /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    816  1.1  christos    symbol of state STATE-NUM.  */
    817  1.2  christos static const yytype_uint8 yystos[] =
    818  1.1  christos {
    819  1.2  christos        0,    22,    28,    29,    30,    18,    19,    20,    21,    41,
    820  1.2  christos       42,    43,     0,     5,     6,     7,     8,     9,    11,    12,
    821  1.2  christos       13,    14,    15,    16,    17,    18,    19,    20,    21,    31,
    822  1.2  christos       32,    33,    34,    35,    36,    37,    38,    39,    40,    44,
    823  1.2  christos       25,     4,    18,    19,     5,     6,     8,    11,    13,    15,
    824  1.2  christos       16,     4,    18,    40,     6,     8,    11,    13,    15,    16,
    825  1.2  christos        5,     6,     8,    10,    11,    12,    13,    15,    16,    18,
    826  1.2  christos       24,    26,    15,    15,    23,     3,    18,    25,    24,    45,
    827  1.2  christos       18,    19,    18,    19,    19,    21,    19,    19,    10,    18,
    828  1.2  christos       24,    46,    26,    23,    45,    43,    19,    21,    18,    46,
    829  1.2  christos       45
    830  1.1  christos };
    831  1.1  christos 
    832  1.1  christos #define yyerrok		(yyerrstatus = 0)
    833  1.1  christos #define yyclearin	(yychar = YYEMPTY)
    834  1.1  christos #define YYEMPTY		(-2)
    835  1.1  christos #define YYEOF		0
    836  1.1  christos 
    837  1.1  christos #define YYACCEPT	goto yyacceptlab
    838  1.1  christos #define YYABORT		goto yyabortlab
    839  1.1  christos #define YYERROR		goto yyerrorlab
    840  1.1  christos 
    841  1.1  christos 
    842  1.1  christos /* Like YYERROR except do call yyerror.  This remains here temporarily
    843  1.1  christos    to ease the transition to the new meaning of YYERROR, for GCC.
    844  1.1  christos    Once GCC version 2 has supplanted version 1, this can go.  */
    845  1.1  christos 
    846  1.1  christos #define YYFAIL		goto yyerrlab
    847  1.1  christos 
    848  1.1  christos #define YYRECOVERING()  (!!yyerrstatus)
    849  1.1  christos 
    850  1.1  christos #define YYBACKUP(Token, Value)					\
    851  1.1  christos do								\
    852  1.1  christos   if (yychar == YYEMPTY && yylen == 1)				\
    853  1.1  christos     {								\
    854  1.1  christos       yychar = (Token);						\
    855  1.1  christos       yylval = (Value);						\
    856  1.1  christos       yytoken = YYTRANSLATE (yychar);				\
    857  1.2  christos       YYPOPSTACK (1);						\
    858  1.1  christos       goto yybackup;						\
    859  1.1  christos     }								\
    860  1.1  christos   else								\
    861  1.2  christos     {								\
    862  1.2  christos       yyerror (pc, YY_("syntax error: cannot back up")); \
    863  1.1  christos       YYERROR;							\
    864  1.1  christos     }								\
    865  1.2  christos while (YYID (0))
    866  1.2  christos 
    867  1.1  christos 
    868  1.1  christos #define YYTERROR	1
    869  1.1  christos #define YYERRCODE	256
    870  1.1  christos 
    871  1.1  christos 
    872  1.2  christos /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    873  1.2  christos    If N is 0, then set CURRENT to the empty location which ends
    874  1.2  christos    the previous symbol: RHS[0] (always defined).  */
    875  1.2  christos 
    876  1.2  christos #define YYRHSLOC(Rhs, K) ((Rhs)[K])
    877  1.1  christos #ifndef YYLLOC_DEFAULT
    878  1.2  christos # define YYLLOC_DEFAULT(Current, Rhs, N)				\
    879  1.2  christos     do									\
    880  1.2  christos       if (YYID (N))                                                    \
    881  1.2  christos 	{								\
    882  1.2  christos 	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
    883  1.2  christos 	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
    884  1.2  christos 	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
    885  1.2  christos 	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
    886  1.2  christos 	}								\
    887  1.2  christos       else								\
    888  1.2  christos 	{								\
    889  1.2  christos 	  (Current).first_line   = (Current).last_line   =		\
    890  1.2  christos 	    YYRHSLOC (Rhs, 0).last_line;				\
    891  1.2  christos 	  (Current).first_column = (Current).last_column =		\
    892  1.2  christos 	    YYRHSLOC (Rhs, 0).last_column;				\
    893  1.2  christos 	}								\
    894  1.2  christos     while (YYID (0))
    895  1.2  christos #endif
    896  1.2  christos 
    897  1.2  christos 
    898  1.2  christos /* YY_LOCATION_PRINT -- Print the location on the stream.
    899  1.2  christos    This macro was not mandated originally: define only if we know
    900  1.2  christos    we won't break user code: when these are the locations we know.  */
    901  1.2  christos 
    902  1.2  christos #ifndef YY_LOCATION_PRINT
    903  1.2  christos # if YYLTYPE_IS_TRIVIAL
    904  1.2  christos #  define YY_LOCATION_PRINT(File, Loc)			\
    905  1.2  christos      fprintf (File, "%d.%d-%d.%d",			\
    906  1.2  christos 	      (Loc).first_line, (Loc).first_column,	\
    907  1.2  christos 	      (Loc).last_line,  (Loc).last_column)
    908  1.2  christos # else
    909  1.2  christos #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
    910  1.2  christos # endif
    911  1.1  christos #endif
    912  1.1  christos 
    913  1.2  christos 
    914  1.1  christos /* YYLEX -- calling `yylex' with the right arguments.  */
    915  1.1  christos 
    916  1.1  christos #ifdef YYLEX_PARAM
    917  1.1  christos # define YYLEX yylex (&yylval, YYLEX_PARAM)
    918  1.1  christos #else
    919  1.1  christos # define YYLEX yylex (&yylval, pc)
    920  1.1  christos #endif
    921  1.1  christos 
    922  1.1  christos /* Enable debugging if requested.  */
    923  1.1  christos #if YYDEBUG
    924  1.1  christos 
    925  1.1  christos # ifndef YYFPRINTF
    926  1.1  christos #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
    927  1.1  christos #  define YYFPRINTF fprintf
    928  1.1  christos # endif
    929  1.1  christos 
    930  1.1  christos # define YYDPRINTF(Args)			\
    931  1.1  christos do {						\
    932  1.1  christos   if (yydebug)					\
    933  1.1  christos     YYFPRINTF Args;				\
    934  1.2  christos } while (YYID (0))
    935  1.2  christos 
    936  1.2  christos # define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
    937  1.2  christos do {									  \
    938  1.2  christos   if (yydebug)								  \
    939  1.2  christos     {									  \
    940  1.2  christos       YYFPRINTF (stderr, "%s ", Title);					  \
    941  1.2  christos       yy_symbol_print (stderr,						  \
    942  1.2  christos 		  Type, Value, pc); \
    943  1.2  christos       YYFPRINTF (stderr, "\n");						  \
    944  1.2  christos     }									  \
    945  1.2  christos } while (YYID (0))
    946  1.2  christos 
    947  1.2  christos 
    948  1.2  christos /*--------------------------------.
    949  1.2  christos | Print this symbol on YYOUTPUT.  |
    950  1.2  christos `--------------------------------*/
    951  1.2  christos 
    952  1.2  christos /*ARGSUSED*/
    953  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
    954  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    955  1.2  christos static void
    956  1.2  christos yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc)
    957  1.2  christos #else
    958  1.2  christos static void
    959  1.2  christos yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc)
    960  1.2  christos     FILE *yyoutput;
    961  1.2  christos     int yytype;
    962  1.2  christos     YYSTYPE const * const yyvaluep;
    963  1.2  christos     parser_control *pc;
    964  1.2  christos #endif
    965  1.2  christos {
    966  1.2  christos   if (!yyvaluep)
    967  1.2  christos     return;
    968  1.2  christos   YYUSE (pc);
    969  1.2  christos # ifdef YYPRINT
    970  1.2  christos   if (yytype < YYNTOKENS)
    971  1.2  christos     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
    972  1.2  christos # else
    973  1.2  christos   YYUSE (yyoutput);
    974  1.2  christos # endif
    975  1.2  christos   switch (yytype)
    976  1.2  christos     {
    977  1.2  christos       default:
    978  1.2  christos 	break;
    979  1.2  christos     }
    980  1.2  christos }
    981  1.2  christos 
    982  1.2  christos 
    983  1.2  christos /*--------------------------------.
    984  1.2  christos | Print this symbol on YYOUTPUT.  |
    985  1.2  christos `--------------------------------*/
    986  1.1  christos 
    987  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
    988  1.2  christos      || defined __cplusplus || defined _MSC_VER)
    989  1.2  christos static void
    990  1.2  christos yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc)
    991  1.2  christos #else
    992  1.2  christos static void
    993  1.2  christos yy_symbol_print (yyoutput, yytype, yyvaluep, pc)
    994  1.2  christos     FILE *yyoutput;
    995  1.2  christos     int yytype;
    996  1.2  christos     YYSTYPE const * const yyvaluep;
    997  1.2  christos     parser_control *pc;
    998  1.2  christos #endif
    999  1.2  christos {
   1000  1.2  christos   if (yytype < YYNTOKENS)
   1001  1.2  christos     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
   1002  1.2  christos   else
   1003  1.2  christos     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
   1004  1.1  christos 
   1005  1.2  christos   yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc);
   1006  1.2  christos   YYFPRINTF (yyoutput, ")");
   1007  1.2  christos }
   1008  1.1  christos 
   1009  1.1  christos /*------------------------------------------------------------------.
   1010  1.1  christos | yy_stack_print -- Print the state stack from its BOTTOM up to its |
   1011  1.1  christos | TOP (included).                                                   |
   1012  1.1  christos `------------------------------------------------------------------*/
   1013  1.1  christos 
   1014  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1015  1.2  christos      || defined __cplusplus || defined _MSC_VER)
   1016  1.1  christos static void
   1017  1.2  christos yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
   1018  1.1  christos #else
   1019  1.1  christos static void
   1020  1.2  christos yy_stack_print (yybottom, yytop)
   1021  1.2  christos     yytype_int16 *yybottom;
   1022  1.2  christos     yytype_int16 *yytop;
   1023  1.1  christos #endif
   1024  1.1  christos {
   1025  1.1  christos   YYFPRINTF (stderr, "Stack now");
   1026  1.2  christos   for (; yybottom <= yytop; yybottom++)
   1027  1.2  christos     {
   1028  1.2  christos       int yybot = *yybottom;
   1029  1.2  christos       YYFPRINTF (stderr, " %d", yybot);
   1030  1.2  christos     }
   1031  1.1  christos   YYFPRINTF (stderr, "\n");
   1032  1.1  christos }
   1033  1.1  christos 
   1034  1.1  christos # define YY_STACK_PRINT(Bottom, Top)				\
   1035  1.1  christos do {								\
   1036  1.1  christos   if (yydebug)							\
   1037  1.1  christos     yy_stack_print ((Bottom), (Top));				\
   1038  1.2  christos } while (YYID (0))
   1039  1.1  christos 
   1040  1.1  christos 
   1041  1.1  christos /*------------------------------------------------.
   1042  1.1  christos | Report that the YYRULE is going to be reduced.  |
   1043  1.1  christos `------------------------------------------------*/
   1044  1.1  christos 
   1045  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1046  1.2  christos      || defined __cplusplus || defined _MSC_VER)
   1047  1.1  christos static void
   1048  1.2  christos yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parser_control *pc)
   1049  1.1  christos #else
   1050  1.1  christos static void
   1051  1.2  christos yy_reduce_print (yyvsp, yyrule, pc)
   1052  1.2  christos     YYSTYPE *yyvsp;
   1053  1.1  christos     int yyrule;
   1054  1.2  christos     parser_control *pc;
   1055  1.1  christos #endif
   1056  1.1  christos {
   1057  1.2  christos   int yynrhs = yyr2[yyrule];
   1058  1.1  christos   int yyi;
   1059  1.2  christos   unsigned long int yylno = yyrline[yyrule];
   1060  1.2  christos   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
   1061  1.2  christos 	     yyrule - 1, yylno);
   1062  1.2  christos   /* The symbols being reduced.  */
   1063  1.2  christos   for (yyi = 0; yyi < yynrhs; yyi++)
   1064  1.2  christos     {
   1065  1.2  christos       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
   1066  1.2  christos       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
   1067  1.2  christos 		       &(yyvsp[(yyi + 1) - (yynrhs)])
   1068  1.2  christos 		       		       , pc);
   1069  1.2  christos       YYFPRINTF (stderr, "\n");
   1070  1.2  christos     }
   1071  1.1  christos }
   1072  1.1  christos 
   1073  1.1  christos # define YY_REDUCE_PRINT(Rule)		\
   1074  1.1  christos do {					\
   1075  1.1  christos   if (yydebug)				\
   1076  1.2  christos     yy_reduce_print (yyvsp, Rule, pc); \
   1077  1.2  christos } while (YYID (0))
   1078  1.1  christos 
   1079  1.1  christos /* Nonzero means print parse trace.  It is left uninitialized so that
   1080  1.1  christos    multiple parsers can coexist.  */
   1081  1.1  christos int yydebug;
   1082  1.1  christos #else /* !YYDEBUG */
   1083  1.1  christos # define YYDPRINTF(Args)
   1084  1.2  christos # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
   1085  1.1  christos # define YY_STACK_PRINT(Bottom, Top)
   1086  1.1  christos # define YY_REDUCE_PRINT(Rule)
   1087  1.1  christos #endif /* !YYDEBUG */
   1088  1.1  christos 
   1089  1.1  christos 
   1090  1.1  christos /* YYINITDEPTH -- initial size of the parser's stacks.  */
   1091  1.1  christos #ifndef	YYINITDEPTH
   1092  1.1  christos # define YYINITDEPTH 200
   1093  1.1  christos #endif
   1094  1.1  christos 
   1095  1.1  christos /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   1096  1.1  christos    if the built-in stack extension method is used).
   1097  1.1  christos 
   1098  1.1  christos    Do not make this value too large; the results are undefined if
   1099  1.2  christos    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   1100  1.1  christos    evaluated with infinite-precision integer arithmetic.  */
   1101  1.1  christos 
   1102  1.1  christos #ifndef YYMAXDEPTH
   1103  1.1  christos # define YYMAXDEPTH 10000
   1104  1.1  christos #endif
   1105  1.1  christos 
   1106  1.1  christos 
   1107  1.1  christos 
   1109  1.1  christos #if YYERROR_VERBOSE
   1110  1.1  christos 
   1111  1.2  christos # ifndef yystrlen
   1112  1.1  christos #  if defined __GLIBC__ && defined _STRING_H
   1113  1.1  christos #   define yystrlen strlen
   1114  1.1  christos #  else
   1115  1.2  christos /* Return the length of YYSTR.  */
   1116  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1117  1.1  christos      || defined __cplusplus || defined _MSC_VER)
   1118  1.1  christos static YYSIZE_T
   1119  1.2  christos yystrlen (const char *yystr)
   1120  1.2  christos #else
   1121  1.1  christos static YYSIZE_T
   1122  1.2  christos yystrlen (yystr)
   1123  1.2  christos     const char *yystr;
   1124  1.1  christos #endif
   1125  1.2  christos {
   1126  1.2  christos   YYSIZE_T yylen;
   1127  1.1  christos   for (yylen = 0; yystr[yylen]; yylen++)
   1128  1.2  christos     continue;
   1129  1.1  christos   return yylen;
   1130  1.1  christos }
   1131  1.1  christos #  endif
   1132  1.1  christos # endif
   1133  1.1  christos 
   1134  1.2  christos # ifndef yystpcpy
   1135  1.1  christos #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
   1136  1.1  christos #   define yystpcpy stpcpy
   1137  1.1  christos #  else
   1138  1.1  christos /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   1139  1.2  christos    YYDEST.  */
   1140  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1141  1.1  christos      || defined __cplusplus || defined _MSC_VER)
   1142  1.1  christos static char *
   1143  1.2  christos yystpcpy (char *yydest, const char *yysrc)
   1144  1.2  christos #else
   1145  1.1  christos static char *
   1146  1.2  christos yystpcpy (yydest, yysrc)
   1147  1.2  christos     char *yydest;
   1148  1.2  christos     const char *yysrc;
   1149  1.1  christos #endif
   1150  1.2  christos {
   1151  1.2  christos   char *yyd = yydest;
   1152  1.1  christos   const char *yys = yysrc;
   1153  1.1  christos 
   1154  1.1  christos   while ((*yyd++ = *yys++) != '\0')
   1155  1.1  christos     continue;
   1156  1.1  christos 
   1157  1.1  christos   return yyd - 1;
   1158  1.1  christos }
   1159  1.1  christos #  endif
   1160  1.1  christos # endif
   1161  1.2  christos 
   1162  1.2  christos # ifndef yytnamerr
   1163  1.2  christos /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   1164  1.2  christos    quotes and backslashes, so that it's suitable for yyerror.  The
   1165  1.2  christos    heuristic is that double-quoting is unnecessary unless the string
   1166  1.2  christos    contains an apostrophe, a comma, or backslash (other than
   1167  1.2  christos    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   1168  1.2  christos    null, do not copy; instead, return the length of what the result
   1169  1.2  christos    would have been.  */
   1170  1.2  christos static YYSIZE_T
   1171  1.2  christos yytnamerr (char *yyres, const char *yystr)
   1172  1.2  christos {
   1173  1.2  christos   if (*yystr == '"')
   1174  1.2  christos     {
   1175  1.2  christos       YYSIZE_T yyn = 0;
   1176  1.2  christos       char const *yyp = yystr;
   1177  1.2  christos 
   1178  1.2  christos       for (;;)
   1179  1.2  christos 	switch (*++yyp)
   1180  1.2  christos 	  {
   1181  1.2  christos 	  case '\'':
   1182  1.2  christos 	  case ',':
   1183  1.2  christos 	    goto do_not_strip_quotes;
   1184  1.2  christos 
   1185  1.2  christos 	  case '\\':
   1186  1.2  christos 	    if (*++yyp != '\\')
   1187  1.2  christos 	      goto do_not_strip_quotes;
   1188  1.2  christos 	    /* Fall through.  */
   1189  1.2  christos 	  default:
   1190  1.2  christos 	    if (yyres)
   1191  1.2  christos 	      yyres[yyn] = *yyp;
   1192  1.2  christos 	    yyn++;
   1193  1.1  christos 	    break;
   1194  1.2  christos 
   1195  1.2  christos 	  case '"':
   1196  1.2  christos 	    if (yyres)
   1197  1.2  christos 	      yyres[yyn] = '\0';
   1198  1.2  christos 	    return yyn;
   1199  1.2  christos 	  }
   1200  1.2  christos     do_not_strip_quotes: ;
   1201  1.2  christos     }
   1202  1.2  christos 
   1203  1.2  christos   if (! yyres)
   1204  1.1  christos     return yystrlen (yystr);
   1205  1.2  christos 
   1206  1.2  christos   return yystpcpy (yyres, yystr) - yyres;
   1207  1.2  christos }
   1208  1.1  christos # endif
   1209  1.2  christos 
   1210  1.2  christos /* Copy into YYRESULT an error message about the unexpected token
   1211  1.2  christos    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
   1212  1.2  christos    including the terminating null byte.  If YYRESULT is null, do not
   1213  1.2  christos    copy anything; just return the number of bytes that would be
   1214  1.2  christos    copied.  As a special case, return 0 if an ordinary "syntax error"
   1215  1.2  christos    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
   1216  1.2  christos    size calculation.  */
   1217  1.2  christos static YYSIZE_T
   1218  1.1  christos yysyntax_error (char *yyresult, int yystate, int yychar)
   1219  1.2  christos {
   1220  1.1  christos   int yyn = yypact[yystate];
   1221  1.2  christos 
   1222  1.2  christos   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
   1223  1.2  christos     return 0;
   1224  1.1  christos   else
   1225  1.2  christos     {
   1226  1.2  christos       int yytype = YYTRANSLATE (yychar);
   1227  1.2  christos       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
   1228  1.2  christos       YYSIZE_T yysize = yysize0;
   1229  1.2  christos       YYSIZE_T yysize1;
   1230  1.2  christos       int yysize_overflow = 0;
   1231  1.2  christos       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   1232  1.2  christos       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
   1233  1.2  christos       int yyx;
   1234  1.2  christos 
   1235  1.2  christos # if 0
   1236  1.2  christos       /* This is so xgettext sees the translatable formats that are
   1237  1.2  christos 	 constructed on the fly.  */
   1238  1.2  christos       YY_("syntax error, unexpected %s");
   1239  1.2  christos       YY_("syntax error, unexpected %s, expecting %s");
   1240  1.2  christos       YY_("syntax error, unexpected %s, expecting %s or %s");
   1241  1.2  christos       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
   1242  1.1  christos       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
   1243  1.2  christos # endif
   1244  1.2  christos       char *yyfmt;
   1245  1.2  christos       char const *yyf;
   1246  1.2  christos       static char const yyunexpected[] = "syntax error, unexpected %s";
   1247  1.2  christos       static char const yyexpecting[] = ", expecting %s";
   1248  1.2  christos       static char const yyor[] = " or %s";
   1249  1.2  christos       char yyformat[sizeof yyunexpected
   1250  1.2  christos 		    + sizeof yyexpecting - 1
   1251  1.2  christos 		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
   1252  1.2  christos 		       * (sizeof yyor - 1))];
   1253  1.2  christos       char const *yyprefix = yyexpecting;
   1254  1.2  christos 
   1255  1.2  christos       /* Start YYX at -YYN if negative to avoid negative indexes in
   1256  1.2  christos 	 YYCHECK.  */
   1257  1.2  christos       int yyxbegin = yyn < 0 ? -yyn : 0;
   1258  1.2  christos 
   1259  1.2  christos       /* Stay within bounds of both yycheck and yytname.  */
   1260  1.2  christos       int yychecklim = YYLAST - yyn + 1;
   1261  1.2  christos       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
   1262  1.2  christos       int yycount = 1;
   1263  1.2  christos 
   1264  1.2  christos       yyarg[0] = yytname[yytype];
   1265  1.2  christos       yyfmt = yystpcpy (yyformat, yyunexpected);
   1266  1.2  christos 
   1267  1.2  christos       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
   1268  1.2  christos 	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
   1269  1.2  christos 	  {
   1270  1.2  christos 	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
   1271  1.2  christos 	      {
   1272  1.2  christos 		yycount = 1;
   1273  1.2  christos 		yysize = yysize0;
   1274  1.2  christos 		yyformat[sizeof yyunexpected - 1] = '\0';
   1275  1.2  christos 		break;
   1276  1.2  christos 	      }
   1277  1.2  christos 	    yyarg[yycount++] = yytname[yyx];
   1278  1.2  christos 	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
   1279  1.2  christos 	    yysize_overflow |= (yysize1 < yysize);
   1280  1.2  christos 	    yysize = yysize1;
   1281  1.2  christos 	    yyfmt = yystpcpy (yyfmt, yyprefix);
   1282  1.2  christos 	    yyprefix = yyor;
   1283  1.2  christos 	  }
   1284  1.2  christos 
   1285  1.2  christos       yyf = YY_(yyformat);
   1286  1.2  christos       yysize1 = yysize + yystrlen (yyf);
   1287  1.2  christos       yysize_overflow |= (yysize1 < yysize);
   1288  1.2  christos       yysize = yysize1;
   1289  1.2  christos 
   1290  1.2  christos       if (yysize_overflow)
   1291  1.1  christos 	return YYSIZE_MAXIMUM;
   1292  1.2  christos 
   1293  1.2  christos       if (yyresult)
   1294  1.2  christos 	{
   1295  1.2  christos 	  /* Avoid sprintf, as that infringes on the user's name space.
   1296  1.2  christos 	     Don't have undefined behavior even if the translation
   1297  1.2  christos 	     produced a string with the wrong number of "%s"s.  */
   1298  1.2  christos 	  char *yyp = yyresult;
   1299  1.2  christos 	  int yyi = 0;
   1300  1.2  christos 	  while ((*yyp = *yyf) != '\0')
   1301  1.2  christos 	    {
   1302  1.2  christos 	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
   1303  1.2  christos 		{
   1304  1.2  christos 		  yyp += yytnamerr (yyp, yyarg[yyi++]);
   1305  1.2  christos 		  yyf += 2;
   1306  1.2  christos 		}
   1307  1.2  christos 	      else
   1308  1.2  christos 		{
   1309  1.2  christos 		  yyp++;
   1310  1.2  christos 		  yyf++;
   1311  1.2  christos 		}
   1312  1.2  christos 	    }
   1313  1.2  christos 	}
   1314  1.1  christos       return yysize;
   1315  1.1  christos     }
   1316  1.2  christos }
   1317  1.2  christos #endif /* YYERROR_VERBOSE */
   1318  1.1  christos 
   1319  1.1  christos 
   1321  1.1  christos /*-----------------------------------------------.
   1322  1.1  christos | Release the memory associated to this symbol.  |
   1323  1.2  christos `-----------------------------------------------*/
   1324  1.2  christos 
   1325  1.2  christos /*ARGSUSED*/
   1326  1.1  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1327  1.2  christos      || defined __cplusplus || defined _MSC_VER)
   1328  1.1  christos static void
   1329  1.1  christos yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parser_control *pc)
   1330  1.2  christos #else
   1331  1.2  christos static void
   1332  1.1  christos yydestruct (yymsg, yytype, yyvaluep, pc)
   1333  1.1  christos     const char *yymsg;
   1334  1.2  christos     int yytype;
   1335  1.1  christos     YYSTYPE *yyvaluep;
   1336  1.1  christos     parser_control *pc;
   1337  1.2  christos #endif
   1338  1.2  christos {
   1339  1.2  christos   YYUSE (yyvaluep);
   1340  1.2  christos   YYUSE (pc);
   1341  1.2  christos 
   1342  1.2  christos   if (!yymsg)
   1343  1.1  christos     yymsg = "Deleting";
   1344  1.1  christos   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
   1345  1.1  christos 
   1346  1.1  christos   switch (yytype)
   1347  1.1  christos     {
   1348  1.2  christos 
   1349  1.1  christos       default:
   1350  1.1  christos 	break;
   1351  1.1  christos     }
   1352  1.1  christos }
   1353  1.1  christos 
   1354  1.2  christos /* Prevent warnings from -Wmissing-prototypes.  */
   1355  1.1  christos #ifdef YYPARSE_PARAM
   1356  1.2  christos #if defined __STDC__ || defined __cplusplus
   1357  1.1  christos int yyparse (void *YYPARSE_PARAM);
   1358  1.2  christos #else
   1359  1.1  christos int yyparse ();
   1360  1.2  christos #endif
   1361  1.2  christos #else /* ! YYPARSE_PARAM */
   1362  1.1  christos #if defined __STDC__ || defined __cplusplus
   1363  1.1  christos int yyparse (parser_control *pc);
   1364  1.1  christos #else
   1365  1.1  christos int yyparse ();
   1366  1.1  christos #endif
   1367  1.1  christos #endif /* ! YYPARSE_PARAM */
   1368  1.1  christos 
   1369  1.1  christos 
   1370  1.1  christos 
   1371  1.2  christos 
   1372  1.2  christos 
   1373  1.2  christos /*-------------------------.
   1374  1.1  christos | yyparse or yypush_parse.  |
   1375  1.1  christos `-------------------------*/
   1376  1.2  christos 
   1377  1.2  christos #ifdef YYPARSE_PARAM
   1378  1.2  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1379  1.2  christos      || defined __cplusplus || defined _MSC_VER)
   1380  1.2  christos int
   1381  1.2  christos yyparse (void *YYPARSE_PARAM)
   1382  1.2  christos #else
   1383  1.2  christos int
   1384  1.2  christos yyparse (YYPARSE_PARAM)
   1385  1.1  christos     void *YYPARSE_PARAM;
   1386  1.2  christos #endif
   1387  1.2  christos #else /* ! YYPARSE_PARAM */
   1388  1.1  christos #if (defined __STDC__ || defined __C99__FUNC__ \
   1389  1.2  christos      || defined __cplusplus || defined _MSC_VER)
   1390  1.1  christos int
   1391  1.1  christos yyparse (parser_control *pc)
   1392  1.1  christos #else
   1393  1.2  christos int
   1394  1.1  christos yyparse (pc)
   1395  1.1  christos     parser_control *pc;
   1396  1.1  christos #endif
   1397  1.2  christos #endif
   1398  1.1  christos {
   1399  1.1  christos /* The lookahead symbol.  */
   1400  1.1  christos int yychar;
   1401  1.1  christos 
   1402  1.1  christos /* The semantic value of the lookahead symbol.  */
   1403  1.2  christos YYSTYPE yylval;
   1404  1.2  christos 
   1405  1.1  christos     /* Number of syntax errors so far.  */
   1406  1.2  christos     int yynerrs;
   1407  1.2  christos 
   1408  1.2  christos     int yystate;
   1409  1.1  christos     /* Number of tokens to shift before error messages enabled.  */
   1410  1.2  christos     int yyerrstatus;
   1411  1.2  christos 
   1412  1.2  christos     /* The stacks and their tools:
   1413  1.1  christos        `yyss': related to states.
   1414  1.2  christos        `yyvs': related to semantic values.
   1415  1.2  christos 
   1416  1.1  christos        Refer to the stacks thru separate pointers, to allow yyoverflow
   1417  1.2  christos        to reallocate them elsewhere.  */
   1418  1.2  christos 
   1419  1.2  christos     /* The state stack.  */
   1420  1.2  christos     yytype_int16 yyssa[YYINITDEPTH];
   1421  1.1  christos     yytype_int16 *yyss;
   1422  1.2  christos     yytype_int16 *yyssp;
   1423  1.2  christos 
   1424  1.2  christos     /* The semantic value stack.  */
   1425  1.2  christos     YYSTYPE yyvsa[YYINITDEPTH];
   1426  1.1  christos     YYSTYPE *yyvs;
   1427  1.2  christos     YYSTYPE *yyvsp;
   1428  1.1  christos 
   1429  1.2  christos     YYSIZE_T yystacksize;
   1430  1.2  christos 
   1431  1.2  christos   int yyn;
   1432  1.2  christos   int yyresult;
   1433  1.1  christos   /* Lookahead token as an internal (translated) token number.  */
   1434  1.1  christos   int yytoken;
   1435  1.1  christos   /* The variables used to return semantic value and location from the
   1436  1.1  christos      action routines.  */
   1437  1.2  christos   YYSTYPE yyval;
   1438  1.2  christos 
   1439  1.2  christos #if YYERROR_VERBOSE
   1440  1.2  christos   /* Buffer for error messages, and its allocated size.  */
   1441  1.2  christos   char yymsgbuf[128];
   1442  1.2  christos   char *yymsg = yymsgbuf;
   1443  1.2  christos   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
   1444  1.2  christos #endif
   1445  1.2  christos 
   1446  1.2  christos #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
   1447  1.2  christos 
   1448  1.2  christos   /* The number of symbols on the RHS of the reduced rule.
   1449  1.2  christos      Keep to zero when no symbol should be popped.  */
   1450  1.2  christos   int yylen = 0;
   1451  1.2  christos 
   1452  1.2  christos   yytoken = 0;
   1453  1.2  christos   yyss = yyssa;
   1454  1.1  christos   yyvs = yyvsa;
   1455  1.1  christos   yystacksize = YYINITDEPTH;
   1456  1.1  christos 
   1457  1.1  christos   YYDPRINTF ((stderr, "Starting parse\n"));
   1458  1.1  christos 
   1459  1.1  christos   yystate = 0;
   1460  1.2  christos   yyerrstatus = 0;
   1461  1.1  christos   yynerrs = 0;
   1462  1.1  christos   yychar = YYEMPTY; /* Cause a token to be read.  */
   1463  1.1  christos 
   1464  1.1  christos   /* Initialize stack pointers.
   1465  1.1  christos      Waste one element of value and location stack
   1466  1.1  christos      so that they stay on the same level as the state stack.
   1467  1.1  christos      The wasted elements are never initialized.  */
   1468  1.1  christos   yyssp = yyss;
   1469  1.1  christos   yyvsp = yyvs;
   1470  1.1  christos 
   1471  1.1  christos   goto yysetstate;
   1472  1.1  christos 
   1473  1.1  christos /*------------------------------------------------------------.
   1474  1.1  christos | yynewstate -- Push a new state, which is found in yystate.  |
   1475  1.1  christos `------------------------------------------------------------*/
   1476  1.2  christos  yynewstate:
   1477  1.1  christos   /* In all cases, when you get here, the value and location stacks
   1478  1.1  christos      have just been pushed.  So pushing a state here evens the stacks.  */
   1479  1.1  christos   yyssp++;
   1480  1.1  christos 
   1481  1.1  christos  yysetstate:
   1482  1.1  christos   *yyssp = yystate;
   1483  1.1  christos 
   1484  1.1  christos   if (yyss + yystacksize - 1 <= yyssp)
   1485  1.1  christos     {
   1486  1.1  christos       /* Get the current used size of the three stacks, in elements.  */
   1487  1.1  christos       YYSIZE_T yysize = yyssp - yyss + 1;
   1488  1.1  christos 
   1489  1.2  christos #ifdef yyoverflow
   1490  1.1  christos       {
   1491  1.1  christos 	/* Give user a chance to reallocate the stack.  Use copies of
   1492  1.1  christos 	   these so that the &'s don't force the real ones into
   1493  1.2  christos 	   memory.  */
   1494  1.1  christos 	YYSTYPE *yyvs1 = yyvs;
   1495  1.1  christos 	yytype_int16 *yyss1 = yyss;
   1496  1.1  christos 
   1497  1.1  christos 	/* Each stack pointer address is followed by the size of the
   1498  1.1  christos 	   data in use in that stack, in bytes.  This used to be a
   1499  1.2  christos 	   conditional around just the two extra args, but that might
   1500  1.1  christos 	   be undefined if yyoverflow is a macro.  */
   1501  1.1  christos 	yyoverflow (YY_("memory exhausted"),
   1502  1.1  christos 		    &yyss1, yysize * sizeof (*yyssp),
   1503  1.1  christos 		    &yyvs1, yysize * sizeof (*yyvsp),
   1504  1.1  christos 		    &yystacksize);
   1505  1.1  christos 
   1506  1.1  christos 	yyss = yyss1;
   1507  1.1  christos 	yyvs = yyvs1;
   1508  1.1  christos       }
   1509  1.2  christos #else /* no yyoverflow */
   1510  1.1  christos # ifndef YYSTACK_RELOCATE
   1511  1.1  christos       goto yyexhaustedlab;
   1512  1.1  christos # else
   1513  1.2  christos       /* Extend the stack our own way.  */
   1514  1.1  christos       if (YYMAXDEPTH <= yystacksize)
   1515  1.1  christos 	goto yyexhaustedlab;
   1516  1.1  christos       yystacksize *= 2;
   1517  1.1  christos       if (YYMAXDEPTH < yystacksize)
   1518  1.1  christos 	yystacksize = YYMAXDEPTH;
   1519  1.2  christos 
   1520  1.1  christos       {
   1521  1.1  christos 	yytype_int16 *yyss1 = yyss;
   1522  1.1  christos 	union yyalloc *yyptr =
   1523  1.2  christos 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
   1524  1.2  christos 	if (! yyptr)
   1525  1.2  christos 	  goto yyexhaustedlab;
   1526  1.1  christos 	YYSTACK_RELOCATE (yyss_alloc, yyss);
   1527  1.1  christos 	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
   1528  1.1  christos #  undef YYSTACK_RELOCATE
   1529  1.1  christos 	if (yyss1 != yyssa)
   1530  1.1  christos 	  YYSTACK_FREE (yyss1);
   1531  1.1  christos       }
   1532  1.1  christos # endif
   1533  1.1  christos #endif /* no yyoverflow */
   1534  1.1  christos 
   1535  1.1  christos       yyssp = yyss + yysize - 1;
   1536  1.1  christos       yyvsp = yyvs + yysize - 1;
   1537  1.1  christos 
   1538  1.1  christos       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
   1539  1.1  christos 		  (unsigned long int) yystacksize));
   1540  1.1  christos 
   1541  1.1  christos       if (yyss + yystacksize - 1 <= yyssp)
   1542  1.1  christos 	YYABORT;
   1543  1.1  christos     }
   1544  1.1  christos 
   1545  1.2  christos   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
   1546  1.2  christos 
   1547  1.2  christos   if (yystate == YYFINAL)
   1548  1.1  christos     YYACCEPT;
   1549  1.1  christos 
   1550  1.1  christos   goto yybackup;
   1551  1.1  christos 
   1552  1.1  christos /*-----------.
   1553  1.1  christos | yybackup.  |
   1554  1.1  christos `-----------*/
   1555  1.2  christos yybackup:
   1556  1.2  christos 
   1557  1.1  christos   /* Do appropriate processing given the current state.  Read a
   1558  1.1  christos      lookahead token if we need one and don't already have one.  */
   1559  1.1  christos 
   1560  1.1  christos   /* First try to decide what to do without reference to lookahead token.  */
   1561  1.1  christos   yyn = yypact[yystate];
   1562  1.1  christos   if (yyn == YYPACT_NINF)
   1563  1.1  christos     goto yydefault;
   1564  1.1  christos 
   1565  1.1  christos   /* Not known => get a lookahead token if don't already have one.  */
   1566  1.1  christos 
   1567  1.1  christos   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
   1568  1.1  christos   if (yychar == YYEMPTY)
   1569  1.1  christos     {
   1570  1.1  christos       YYDPRINTF ((stderr, "Reading a token: "));
   1571  1.1  christos       yychar = YYLEX;
   1572  1.1  christos     }
   1573  1.1  christos 
   1574  1.1  christos   if (yychar <= YYEOF)
   1575  1.1  christos     {
   1576  1.1  christos       yychar = yytoken = YYEOF;
   1577  1.1  christos       YYDPRINTF ((stderr, "Now at end of input.\n"));
   1578  1.1  christos     }
   1579  1.1  christos   else
   1580  1.2  christos     {
   1581  1.1  christos       yytoken = YYTRANSLATE (yychar);
   1582  1.1  christos       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
   1583  1.1  christos     }
   1584  1.1  christos 
   1585  1.1  christos   /* If the proper action on seeing token YYTOKEN is to reduce or to
   1586  1.1  christos      detect an error, take that action.  */
   1587  1.1  christos   yyn += yytoken;
   1588  1.1  christos   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
   1589  1.1  christos     goto yydefault;
   1590  1.1  christos   yyn = yytable[yyn];
   1591  1.1  christos   if (yyn <= 0)
   1592  1.1  christos     {
   1593  1.1  christos       if (yyn == 0 || yyn == YYTABLE_NINF)
   1594  1.1  christos 	goto yyerrlab;
   1595  1.1  christos       yyn = -yyn;
   1596  1.1  christos       goto yyreduce;
   1597  1.2  christos     }
   1598  1.2  christos 
   1599  1.2  christos   /* Count tokens shifted since error; after three, turn off error
   1600  1.2  christos      status.  */
   1601  1.1  christos   if (yyerrstatus)
   1602  1.1  christos     yyerrstatus--;
   1603  1.2  christos 
   1604  1.1  christos   /* Shift the lookahead token.  */
   1605  1.2  christos   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
   1606  1.2  christos 
   1607  1.1  christos   /* Discard the shifted token.  */
   1608  1.2  christos   yychar = YYEMPTY;
   1609  1.1  christos 
   1610  1.1  christos   yystate = yyn;
   1611  1.1  christos   *++yyvsp = yylval;
   1612  1.1  christos 
   1613  1.1  christos   goto yynewstate;
   1614  1.1  christos 
   1615  1.1  christos 
   1616  1.1  christos /*-----------------------------------------------------------.
   1617  1.1  christos | yydefault -- do the default action for the current state.  |
   1618  1.1  christos `-----------------------------------------------------------*/
   1619  1.1  christos yydefault:
   1620  1.1  christos   yyn = yydefact[yystate];
   1621  1.1  christos   if (yyn == 0)
   1622  1.1  christos     goto yyerrlab;
   1623  1.1  christos   goto yyreduce;
   1624  1.1  christos 
   1625  1.1  christos 
   1626  1.1  christos /*-----------------------------.
   1627  1.1  christos | yyreduce -- Do a reduction.  |
   1628  1.1  christos `-----------------------------*/
   1629  1.1  christos yyreduce:
   1630  1.1  christos   /* yyn is the number of a rule to reduce with.  */
   1631  1.1  christos   yylen = yyr2[yyn];
   1632  1.1  christos 
   1633  1.1  christos   /* If YYLEN is nonzero, implement the default value of the action:
   1634  1.1  christos      `$$ = $1'.
   1635  1.1  christos 
   1636  1.1  christos      Otherwise, the following line sets YYVAL to garbage.
   1637  1.1  christos      This behavior is undocumented and Bison
   1638  1.1  christos      users should not rely upon it.  Assigning to YYVAL
   1639  1.1  christos      unconditionally makes the parser a bit smaller, and it avoids a
   1640  1.1  christos      GCC warning that YYVAL may be used uninitialized.  */
   1641  1.1  christos   yyval = yyvsp[1-yylen];
   1642  1.1  christos 
   1643  1.1  christos 
   1644  1.1  christos   YY_REDUCE_PRINT (yyn);
   1645  1.1  christos   switch (yyn)
   1646  1.2  christos     {
   1647  1.2  christos         case 4:
   1648  1.2  christos 
   1649  1.1  christos /* Line 1455 of yacc.c  */
   1650  1.2  christos #line 236 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1651  1.1  christos     {
   1652  1.2  christos 	pc->seconds = (yyvsp[(2) - (2)].timespec);
   1653  1.1  christos 	pc->timespec_seen = true;
   1654  1.1  christos       ;}
   1655  1.1  christos     break;
   1656  1.2  christos 
   1657  1.2  christos   case 7:
   1658  1.2  christos 
   1659  1.2  christos /* Line 1455 of yacc.c  */
   1660  1.1  christos #line 249 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1661  1.1  christos     { pc->times_seen++; ;}
   1662  1.1  christos     break;
   1663  1.2  christos 
   1664  1.2  christos   case 8:
   1665  1.2  christos 
   1666  1.2  christos /* Line 1455 of yacc.c  */
   1667  1.1  christos #line 251 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1668  1.1  christos     { pc->local_zones_seen++; ;}
   1669  1.1  christos     break;
   1670  1.2  christos 
   1671  1.2  christos   case 9:
   1672  1.2  christos 
   1673  1.2  christos /* Line 1455 of yacc.c  */
   1674  1.1  christos #line 253 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1675  1.1  christos     { pc->zones_seen++; ;}
   1676  1.1  christos     break;
   1677  1.2  christos 
   1678  1.2  christos   case 10:
   1679  1.2  christos 
   1680  1.2  christos /* Line 1455 of yacc.c  */
   1681  1.1  christos #line 255 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1682  1.1  christos     { pc->dates_seen++; ;}
   1683  1.1  christos     break;
   1684  1.2  christos 
   1685  1.2  christos   case 11:
   1686  1.2  christos 
   1687  1.2  christos /* Line 1455 of yacc.c  */
   1688  1.1  christos #line 257 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1689  1.1  christos     { pc->days_seen++; ;}
   1690  1.1  christos     break;
   1691  1.2  christos 
   1692  1.2  christos   case 12:
   1693  1.2  christos 
   1694  1.2  christos /* Line 1455 of yacc.c  */
   1695  1.1  christos #line 259 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1696  1.1  christos     { pc->rels_seen = true; ;}
   1697  1.2  christos     break;
   1698  1.2  christos 
   1699  1.2  christos   case 13:
   1700  1.2  christos 
   1701  1.1  christos /* Line 1455 of yacc.c  */
   1702  1.2  christos #line 261 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1703  1.2  christos     {
   1704  1.2  christos         pc->dates_seen++;
   1705  1.2  christos         pc->zones_seen++;
   1706  1.1  christos         pc->times_seen++;
   1707  1.1  christos       ;}
   1708  1.1  christos     break;
   1709  1.2  christos 
   1710  1.2  christos   case 15:
   1711  1.2  christos 
   1712  1.1  christos /* Line 1455 of yacc.c  */
   1713  1.2  christos #line 270 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1714  1.2  christos     {
   1715  1.2  christos     int i;
   1716  1.2  christos     pc->year.negative = 0;
   1717  1.2  christos     pc->year.value = (yyvsp[(1) - (5)].timespec).tv_sec;
   1718  1.2  christos 
   1719  1.2  christos     if (pc->year.value < 70)
   1720  1.2  christos       pc->year.value += 2000;
   1721  1.2  christos     else if (pc->year.value < 100)
   1722  1.2  christos       pc->year.value += 1900;
   1723  1.2  christos 
   1724  1.2  christos     for (i = pc->year.value, pc->year.digits = 0; i; i /= 10, pc->year.digits++)
   1725  1.2  christos       continue;
   1726  1.2  christos     if (pc->year.digits == 0)
   1727  1.2  christos       pc->year.digits++;
   1728  1.2  christos 
   1729  1.2  christos     pc->month = (yyvsp[(1) - (5)].timespec).tv_nsec / 10000000;
   1730  1.2  christos     pc->day = (yyvsp[(3) - (5)].timespec).tv_sec;
   1731  1.2  christos     pc->hour = (yyvsp[(3) - (5)].timespec).tv_nsec / 10000000;
   1732  1.2  christos     pc->minutes = (yyvsp[(5) - (5)].timespec).tv_sec;
   1733  1.2  christos     pc->seconds.tv_sec = (yyvsp[(5) - (5)].timespec).tv_nsec / 10000000;
   1734  1.2  christos     pc->seconds.tv_nsec = 0;
   1735  1.2  christos     pc->meridian = MER24;
   1736  1.1  christos     pc->time_zone = 0;
   1737  1.1  christos   ;}
   1738  1.1  christos     break;
   1739  1.2  christos 
   1740  1.2  christos   case 16:
   1741  1.2  christos 
   1742  1.1  christos /* Line 1455 of yacc.c  */
   1743  1.2  christos #line 297 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1744  1.2  christos     {
   1745  1.1  christos 	pc->hour = (yyvsp[(1) - (2)].textintval).value;
   1746  1.1  christos 	pc->minutes = 0;
   1747  1.2  christos 	pc->seconds.tv_sec = 0;
   1748  1.2  christos 	pc->seconds.tv_nsec = 0;
   1749  1.1  christos 	pc->meridian = (yyvsp[(2) - (2)].intval);
   1750  1.1  christos       ;}
   1751  1.1  christos     break;
   1752  1.2  christos 
   1753  1.2  christos   case 17:
   1754  1.2  christos 
   1755  1.1  christos /* Line 1455 of yacc.c  */
   1756  1.2  christos #line 305 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1757  1.2  christos     {
   1758  1.2  christos 	pc->hour = (yyvsp[(1) - (4)].textintval).value;
   1759  1.2  christos 	pc->minutes = (yyvsp[(3) - (4)].textintval).value;
   1760  1.2  christos 	pc->seconds.tv_sec = 0;
   1761  1.2  christos 	pc->seconds.tv_nsec = 0;
   1762  1.1  christos 	pc->meridian = (yyvsp[(4) - (4)].intval);
   1763  1.1  christos       ;}
   1764  1.1  christos     break;
   1765  1.2  christos 
   1766  1.2  christos   case 18:
   1767  1.2  christos 
   1768  1.1  christos /* Line 1455 of yacc.c  */
   1769  1.2  christos #line 313 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1770  1.2  christos     {
   1771  1.2  christos 	pc->hour = (yyvsp[(1) - (5)].textintval).value;
   1772  1.2  christos 	pc->minutes = (yyvsp[(3) - (5)].textintval).value;
   1773  1.1  christos 	pc->seconds.tv_sec = 0;
   1774  1.1  christos 	pc->seconds.tv_nsec = 0;
   1775  1.2  christos 	pc->meridian = MER24;
   1776  1.2  christos 	pc->zones_seen++;
   1777  1.1  christos 	pc->time_zone = time_zone_hhmm ((yyvsp[(4) - (5)].textintval), (yyvsp[(5) - (5)].intval));
   1778  1.1  christos       ;}
   1779  1.1  christos     break;
   1780  1.2  christos 
   1781  1.2  christos   case 19:
   1782  1.2  christos 
   1783  1.1  christos /* Line 1455 of yacc.c  */
   1784  1.2  christos #line 323 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1785  1.2  christos     {
   1786  1.2  christos 	pc->hour = (yyvsp[(1) - (6)].textintval).value;
   1787  1.2  christos 	pc->minutes = (yyvsp[(3) - (6)].textintval).value;
   1788  1.2  christos 	pc->seconds = (yyvsp[(5) - (6)].timespec);
   1789  1.1  christos 	pc->meridian = (yyvsp[(6) - (6)].intval);
   1790  1.1  christos       ;}
   1791  1.1  christos     break;
   1792  1.2  christos 
   1793  1.2  christos   case 20:
   1794  1.2  christos 
   1795  1.1  christos /* Line 1455 of yacc.c  */
   1796  1.2  christos #line 330 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1797  1.2  christos     {
   1798  1.2  christos 	pc->hour = (yyvsp[(1) - (7)].textintval).value;
   1799  1.2  christos 	pc->minutes = (yyvsp[(3) - (7)].textintval).value;
   1800  1.2  christos 	pc->seconds = (yyvsp[(5) - (7)].timespec);
   1801  1.2  christos 	pc->meridian = MER24;
   1802  1.2  christos 	pc->zones_seen++;
   1803  1.1  christos 	pc->time_zone = time_zone_hhmm ((yyvsp[(6) - (7)].textintval), (yyvsp[(7) - (7)].intval));
   1804  1.1  christos       ;}
   1805  1.1  christos     break;
   1806  1.2  christos 
   1807  1.2  christos   case 21:
   1808  1.2  christos 
   1809  1.2  christos /* Line 1455 of yacc.c  */
   1810  1.2  christos #line 342 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1811  1.2  christos     {
   1812  1.2  christos 	pc->local_isdst = (yyvsp[(1) - (1)].intval);
   1813  1.1  christos 	pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval));
   1814  1.1  christos       ;}
   1815  1.1  christos     break;
   1816  1.2  christos 
   1817  1.2  christos   case 22:
   1818  1.2  christos 
   1819  1.2  christos /* Line 1455 of yacc.c  */
   1820  1.2  christos #line 347 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1821  1.2  christos     {
   1822  1.2  christos 	pc->local_isdst = 1;
   1823  1.1  christos 	pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1;
   1824  1.1  christos       ;}
   1825  1.1  christos     break;
   1826  1.2  christos 
   1827  1.2  christos   case 23:
   1828  1.2  christos 
   1829  1.2  christos /* Line 1455 of yacc.c  */
   1830  1.1  christos #line 355 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1831  1.1  christos     { pc->time_zone = (yyvsp[(1) - (1)].intval); ;}
   1832  1.1  christos     break;
   1833  1.2  christos 
   1834  1.2  christos   case 24:
   1835  1.2  christos 
   1836  1.2  christos /* Line 1455 of yacc.c  */
   1837  1.1  christos #line 357 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1838  1.1  christos     { pc->time_zone = (yyvsp[(1) - (2)].intval); pc->rels_seen = true; ;}
   1839  1.1  christos     break;
   1840  1.2  christos 
   1841  1.2  christos   case 25:
   1842  1.2  christos 
   1843  1.2  christos /* Line 1455 of yacc.c  */
   1844  1.1  christos #line 359 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1845  1.1  christos     { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm ((yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); ;}
   1846  1.1  christos     break;
   1847  1.2  christos 
   1848  1.2  christos   case 26:
   1849  1.2  christos 
   1850  1.2  christos /* Line 1455 of yacc.c  */
   1851  1.1  christos #line 361 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1852  1.1  christos     { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; ;}
   1853  1.1  christos     break;
   1854  1.2  christos 
   1855  1.2  christos   case 27:
   1856  1.2  christos 
   1857  1.2  christos /* Line 1455 of yacc.c  */
   1858  1.1  christos #line 363 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1859  1.1  christos     { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; ;}
   1860  1.1  christos     break;
   1861  1.2  christos 
   1862  1.2  christos   case 28:
   1863  1.2  christos 
   1864  1.1  christos /* Line 1455 of yacc.c  */
   1865  1.2  christos #line 368 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1866  1.2  christos     {
   1867  1.2  christos 	pc->day_ordinal = 1;
   1868  1.1  christos 	pc->day_number = (yyvsp[(1) - (1)].intval);
   1869  1.1  christos       ;}
   1870  1.1  christos     break;
   1871  1.2  christos 
   1872  1.2  christos   case 29:
   1873  1.2  christos 
   1874  1.1  christos /* Line 1455 of yacc.c  */
   1875  1.2  christos #line 373 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1876  1.2  christos     {
   1877  1.2  christos 	pc->day_ordinal = 1;
   1878  1.1  christos 	pc->day_number = (yyvsp[(1) - (2)].intval);
   1879  1.1  christos       ;}
   1880  1.1  christos     break;
   1881  1.2  christos 
   1882  1.2  christos   case 30:
   1883  1.2  christos 
   1884  1.1  christos /* Line 1455 of yacc.c  */
   1885  1.2  christos #line 378 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1886  1.2  christos     {
   1887  1.2  christos 	pc->day_ordinal = (yyvsp[(1) - (2)].intval);
   1888  1.1  christos 	pc->day_number = (yyvsp[(2) - (2)].intval);
   1889  1.1  christos       ;}
   1890  1.1  christos     break;
   1891  1.2  christos 
   1892  1.2  christos   case 31:
   1893  1.2  christos 
   1894  1.2  christos /* Line 1455 of yacc.c  */
   1895  1.2  christos #line 383 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1896  1.2  christos     {
   1897  1.2  christos 	pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value;
   1898  1.2  christos 	pc->day_number = (yyvsp[(2) - (2)].intval);
   1899  1.2  christos       ;}
   1900  1.2  christos     break;
   1901  1.2  christos 
   1902  1.2  christos   case 32:
   1903  1.2  christos 
   1904  1.2  christos /* Line 1455 of yacc.c  */
   1905  1.2  christos #line 391 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1906  1.2  christos     {
   1907  1.2  christos 	pc->month = (yyvsp[(1) - (3)].textintval).value;
   1908  1.2  christos 	pc->day = (yyvsp[(3) - (3)].textintval).value;
   1909  1.2  christos       ;}
   1910  1.2  christos     break;
   1911  1.2  christos 
   1912  1.2  christos   case 33:
   1913  1.2  christos 
   1914  1.1  christos /* Line 1455 of yacc.c  */
   1915  1.1  christos #line 396 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1916  1.1  christos     {
   1917  1.1  christos 	/* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
   1918  1.1  christos 	   otherwise as MM/DD/YY.
   1919  1.1  christos 	   The goal in recognizing YYYY/MM/DD is solely to support legacy
   1920  1.2  christos 	   machine-generated dates like those in an RCS log listing.  If
   1921  1.1  christos 	   you want portability, use the ISO 8601 format.  */
   1922  1.2  christos 	if (4 <= (yyvsp[(1) - (5)].textintval).digits)
   1923  1.2  christos 	  {
   1924  1.2  christos 	    pc->year = (yyvsp[(1) - (5)].textintval);
   1925  1.1  christos 	    pc->month = (yyvsp[(3) - (5)].textintval).value;
   1926  1.1  christos 	    pc->day = (yyvsp[(5) - (5)].textintval).value;
   1927  1.1  christos 	  }
   1928  1.2  christos 	else
   1929  1.2  christos 	  {
   1930  1.2  christos 	    pc->month = (yyvsp[(1) - (5)].textintval).value;
   1931  1.1  christos 	    pc->day = (yyvsp[(3) - (5)].textintval).value;
   1932  1.2  christos 	    pc->year = (yyvsp[(5) - (5)].textintval);
   1933  1.1  christos 	  }
   1934  1.1  christos       ;}
   1935  1.2  christos     break;
   1936  1.2  christos 
   1937  1.2  christos   case 34:
   1938  1.2  christos 
   1939  1.1  christos /* Line 1455 of yacc.c  */
   1940  1.1  christos #line 416 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1941  1.2  christos     {
   1942  1.2  christos 	/* ISO 8601 format.  YYYY-MM-DD.  */
   1943  1.2  christos 	pc->year = (yyvsp[(1) - (3)].textintval);
   1944  1.2  christos 	pc->month = -(yyvsp[(2) - (3)].textintval).value;
   1945  1.1  christos 	pc->day = -(yyvsp[(3) - (3)].textintval).value;
   1946  1.1  christos       ;}
   1947  1.2  christos     break;
   1948  1.2  christos 
   1949  1.2  christos   case 35:
   1950  1.2  christos 
   1951  1.1  christos /* Line 1455 of yacc.c  */
   1952  1.1  christos #line 423 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1953  1.2  christos     {
   1954  1.2  christos 	/* e.g. 17-JUN-1992.  */
   1955  1.2  christos 	pc->day = (yyvsp[(1) - (3)].textintval).value;
   1956  1.2  christos 	pc->month = (yyvsp[(2) - (3)].intval);
   1957  1.2  christos 	pc->year.value = -(yyvsp[(3) - (3)].textintval).value;
   1958  1.1  christos 	pc->year.digits = (yyvsp[(3) - (3)].textintval).digits;
   1959  1.1  christos       ;}
   1960  1.2  christos     break;
   1961  1.2  christos 
   1962  1.2  christos   case 36:
   1963  1.2  christos 
   1964  1.1  christos /* Line 1455 of yacc.c  */
   1965  1.1  christos #line 431 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1966  1.2  christos     {
   1967  1.2  christos 	/* e.g. JUN-17-1992.  */
   1968  1.2  christos 	pc->month = (yyvsp[(1) - (3)].intval);
   1969  1.2  christos 	pc->day = -(yyvsp[(2) - (3)].textintval).value;
   1970  1.2  christos 	pc->year.value = -(yyvsp[(3) - (3)].textintval).value;
   1971  1.1  christos 	pc->year.digits = (yyvsp[(3) - (3)].textintval).digits;
   1972  1.1  christos       ;}
   1973  1.2  christos     break;
   1974  1.2  christos 
   1975  1.2  christos   case 37:
   1976  1.2  christos 
   1977  1.1  christos /* Line 1455 of yacc.c  */
   1978  1.2  christos #line 439 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1979  1.2  christos     {
   1980  1.2  christos 	pc->month = (yyvsp[(1) - (2)].intval);
   1981  1.1  christos 	pc->day = (yyvsp[(2) - (2)].textintval).value;
   1982  1.1  christos       ;}
   1983  1.2  christos     break;
   1984  1.2  christos 
   1985  1.2  christos   case 38:
   1986  1.2  christos 
   1987  1.1  christos /* Line 1455 of yacc.c  */
   1988  1.2  christos #line 444 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   1989  1.2  christos     {
   1990  1.2  christos 	pc->month = (yyvsp[(1) - (4)].intval);
   1991  1.2  christos 	pc->day = (yyvsp[(2) - (4)].textintval).value;
   1992  1.1  christos 	pc->year = (yyvsp[(4) - (4)].textintval);
   1993  1.1  christos       ;}
   1994  1.2  christos     break;
   1995  1.2  christos 
   1996  1.2  christos   case 39:
   1997  1.2  christos 
   1998  1.1  christos /* Line 1455 of yacc.c  */
   1999  1.2  christos #line 450 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2000  1.2  christos     {
   2001  1.2  christos 	pc->day = (yyvsp[(1) - (2)].textintval).value;
   2002  1.1  christos 	pc->month = (yyvsp[(2) - (2)].intval);
   2003  1.1  christos       ;}
   2004  1.2  christos     break;
   2005  1.2  christos 
   2006  1.2  christos   case 40:
   2007  1.2  christos 
   2008  1.1  christos /* Line 1455 of yacc.c  */
   2009  1.2  christos #line 455 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2010  1.2  christos     {
   2011  1.2  christos 	pc->day = (yyvsp[(1) - (3)].textintval).value;
   2012  1.2  christos 	pc->month = (yyvsp[(2) - (3)].intval);
   2013  1.1  christos 	pc->year = (yyvsp[(3) - (3)].textintval);
   2014  1.1  christos       ;}
   2015  1.2  christos     break;
   2016  1.2  christos 
   2017  1.2  christos   case 41:
   2018  1.2  christos 
   2019  1.1  christos /* Line 1455 of yacc.c  */
   2020  1.1  christos #line 464 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2021  1.1  christos     {
   2022  1.1  christos 	pc->rel_ns = -pc->rel_ns;
   2023  1.1  christos 	pc->rel_seconds = -pc->rel_seconds;
   2024  1.1  christos 	pc->rel_minutes = -pc->rel_minutes;
   2025  1.1  christos 	pc->rel_hour = -pc->rel_hour;
   2026  1.1  christos 	pc->rel_day = -pc->rel_day;
   2027  1.2  christos 	pc->rel_month = -pc->rel_month;
   2028  1.1  christos 	pc->rel_year = -pc->rel_year;
   2029  1.1  christos       ;}
   2030  1.2  christos     break;
   2031  1.1  christos 
   2032  1.2  christos   case 43:
   2033  1.2  christos 
   2034  1.2  christos /* Line 1455 of yacc.c  */
   2035  1.1  christos #line 478 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2036  1.1  christos     { pc->rel_year += (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); ;}
   2037  1.2  christos     break;
   2038  1.1  christos 
   2039  1.2  christos   case 44:
   2040  1.2  christos 
   2041  1.2  christos /* Line 1455 of yacc.c  */
   2042  1.1  christos #line 480 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2043  1.1  christos     { pc->rel_year += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2044  1.1  christos     break;
   2045  1.2  christos 
   2046  1.2  christos   case 45:
   2047  1.2  christos 
   2048  1.2  christos /* Line 1455 of yacc.c  */
   2049  1.1  christos #line 482 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2050  1.1  christos     { pc->rel_year += (yyvsp[(1) - (1)].intval); ;}
   2051  1.1  christos     break;
   2052  1.2  christos 
   2053  1.2  christos   case 46:
   2054  1.2  christos 
   2055  1.2  christos /* Line 1455 of yacc.c  */
   2056  1.1  christos #line 484 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2057  1.1  christos     { pc->rel_month += (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); ;}
   2058  1.1  christos     break;
   2059  1.2  christos 
   2060  1.2  christos   case 47:
   2061  1.2  christos 
   2062  1.2  christos /* Line 1455 of yacc.c  */
   2063  1.1  christos #line 486 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2064  1.1  christos     { pc->rel_month += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2065  1.1  christos     break;
   2066  1.2  christos 
   2067  1.2  christos   case 48:
   2068  1.2  christos 
   2069  1.2  christos /* Line 1455 of yacc.c  */
   2070  1.1  christos #line 488 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2071  1.1  christos     { pc->rel_month += (yyvsp[(1) - (1)].intval); ;}
   2072  1.1  christos     break;
   2073  1.2  christos 
   2074  1.2  christos   case 49:
   2075  1.2  christos 
   2076  1.2  christos /* Line 1455 of yacc.c  */
   2077  1.1  christos #line 490 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2078  1.1  christos     { pc->rel_day += (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); ;}
   2079  1.1  christos     break;
   2080  1.2  christos 
   2081  1.2  christos   case 50:
   2082  1.2  christos 
   2083  1.2  christos /* Line 1455 of yacc.c  */
   2084  1.1  christos #line 492 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2085  1.1  christos     { pc->rel_day += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2086  1.1  christos     break;
   2087  1.2  christos 
   2088  1.2  christos   case 51:
   2089  1.2  christos 
   2090  1.2  christos /* Line 1455 of yacc.c  */
   2091  1.1  christos #line 494 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2092  1.1  christos     { pc->rel_day += (yyvsp[(1) - (1)].intval); ;}
   2093  1.1  christos     break;
   2094  1.2  christos 
   2095  1.2  christos   case 52:
   2096  1.2  christos 
   2097  1.2  christos /* Line 1455 of yacc.c  */
   2098  1.1  christos #line 496 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2099  1.1  christos     { pc->rel_hour += (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); ;}
   2100  1.1  christos     break;
   2101  1.2  christos 
   2102  1.2  christos   case 53:
   2103  1.2  christos 
   2104  1.2  christos /* Line 1455 of yacc.c  */
   2105  1.1  christos #line 498 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2106  1.1  christos     { pc->rel_hour += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2107  1.1  christos     break;
   2108  1.2  christos 
   2109  1.2  christos   case 54:
   2110  1.2  christos 
   2111  1.2  christos /* Line 1455 of yacc.c  */
   2112  1.1  christos #line 500 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2113  1.1  christos     { pc->rel_hour += (yyvsp[(1) - (1)].intval); ;}
   2114  1.1  christos     break;
   2115  1.2  christos 
   2116  1.2  christos   case 55:
   2117  1.2  christos 
   2118  1.2  christos /* Line 1455 of yacc.c  */
   2119  1.1  christos #line 502 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2120  1.1  christos     { pc->rel_minutes += (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); ;}
   2121  1.1  christos     break;
   2122  1.2  christos 
   2123  1.2  christos   case 56:
   2124  1.2  christos 
   2125  1.2  christos /* Line 1455 of yacc.c  */
   2126  1.1  christos #line 504 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2127  1.1  christos     { pc->rel_minutes += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2128  1.1  christos     break;
   2129  1.2  christos 
   2130  1.2  christos   case 57:
   2131  1.2  christos 
   2132  1.2  christos /* Line 1455 of yacc.c  */
   2133  1.1  christos #line 506 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2134  1.1  christos     { pc->rel_minutes += (yyvsp[(1) - (1)].intval); ;}
   2135  1.1  christos     break;
   2136  1.2  christos 
   2137  1.2  christos   case 58:
   2138  1.2  christos 
   2139  1.2  christos /* Line 1455 of yacc.c  */
   2140  1.1  christos #line 508 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2141  1.1  christos     { pc->rel_seconds += (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); ;}
   2142  1.1  christos     break;
   2143  1.2  christos 
   2144  1.2  christos   case 59:
   2145  1.2  christos 
   2146  1.2  christos /* Line 1455 of yacc.c  */
   2147  1.1  christos #line 510 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2148  1.1  christos     { pc->rel_seconds += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2149  1.1  christos     break;
   2150  1.2  christos 
   2151  1.2  christos   case 60:
   2152  1.2  christos 
   2153  1.2  christos /* Line 1455 of yacc.c  */
   2154  1.2  christos #line 512 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2155  1.2  christos     { pc->rel_seconds += (yyvsp[(1) - (2)].timespec).tv_sec * (yyvsp[(2) - (2)].intval); pc->rel_ns += (yyvsp[(1) - (2)].timespec).tv_nsec * (yyvsp[(2) - (2)].intval); ;}
   2156  1.2  christos     break;
   2157  1.2  christos 
   2158  1.2  christos   case 61:
   2159  1.2  christos 
   2160  1.2  christos /* Line 1455 of yacc.c  */
   2161  1.1  christos #line 514 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2162  1.1  christos     { pc->rel_seconds += (yyvsp[(1) - (2)].timespec).tv_sec * (yyvsp[(2) - (2)].intval); pc->rel_ns += (yyvsp[(1) - (2)].timespec).tv_nsec * (yyvsp[(2) - (2)].intval); ;}
   2163  1.1  christos     break;
   2164  1.1  christos 
   2165  1.2  christos   case 62:
   2166  1.2  christos 
   2167  1.2  christos /* Line 1455 of yacc.c  */
   2168  1.1  christos #line 516 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2169  1.1  christos     { pc->rel_seconds += (yyvsp[(1) - (1)].intval); ;}
   2170  1.1  christos     break;
   2171  1.2  christos 
   2172  1.2  christos   case 64:
   2173  1.2  christos 
   2174  1.2  christos /* Line 1455 of yacc.c  */
   2175  1.1  christos #line 522 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2176  1.1  christos     { pc->rel_year += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2177  1.1  christos     break;
   2178  1.2  christos 
   2179  1.2  christos   case 65:
   2180  1.2  christos 
   2181  1.2  christos /* Line 1455 of yacc.c  */
   2182  1.1  christos #line 524 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2183  1.1  christos     { pc->rel_month += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2184  1.1  christos     break;
   2185  1.2  christos 
   2186  1.2  christos   case 66:
   2187  1.2  christos 
   2188  1.2  christos /* Line 1455 of yacc.c  */
   2189  1.1  christos #line 526 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2190  1.1  christos     { pc->rel_day += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2191  1.1  christos     break;
   2192  1.2  christos 
   2193  1.2  christos   case 67:
   2194  1.2  christos 
   2195  1.2  christos /* Line 1455 of yacc.c  */
   2196  1.2  christos #line 528 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2197  1.2  christos     { pc->rel_hour += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2198  1.2  christos     break;
   2199  1.2  christos 
   2200  1.2  christos   case 68:
   2201  1.2  christos 
   2202  1.2  christos /* Line 1455 of yacc.c  */
   2203  1.1  christos #line 530 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2204  1.1  christos     { pc->rel_minutes += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2205  1.2  christos     break;
   2206  1.2  christos 
   2207  1.2  christos   case 69:
   2208  1.2  christos 
   2209  1.2  christos /* Line 1455 of yacc.c  */
   2210  1.1  christos #line 532 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2211  1.1  christos     { pc->rel_seconds += (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); ;}
   2212  1.1  christos     break;
   2213  1.2  christos 
   2214  1.2  christos   case 73:
   2215  1.2  christos 
   2216  1.2  christos /* Line 1455 of yacc.c  */
   2217  1.2  christos #line 540 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2218  1.2  christos     { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; ;}
   2219  1.2  christos     break;
   2220  1.2  christos 
   2221  1.2  christos   case 75:
   2222  1.2  christos 
   2223  1.2  christos /* Line 1455 of yacc.c  */
   2224  1.1  christos #line 546 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2225  1.1  christos     { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; ;}
   2226  1.2  christos     break;
   2227  1.2  christos 
   2228  1.2  christos   case 76:
   2229  1.2  christos 
   2230  1.1  christos /* Line 1455 of yacc.c  */
   2231  1.1  christos #line 551 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2232  1.2  christos     {
   2233  1.2  christos 	if (pc->dates_seen && ! pc->year.digits
   2234  1.1  christos 	    && ! pc->rels_seen && (pc->times_seen || 2 < (yyvsp[(1) - (1)].textintval).digits))
   2235  1.1  christos 	  pc->year = (yyvsp[(1) - (1)].textintval);
   2236  1.2  christos 	else
   2237  1.1  christos 	  {
   2238  1.1  christos 	    if (4 < (yyvsp[(1) - (1)].textintval).digits)
   2239  1.2  christos 	      {
   2240  1.2  christos 		pc->dates_seen++;
   2241  1.2  christos 		pc->day = (yyvsp[(1) - (1)].textintval).value % 100;
   2242  1.2  christos 		pc->month = ((yyvsp[(1) - (1)].textintval).value / 100) % 100;
   2243  1.1  christos 		pc->year.value = (yyvsp[(1) - (1)].textintval).value / 10000;
   2244  1.1  christos 		pc->year.digits = (yyvsp[(1) - (1)].textintval).digits - 4;
   2245  1.1  christos 	      }
   2246  1.1  christos 	    else
   2247  1.2  christos 	      {
   2248  1.1  christos 		pc->times_seen++;
   2249  1.2  christos 		if ((yyvsp[(1) - (1)].textintval).digits <= 2)
   2250  1.1  christos 		  {
   2251  1.1  christos 		    pc->hour = (yyvsp[(1) - (1)].textintval).value;
   2252  1.1  christos 		    pc->minutes = 0;
   2253  1.1  christos 		  }
   2254  1.2  christos 		else
   2255  1.2  christos 		  {
   2256  1.1  christos 		    pc->hour = (yyvsp[(1) - (1)].textintval).value / 100;
   2257  1.1  christos 		    pc->minutes = (yyvsp[(1) - (1)].textintval).value % 100;
   2258  1.1  christos 		  }
   2259  1.1  christos 		pc->seconds.tv_sec = 0;
   2260  1.1  christos 		pc->seconds.tv_nsec = 0;
   2261  1.1  christos 		pc->meridian = MER24;
   2262  1.2  christos 	      }
   2263  1.1  christos 	  }
   2264  1.1  christos       ;}
   2265  1.2  christos     break;
   2266  1.2  christos 
   2267  1.2  christos   case 77:
   2268  1.2  christos 
   2269  1.2  christos /* Line 1455 of yacc.c  */
   2270  1.1  christos #line 588 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2271  1.1  christos     { (yyval.intval) = -1; ;}
   2272  1.2  christos     break;
   2273  1.2  christos 
   2274  1.2  christos   case 78:
   2275  1.2  christos 
   2276  1.2  christos /* Line 1455 of yacc.c  */
   2277  1.1  christos #line 590 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2278  1.1  christos     { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; ;}
   2279  1.2  christos     break;
   2280  1.2  christos 
   2281  1.2  christos   case 79:
   2282  1.2  christos 
   2283  1.2  christos /* Line 1455 of yacc.c  */
   2284  1.1  christos #line 595 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2285  1.1  christos     { (yyval.intval) = MER24; ;}
   2286  1.2  christos     break;
   2287  1.2  christos 
   2288  1.2  christos   case 80:
   2289  1.2  christos 
   2290  1.2  christos /* Line 1455 of yacc.c  */
   2291  1.1  christos #line 597 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2292  1.1  christos     { (yyval.intval) = (yyvsp[(1) - (1)].intval); ;}
   2293  1.1  christos     break;
   2294  1.2  christos 
   2295  1.2  christos 
   2296  1.2  christos 
   2297  1.2  christos /* Line 1455 of yacc.c  */
   2298  1.1  christos #line 2294 "getdate.c"
   2299  1.2  christos       default: break;
   2300  1.1  christos     }
   2301  1.2  christos   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
   2302  1.2  christos 
   2303  1.1  christos   YYPOPSTACK (yylen);
   2304  1.1  christos   yylen = 0;
   2305  1.1  christos   YY_STACK_PRINT (yyss, yyssp);
   2306  1.1  christos 
   2307  1.1  christos   *++yyvsp = yyval;
   2308  1.1  christos 
   2309  1.1  christos   /* Now `shift' the result of the reduction.  Determine what state
   2310  1.1  christos      that goes to, based on the state we popped back to and the rule
   2311  1.1  christos      number reduced by.  */
   2312  1.1  christos 
   2313  1.1  christos   yyn = yyr1[yyn];
   2314  1.1  christos 
   2315  1.1  christos   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
   2316  1.1  christos   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
   2317  1.1  christos     yystate = yytable[yystate];
   2318  1.1  christos   else
   2319  1.1  christos     yystate = yydefgoto[yyn - YYNTOKENS];
   2320  1.1  christos 
   2321  1.1  christos   goto yynewstate;
   2322  1.1  christos 
   2323  1.1  christos 
   2324  1.1  christos /*------------------------------------.
   2325  1.1  christos | yyerrlab -- here on detecting error |
   2326  1.1  christos `------------------------------------*/
   2327  1.1  christos yyerrlab:
   2328  1.1  christos   /* If not already recovering from an error, report this error.  */
   2329  1.1  christos   if (!yyerrstatus)
   2330  1.2  christos     {
   2331  1.2  christos       ++yynerrs;
   2332  1.2  christos #if ! YYERROR_VERBOSE
   2333  1.2  christos       yyerror (pc, YY_("syntax error"));
   2334  1.2  christos #else
   2335  1.2  christos       {
   2336  1.2  christos 	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
   2337  1.2  christos 	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
   2338  1.2  christos 	  {
   2339  1.2  christos 	    YYSIZE_T yyalloc = 2 * yysize;
   2340  1.2  christos 	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
   2341  1.2  christos 	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
   2342  1.2  christos 	    if (yymsg != yymsgbuf)
   2343  1.2  christos 	      YYSTACK_FREE (yymsg);
   2344  1.2  christos 	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
   2345  1.2  christos 	    if (yymsg)
   2346  1.1  christos 	      yymsg_alloc = yyalloc;
   2347  1.2  christos 	    else
   2348  1.2  christos 	      {
   2349  1.1  christos 		yymsg = yymsgbuf;
   2350  1.2  christos 		yymsg_alloc = sizeof yymsgbuf;
   2351  1.1  christos 	      }
   2352  1.2  christos 	  }
   2353  1.2  christos 
   2354  1.2  christos 	if (0 < yysize && yysize <= yymsg_alloc)
   2355  1.2  christos 	  {
   2356  1.2  christos 	    (void) yysyntax_error (yymsg, yystate, yychar);
   2357  1.2  christos 	    yyerror (pc, yymsg);
   2358  1.2  christos 	  }
   2359  1.2  christos 	else
   2360  1.2  christos 	  {
   2361  1.2  christos 	    yyerror (pc, YY_("syntax error"));
   2362  1.2  christos 	    if (yysize != 0)
   2363  1.2  christos 	      goto yyexhaustedlab;
   2364  1.2  christos 	  }
   2365  1.1  christos       }
   2366  1.1  christos #endif
   2367  1.1  christos     }
   2368  1.1  christos 
   2369  1.1  christos 
   2370  1.1  christos 
   2371  1.1  christos   if (yyerrstatus == 3)
   2372  1.1  christos     {
   2373  1.1  christos       /* If just tried and failed to reuse lookahead token after an
   2374  1.1  christos 	 error, discard it.  */
   2375  1.2  christos 
   2376  1.2  christos       if (yychar <= YYEOF)
   2377  1.1  christos 	{
   2378  1.2  christos 	  /* Return failure if at end of input.  */
   2379  1.2  christos 	  if (yychar == YYEOF)
   2380  1.1  christos 	    YYABORT;
   2381  1.1  christos 	}
   2382  1.2  christos       else
   2383  1.2  christos 	{
   2384  1.1  christos 	  yydestruct ("Error: discarding",
   2385  1.1  christos 		      yytoken, &yylval, pc);
   2386  1.1  christos 	  yychar = YYEMPTY;
   2387  1.1  christos 	}
   2388  1.1  christos     }
   2389  1.1  christos 
   2390  1.1  christos   /* Else will try to reuse lookahead token after shifting the error
   2391  1.1  christos      token.  */
   2392  1.1  christos   goto yyerrlab1;
   2393  1.1  christos 
   2394  1.1  christos 
   2395  1.1  christos /*---------------------------------------------------.
   2396  1.1  christos | yyerrorlab -- error raised explicitly by YYERROR.  |
   2397  1.1  christos `---------------------------------------------------*/
   2398  1.2  christos yyerrorlab:
   2399  1.2  christos 
   2400  1.2  christos   /* Pacify compilers like GCC when the user code never invokes
   2401  1.2  christos      YYERROR and the label yyerrorlab therefore never appears in user
   2402  1.1  christos      code.  */
   2403  1.1  christos   if (/*CONSTCOND*/ 0)
   2404  1.2  christos      goto yyerrorlab;
   2405  1.2  christos 
   2406  1.2  christos   /* Do not reclaim the symbols of the rule which action triggered
   2407  1.2  christos      this YYERROR.  */
   2408  1.2  christos   YYPOPSTACK (yylen);
   2409  1.1  christos   yylen = 0;
   2410  1.1  christos   YY_STACK_PRINT (yyss, yyssp);
   2411  1.1  christos   yystate = *yyssp;
   2412  1.1  christos   goto yyerrlab1;
   2413  1.1  christos 
   2414  1.1  christos 
   2415  1.1  christos /*-------------------------------------------------------------.
   2416  1.1  christos | yyerrlab1 -- common code for both syntax error and YYERROR.  |
   2417  1.1  christos `-------------------------------------------------------------*/
   2418  1.1  christos yyerrlab1:
   2419  1.1  christos   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
   2420  1.1  christos 
   2421  1.1  christos   for (;;)
   2422  1.1  christos     {
   2423  1.1  christos       yyn = yypact[yystate];
   2424  1.1  christos       if (yyn != YYPACT_NINF)
   2425  1.1  christos 	{
   2426  1.1  christos 	  yyn += YYTERROR;
   2427  1.1  christos 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
   2428  1.1  christos 	    {
   2429  1.1  christos 	      yyn = yytable[yyn];
   2430  1.1  christos 	      if (0 < yyn)
   2431  1.1  christos 		break;
   2432  1.1  christos 	    }
   2433  1.1  christos 	}
   2434  1.1  christos 
   2435  1.1  christos       /* Pop the current state because it cannot handle the error token.  */
   2436  1.1  christos       if (yyssp == yyss)
   2437  1.2  christos 	YYABORT;
   2438  1.2  christos 
   2439  1.2  christos 
   2440  1.2  christos       yydestruct ("Error: popping",
   2441  1.1  christos 		  yystos[yystate], yyvsp, pc);
   2442  1.1  christos       YYPOPSTACK (1);
   2443  1.1  christos       yystate = *yyssp;
   2444  1.1  christos       YY_STACK_PRINT (yyss, yyssp);
   2445  1.2  christos     }
   2446  1.1  christos 
   2447  1.1  christos   *++yyvsp = yylval;
   2448  1.2  christos 
   2449  1.2  christos 
   2450  1.1  christos   /* Shift the error token.  */
   2451  1.1  christos   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
   2452  1.1  christos 
   2453  1.1  christos   yystate = yyn;
   2454  1.1  christos   goto yynewstate;
   2455  1.1  christos 
   2456  1.1  christos 
   2457  1.1  christos /*-------------------------------------.
   2458  1.1  christos | yyacceptlab -- YYACCEPT comes here.  |
   2459  1.1  christos `-------------------------------------*/
   2460  1.1  christos yyacceptlab:
   2461  1.1  christos   yyresult = 0;
   2462  1.1  christos   goto yyreturn;
   2463  1.1  christos 
   2464  1.1  christos /*-----------------------------------.
   2465  1.1  christos | yyabortlab -- YYABORT comes here.  |
   2466  1.1  christos `-----------------------------------*/
   2467  1.1  christos yyabortlab:
   2468  1.1  christos   yyresult = 1;
   2469  1.2  christos   goto yyreturn;
   2470  1.2  christos 
   2471  1.2  christos #if !defined(yyoverflow) || YYERROR_VERBOSE
   2472  1.2  christos /*-------------------------------------------------.
   2473  1.2  christos | yyexhaustedlab -- memory exhaustion comes here.  |
   2474  1.2  christos `-------------------------------------------------*/
   2475  1.1  christos yyexhaustedlab:
   2476  1.1  christos   yyerror (pc, YY_("memory exhausted"));
   2477  1.1  christos   yyresult = 2;
   2478  1.1  christos   /* Fall through.  */
   2479  1.1  christos #endif
   2480  1.2  christos 
   2481  1.2  christos yyreturn:
   2482  1.2  christos   if (yychar != YYEMPTY)
   2483  1.2  christos      yydestruct ("Cleanup: discarding lookahead",
   2484  1.2  christos 		 yytoken, &yylval, pc);
   2485  1.2  christos   /* Do not reclaim the symbols of the rule which action triggered
   2486  1.2  christos      this YYABORT or YYACCEPT.  */
   2487  1.2  christos   YYPOPSTACK (yylen);
   2488  1.2  christos   YY_STACK_PRINT (yyss, yyssp);
   2489  1.2  christos   while (yyssp != yyss)
   2490  1.2  christos     {
   2491  1.2  christos       yydestruct ("Cleanup: popping",
   2492  1.2  christos 		  yystos[*yyssp], yyvsp, pc);
   2493  1.1  christos       YYPOPSTACK (1);
   2494  1.1  christos     }
   2495  1.1  christos #ifndef yyoverflow
   2496  1.1  christos   if (yyss != yyssa)
   2497  1.2  christos     YYSTACK_FREE (yyss);
   2498  1.2  christos #endif
   2499  1.2  christos #if YYERROR_VERBOSE
   2500  1.2  christos   if (yymsg != yymsgbuf)
   2501  1.2  christos     YYSTACK_FREE (yymsg);
   2502  1.2  christos #endif
   2503  1.1  christos   /* Make sure YYID is used.  */
   2504  1.1  christos   return YYID (yyresult);
   2505  1.1  christos }
   2506  1.2  christos 
   2507  1.2  christos 
   2508  1.2  christos 
   2509  1.1  christos /* Line 1675 of yacc.c  */
   2510  1.1  christos #line 600 "/usr/src/external/gpl2/xcvs/dist/lib/getdate.y"
   2511  1.1  christos 
   2512  1.1  christos 
   2513  1.1  christos static table const meridian_table[] =
   2514  1.1  christos {
   2515  1.1  christos   { "AM",   tMERIDIAN, MERam },
   2516  1.1  christos   { "A.M.", tMERIDIAN, MERam },
   2517  1.1  christos   { "PM",   tMERIDIAN, MERpm },
   2518  1.1  christos   { "P.M.", tMERIDIAN, MERpm },
   2519  1.1  christos   { NULL, 0, 0 }
   2520  1.1  christos };
   2521  1.1  christos 
   2522  1.1  christos static table const dst_table[] =
   2523  1.1  christos {
   2524  1.1  christos   { "DST", tDST, 0 }
   2525  1.1  christos };
   2526  1.1  christos 
   2527  1.1  christos static table const month_and_day_table[] =
   2528  1.1  christos {
   2529  1.1  christos   { "JANUARY",	tMONTH,	 1 },
   2530  1.1  christos   { "FEBRUARY",	tMONTH,	 2 },
   2531  1.1  christos   { "MARCH",	tMONTH,	 3 },
   2532  1.1  christos   { "APRIL",	tMONTH,	 4 },
   2533  1.1  christos   { "MAY",	tMONTH,	 5 },
   2534  1.1  christos   { "JUNE",	tMONTH,	 6 },
   2535  1.1  christos   { "JULY",	tMONTH,	 7 },
   2536  1.1  christos   { "AUGUST",	tMONTH,	 8 },
   2537  1.1  christos   { "SEPTEMBER",tMONTH,	 9 },
   2538  1.1  christos   { "SEPT",	tMONTH,	 9 },
   2539  1.1  christos   { "OCTOBER",	tMONTH,	10 },
   2540  1.1  christos   { "NOVEMBER",	tMONTH,	11 },
   2541  1.1  christos   { "DECEMBER",	tMONTH,	12 },
   2542  1.1  christos   { "SUNDAY",	tDAY,	 0 },
   2543  1.1  christos   { "MONDAY",	tDAY,	 1 },
   2544  1.1  christos   { "TUESDAY",	tDAY,	 2 },
   2545  1.1  christos   { "TUES",	tDAY,	 2 },
   2546  1.1  christos   { "WEDNESDAY",tDAY,	 3 },
   2547  1.1  christos   { "WEDNES",	tDAY,	 3 },
   2548  1.1  christos   { "THURSDAY",	tDAY,	 4 },
   2549  1.1  christos   { "THUR",	tDAY,	 4 },
   2550  1.1  christos   { "THURS",	tDAY,	 4 },
   2551  1.1  christos   { "FRIDAY",	tDAY,	 5 },
   2552  1.1  christos   { "SATURDAY",	tDAY,	 6 },
   2553  1.1  christos   { NULL, 0, 0 }
   2554  1.1  christos };
   2555  1.1  christos 
   2556  1.1  christos static table const time_units_table[] =
   2557  1.1  christos {
   2558  1.1  christos   { "YEAR",	tYEAR_UNIT,	 1 },
   2559  1.1  christos   { "MONTH",	tMONTH_UNIT,	 1 },
   2560  1.1  christos   { "FORTNIGHT",tDAY_UNIT,	14 },
   2561  1.1  christos   { "WEEK",	tDAY_UNIT,	 7 },
   2562  1.1  christos   { "DAY",	tDAY_UNIT,	 1 },
   2563  1.1  christos   { "HOUR",	tHOUR_UNIT,	 1 },
   2564  1.1  christos   { "MINUTE",	tMINUTE_UNIT,	 1 },
   2565  1.1  christos   { "MIN",	tMINUTE_UNIT,	 1 },
   2566  1.1  christos   { "SECOND",	tSEC_UNIT,	 1 },
   2567  1.1  christos   { "SEC",	tSEC_UNIT,	 1 },
   2568  1.1  christos   { NULL, 0, 0 }
   2569  1.1  christos };
   2570  1.1  christos 
   2571  1.1  christos /* Assorted relative-time words. */
   2572  1.1  christos static table const relative_time_table[] =
   2573  1.1  christos {
   2574  1.1  christos   { "TOMORROW",	tDAY_UNIT,	 1 },
   2575  1.1  christos   { "YESTERDAY",tDAY_UNIT,	-1 },
   2576  1.1  christos   { "TODAY",	tDAY_UNIT,	 0 },
   2577  1.1  christos   { "NOW",	tDAY_UNIT,	 0 },
   2578  1.1  christos   { "LAST",	tORDINAL,	-1 },
   2579  1.1  christos   { "THIS",	tORDINAL,	 0 },
   2580  1.1  christos   { "NEXT",	tORDINAL,	 1 },
   2581  1.1  christos   { "FIRST",	tORDINAL,	 1 },
   2582  1.1  christos /*{ "SECOND",	tORDINAL,	 2 }, */
   2583  1.1  christos   { "THIRD",	tORDINAL,	 3 },
   2584  1.1  christos   { "FOURTH",	tORDINAL,	 4 },
   2585  1.1  christos   { "FIFTH",	tORDINAL,	 5 },
   2586  1.1  christos   { "SIXTH",	tORDINAL,	 6 },
   2587  1.1  christos   { "SEVENTH",	tORDINAL,	 7 },
   2588  1.1  christos   { "EIGHTH",	tORDINAL,	 8 },
   2589  1.1  christos   { "NINTH",	tORDINAL,	 9 },
   2590  1.1  christos   { "TENTH",	tORDINAL,	10 },
   2591  1.1  christos   { "ELEVENTH",	tORDINAL,	11 },
   2592  1.1  christos   { "TWELFTH",	tORDINAL,	12 },
   2593  1.1  christos   { "AGO",	tAGO,		 1 },
   2594  1.1  christos   { NULL, 0, 0 }
   2595  1.1  christos };
   2596  1.1  christos 
   2597  1.1  christos /* The universal time zone table.  These labels can be used even for
   2598  1.1  christos    time stamps that would not otherwise be valid, e.g., GMT time
   2599  1.1  christos    stamps in London during summer.  */
   2600  1.1  christos static table const universal_time_zone_table[] =
   2601  1.1  christos {
   2602  1.1  christos   { "GMT",	tZONE,     HOUR ( 0) },	/* Greenwich Mean */
   2603  1.1  christos   { "UT",	tZONE,     HOUR ( 0) },	/* Universal (Coordinated) */
   2604  1.1  christos   { "UTC",	tZONE,     HOUR ( 0) },
   2605  1.1  christos   { NULL, 0, 0 }
   2606  1.1  christos };
   2607  1.1  christos 
   2608  1.1  christos /* The time zone table.  This table is necessarily incomplete, as time
   2609  1.1  christos    zone abbreviations are ambiguous; e.g. Australians interpret "EST"
   2610  1.1  christos    as Eastern time in Australia, not as US Eastern Standard Time.
   2611  1.1  christos    You cannot rely on getdate to handle arbitrary time zone
   2612  1.1  christos    abbreviations; use numeric abbreviations like `-0500' instead.  */
   2613  1.1  christos static table const time_zone_table[] =
   2614  1.1  christos {
   2615  1.1  christos   { "WET",	tZONE,     HOUR ( 0) },	/* Western European */
   2616  1.1  christos   { "WEST",	tDAYZONE,  HOUR ( 0) },	/* Western European Summer */
   2617  1.1  christos   { "BST",	tDAYZONE,  HOUR ( 0) },	/* British Summer */
   2618  1.1  christos   { "ART",	tZONE,	  -HOUR ( 3) },	/* Argentina */
   2619  1.1  christos   { "BRT",	tZONE,	  -HOUR ( 3) },	/* Brazil */
   2620  1.1  christos   { "BRST",	tDAYZONE, -HOUR ( 3) },	/* Brazil Summer */
   2621  1.1  christos   { "NST",	tZONE,	 -(HOUR ( 3) + 30) },	/* Newfoundland Standard */
   2622  1.1  christos   { "NDT",	tDAYZONE,-(HOUR ( 3) + 30) },	/* Newfoundland Daylight */
   2623  1.1  christos   { "AST",	tZONE,    -HOUR ( 4) },	/* Atlantic Standard */
   2624  1.1  christos   { "ADT",	tDAYZONE, -HOUR ( 4) },	/* Atlantic Daylight */
   2625  1.1  christos   { "CLT",	tZONE,    -HOUR ( 4) },	/* Chile */
   2626  1.1  christos   { "CLST",	tDAYZONE, -HOUR ( 4) },	/* Chile Summer */
   2627  1.1  christos   { "EST",	tZONE,    -HOUR ( 5) },	/* Eastern Standard */
   2628  1.1  christos   { "EDT",	tDAYZONE, -HOUR ( 5) },	/* Eastern Daylight */
   2629  1.1  christos   { "CST",	tZONE,    -HOUR ( 6) },	/* Central Standard */
   2630  1.1  christos   { "CDT",	tDAYZONE, -HOUR ( 6) },	/* Central Daylight */
   2631  1.1  christos   { "MST",	tZONE,    -HOUR ( 7) },	/* Mountain Standard */
   2632  1.1  christos   { "MDT",	tDAYZONE, -HOUR ( 7) },	/* Mountain Daylight */
   2633  1.1  christos   { "PST",	tZONE,    -HOUR ( 8) },	/* Pacific Standard */
   2634  1.1  christos   { "PDT",	tDAYZONE, -HOUR ( 8) },	/* Pacific Daylight */
   2635  1.1  christos   { "AKST",	tZONE,    -HOUR ( 9) },	/* Alaska Standard */
   2636  1.1  christos   { "AKDT",	tDAYZONE, -HOUR ( 9) },	/* Alaska Daylight */
   2637  1.1  christos   { "HST",	tZONE,    -HOUR (10) },	/* Hawaii Standard */
   2638  1.1  christos   { "HAST",	tZONE,	  -HOUR (10) },	/* Hawaii-Aleutian Standard */
   2639  1.1  christos   { "HADT",	tDAYZONE, -HOUR (10) },	/* Hawaii-Aleutian Daylight */
   2640  1.1  christos   { "SST",	tZONE,    -HOUR (12) },	/* Samoa Standard */
   2641  1.1  christos   { "WAT",	tZONE,     HOUR ( 1) },	/* West Africa */
   2642  1.1  christos   { "CET",	tZONE,     HOUR ( 1) },	/* Central European */
   2643  1.1  christos   { "CEST",	tDAYZONE,  HOUR ( 1) },	/* Central European Summer */
   2644  1.1  christos   { "MET",	tZONE,     HOUR ( 1) },	/* Middle European */
   2645  1.1  christos   { "MEZ",	tZONE,     HOUR ( 1) },	/* Middle European */
   2646  1.1  christos   { "MEST",	tDAYZONE,  HOUR ( 1) },	/* Middle European Summer */
   2647  1.1  christos   { "MESZ",	tDAYZONE,  HOUR ( 1) },	/* Middle European Summer */
   2648  1.1  christos   { "EET",	tZONE,     HOUR ( 2) },	/* Eastern European */
   2649  1.1  christos   { "EEST",	tDAYZONE,  HOUR ( 2) },	/* Eastern European Summer */
   2650  1.1  christos   { "CAT",	tZONE,	   HOUR ( 2) },	/* Central Africa */
   2651  1.1  christos   { "SAST",	tZONE,	   HOUR ( 2) },	/* South Africa Standard */
   2652  1.1  christos   { "EAT",	tZONE,	   HOUR ( 3) },	/* East Africa */
   2653  1.1  christos   { "MSK",	tZONE,	   HOUR ( 3) },	/* Moscow */
   2654  1.1  christos   { "MSD",	tDAYZONE,  HOUR ( 3) },	/* Moscow Daylight */
   2655  1.1  christos   { "IST",	tZONE,	  (HOUR ( 5) + 30) },	/* India Standard */
   2656  1.1  christos   { "SGT",	tZONE,     HOUR ( 8) },	/* Singapore */
   2657  1.1  christos   { "KST",	tZONE,     HOUR ( 9) },	/* Korea Standard */
   2658  1.1  christos   { "JST",	tZONE,     HOUR ( 9) },	/* Japan Standard */
   2659  1.1  christos   { "GST",	tZONE,     HOUR (10) },	/* Guam Standard */
   2660  1.1  christos   { "NZST",	tZONE,     HOUR (12) },	/* New Zealand Standard */
   2661  1.1  christos   { "NZDT",	tDAYZONE,  HOUR (12) },	/* New Zealand Daylight */
   2662  1.1  christos   { NULL, 0, 0 }
   2663  1.1  christos };
   2664  1.1  christos 
   2665  1.1  christos /* Military time zone table. */
   2666  1.1  christos static table const military_table[] =
   2667  1.1  christos {
   2668  1.1  christos   { "A", tZONE,	-HOUR ( 1) },
   2669  1.1  christos   { "B", tZONE,	-HOUR ( 2) },
   2670  1.1  christos   { "C", tZONE,	-HOUR ( 3) },
   2671  1.1  christos   { "D", tZONE,	-HOUR ( 4) },
   2672  1.1  christos   { "E", tZONE,	-HOUR ( 5) },
   2673  1.1  christos   { "F", tZONE,	-HOUR ( 6) },
   2674  1.1  christos   { "G", tZONE,	-HOUR ( 7) },
   2675  1.1  christos   { "H", tZONE,	-HOUR ( 8) },
   2676  1.1  christos   { "I", tZONE,	-HOUR ( 9) },
   2677  1.1  christos   { "K", tZONE,	-HOUR (10) },
   2678  1.1  christos   { "L", tZONE,	-HOUR (11) },
   2679  1.1  christos   { "M", tZONE,	-HOUR (12) },
   2680  1.1  christos   { "N", tZONE,	 HOUR ( 1) },
   2681  1.1  christos   { "O", tZONE,	 HOUR ( 2) },
   2682  1.1  christos   { "P", tZONE,	 HOUR ( 3) },
   2683  1.1  christos   { "Q", tZONE,	 HOUR ( 4) },
   2684  1.1  christos   { "R", tZONE,	 HOUR ( 5) },
   2685  1.1  christos   { "S", tZONE,	 HOUR ( 6) },
   2686  1.1  christos   { "T", tZONE,	 HOUR ( 7) },
   2687  1.1  christos   { "U", tZONE,	 HOUR ( 8) },
   2688  1.1  christos   { "V", tZONE,	 HOUR ( 9) },
   2689  1.1  christos   { "W", tZONE,	 HOUR (10) },
   2690  1.1  christos   { "X", tZONE,	 HOUR (11) },
   2691  1.1  christos   { "Y", tZONE,	 HOUR (12) },
   2692  1.1  christos   { "Z", tZONE,	 HOUR ( 0) },
   2693  1.1  christos   { NULL, 0, 0 }
   2694  1.1  christos };
   2695  1.1  christos 
   2696  1.1  christos 
   2697  1.1  christos 
   2699  1.1  christos /* Convert a time zone expressed as HH:MM into an integer count of
   2700  1.1  christos    minutes.  If MM is negative, then S is of the form HHMM and needs
   2701  1.1  christos    to be picked apart; otherwise, S is of the form HH.  */
   2702  1.1  christos 
   2703  1.1  christos static long int
   2704  1.1  christos time_zone_hhmm (textint s, long int mm)
   2705  1.1  christos {
   2706  1.1  christos   if (mm < 0)
   2707  1.1  christos     return (s.value / 100) * 60 + s.value % 100;
   2708  1.1  christos   else
   2709  1.1  christos     return s.value * 60 + (s.negative ? -mm : mm);
   2710  1.1  christos }
   2711  1.1  christos 
   2712  1.1  christos static int
   2713  1.1  christos to_hour (long int hours, int meridian)
   2714  1.1  christos {
   2715  1.1  christos   switch (meridian)
   2716  1.1  christos     {
   2717  1.1  christos     default: /* Pacify GCC.  */
   2718  1.1  christos     case MER24:
   2719  1.1  christos       return 0 <= hours && hours < 24 ? hours : -1;
   2720  1.1  christos     case MERam:
   2721  1.1  christos       return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
   2722  1.1  christos     case MERpm:
   2723  1.1  christos       return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
   2724  1.1  christos     }
   2725  1.1  christos }
   2726  1.1  christos 
   2727  1.1  christos static long int
   2728  1.1  christos to_year (textint textyear)
   2729  1.1  christos {
   2730  1.1  christos   long int year = textyear.value;
   2731  1.1  christos 
   2732  1.1  christos   if (year < 0)
   2733  1.1  christos     year = -year;
   2734  1.1  christos 
   2735  1.1  christos   /* XPG4 suggests that years 00-68 map to 2000-2068, and
   2736  1.1  christos      years 69-99 map to 1969-1999.  */
   2737  1.1  christos   else if (textyear.digits == 2)
   2738  1.1  christos     year += year < 69 ? 2000 : 1900;
   2739  1.1  christos 
   2740  1.1  christos   return year;
   2741  1.1  christos }
   2742  1.1  christos 
   2743  1.1  christos static table const *
   2744  1.1  christos lookup_zone (parser_control const *pc, char const *name)
   2745  1.1  christos {
   2746  1.1  christos   table const *tp;
   2747  1.1  christos 
   2748  1.1  christos   for (tp = universal_time_zone_table; tp->name; tp++)
   2749  1.1  christos     if (strcmp (name, tp->name) == 0)
   2750  1.1  christos       return tp;
   2751  1.1  christos 
   2752  1.1  christos   /* Try local zone abbreviations before those in time_zone_table, as
   2753  1.1  christos      the local ones are more likely to be right.  */
   2754  1.1  christos   for (tp = pc->local_time_zone_table; tp->name; tp++)
   2755  1.1  christos     if (strcmp (name, tp->name) == 0)
   2756  1.1  christos       return tp;
   2757  1.1  christos 
   2758  1.1  christos   for (tp = time_zone_table; tp->name; tp++)
   2759  1.1  christos     if (strcmp (name, tp->name) == 0)
   2760  1.1  christos       return tp;
   2761  1.1  christos 
   2762  1.1  christos   return NULL;
   2763  1.1  christos }
   2764  1.1  christos 
   2765  1.1  christos #if ! HAVE_TM_GMTOFF
   2766  1.1  christos /* Yield the difference between *A and *B,
   2767  1.1  christos    measured in seconds, ignoring leap seconds.
   2768  1.1  christos    The body of this function is taken directly from the GNU C Library;
   2769  1.1  christos    see src/strftime.c.  */
   2770  1.1  christos static long int
   2771  1.1  christos tm_diff (struct tm const *a, struct tm const *b)
   2772  1.1  christos {
   2773  1.1  christos   /* Compute intervening leap days correctly even if year is negative.
   2774  1.1  christos      Take care to avoid int overflow in leap day calculations.  */
   2775  1.1  christos   int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3);
   2776  1.1  christos   int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3);
   2777  1.1  christos   int a100 = a4 / 25 - (a4 % 25 < 0);
   2778  1.1  christos   int b100 = b4 / 25 - (b4 % 25 < 0);
   2779  1.1  christos   int a400 = SHR (a100, 2);
   2780  1.1  christos   int b400 = SHR (b100, 2);
   2781  1.1  christos   int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
   2782  1.1  christos   long int ayear = a->tm_year;
   2783  1.1  christos   long int years = ayear - b->tm_year;
   2784  1.1  christos   long int days = (365 * years + intervening_leap_days
   2785  1.1  christos 		   + (a->tm_yday - b->tm_yday));
   2786  1.1  christos   return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
   2787  1.1  christos 		+ (a->tm_min - b->tm_min))
   2788  1.1  christos 	  + (a->tm_sec - b->tm_sec));
   2789  1.1  christos }
   2790  1.1  christos #endif /* ! HAVE_TM_GMTOFF */
   2791  1.1  christos 
   2792  1.1  christos static table const *
   2793  1.1  christos lookup_word (parser_control const *pc, char *word)
   2794  1.1  christos {
   2795  1.1  christos   char *p;
   2796  1.1  christos   char *q;
   2797  1.1  christos   size_t wordlen;
   2798  1.1  christos   table const *tp;
   2799  1.1  christos   bool period_found;
   2800  1.1  christos   bool abbrev;
   2801  1.1  christos 
   2802  1.1  christos   /* Make it uppercase.  */
   2803  1.1  christos   for (p = word; *p; p++)
   2804  1.1  christos     {
   2805  1.1  christos       unsigned char ch = *p;
   2806  1.1  christos       if (ISLOWER (ch))
   2807  1.1  christos 	*p = toupper (ch);
   2808  1.1  christos     }
   2809  1.1  christos 
   2810  1.1  christos   for (tp = meridian_table; tp->name; tp++)
   2811  1.1  christos     if (strcmp (word, tp->name) == 0)
   2812  1.1  christos       return tp;
   2813  1.1  christos 
   2814  1.1  christos   /* See if we have an abbreviation for a month. */
   2815  1.1  christos   wordlen = strlen (word);
   2816  1.1  christos   abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.');
   2817  1.1  christos 
   2818  1.1  christos   for (tp = month_and_day_table; tp->name; tp++)
   2819  1.1  christos     if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0)
   2820  1.1  christos       return tp;
   2821  1.1  christos 
   2822  1.1  christos   if ((tp = lookup_zone (pc, word)))
   2823  1.1  christos     return tp;
   2824  1.1  christos 
   2825  1.1  christos   if (strcmp (word, dst_table[0].name) == 0)
   2826  1.1  christos     return dst_table;
   2827  1.1  christos 
   2828  1.1  christos   for (tp = time_units_table; tp->name; tp++)
   2829  1.1  christos     if (strcmp (word, tp->name) == 0)
   2830  1.1  christos       return tp;
   2831  1.1  christos 
   2832  1.1  christos   /* Strip off any plural and try the units table again. */
   2833  1.1  christos   if (word[wordlen - 1] == 'S')
   2834  1.1  christos     {
   2835  1.1  christos       word[wordlen - 1] = '\0';
   2836  1.1  christos       for (tp = time_units_table; tp->name; tp++)
   2837  1.1  christos 	if (strcmp (word, tp->name) == 0)
   2838  1.1  christos 	  return tp;
   2839  1.1  christos       word[wordlen - 1] = 'S';	/* For "this" in relative_time_table.  */
   2840  1.1  christos     }
   2841  1.1  christos 
   2842  1.1  christos   for (tp = relative_time_table; tp->name; tp++)
   2843  1.1  christos     if (strcmp (word, tp->name) == 0)
   2844  1.1  christos       return tp;
   2845  1.1  christos 
   2846  1.1  christos   /* Military time zones. */
   2847  1.1  christos   if (wordlen == 1)
   2848  1.1  christos     for (tp = military_table; tp->name; tp++)
   2849  1.1  christos       if (word[0] == tp->name[0])
   2850  1.1  christos 	return tp;
   2851  1.1  christos 
   2852  1.1  christos   /* Drop out any periods and try the time zone table again. */
   2853  1.1  christos   for (period_found = false, p = q = word; (*p = *q); q++)
   2854  1.1  christos     if (*q == '.')
   2855  1.1  christos       period_found = true;
   2856  1.1  christos     else
   2857  1.1  christos       p++;
   2858  1.1  christos   if (period_found && (tp = lookup_zone (pc, word)))
   2859  1.1  christos     return tp;
   2860  1.1  christos 
   2861  1.1  christos   return NULL;
   2862  1.1  christos }
   2863  1.1  christos 
   2864  1.1  christos static int
   2865  1.1  christos yylex (YYSTYPE *lvalp, parser_control *pc)
   2866  1.1  christos {
   2867  1.1  christos   unsigned char c;
   2868  1.1  christos   size_t count;
   2869  1.1  christos 
   2870  1.1  christos   for (;;)
   2871  1.1  christos     {
   2872  1.1  christos       while (c = *pc->input, ISSPACE (c))
   2873  1.1  christos 	pc->input++;
   2874  1.1  christos 
   2875  1.1  christos       if (ISDIGIT (c) || c == '-' || c == '+')
   2876  1.1  christos 	{
   2877  1.1  christos 	  char const *p;
   2878  1.1  christos 	  int sign;
   2879  1.1  christos 	  unsigned long int value;
   2880  1.1  christos 	  if (c == '-' || c == '+')
   2881  1.1  christos 	    {
   2882  1.1  christos 	      sign = c == '-' ? -1 : 1;
   2883  1.1  christos 	      while (c = *++pc->input, ISSPACE (c))
   2884  1.1  christos 		continue;
   2885  1.1  christos 	      if (! ISDIGIT (c))
   2886  1.1  christos 		/* skip the '-' sign */
   2887  1.1  christos 		continue;
   2888  1.1  christos 	    }
   2889  1.1  christos 	  else
   2890  1.1  christos 	    sign = 0;
   2891  1.1  christos 	  p = pc->input;
   2892  1.1  christos 	  for (value = 0; ; value *= 10)
   2893  1.1  christos 	    {
   2894  1.1  christos 	      unsigned long int value1 = value + (c - '0');
   2895  1.1  christos 	      if (value1 < value)
   2896  1.1  christos 		return '?';
   2897  1.1  christos 	      value = value1;
   2898  1.1  christos 	      c = *++p;
   2899  1.1  christos 	      if (! ISDIGIT (c))
   2900  1.1  christos 		break;
   2901  1.1  christos 	      if (ULONG_MAX / 10 < value)
   2902  1.1  christos 		return '?';
   2903  1.1  christos 	    }
   2904  1.1  christos 	  if ((c == '.' || c == ',') && ISDIGIT (p[1]))
   2905  1.1  christos 	    {
   2906  1.1  christos 	      time_t s;
   2907  1.1  christos 	      int ns;
   2908  1.1  christos 	      int digits;
   2909  1.1  christos 	      unsigned long int value1;
   2910  1.1  christos 
   2911  1.1  christos 	      /* Check for overflow when converting value to time_t.  */
   2912  1.1  christos 	      if (sign < 0)
   2913  1.1  christos 		{
   2914  1.1  christos 		  s = - value;
   2915  1.1  christos 		  if (0 < s)
   2916  1.1  christos 		    return '?';
   2917  1.1  christos 		  value1 = -s;
   2918  1.1  christos 		}
   2919  1.1  christos 	      else
   2920  1.1  christos 		{
   2921  1.1  christos 		  s = value;
   2922  1.1  christos 		  if (s < 0)
   2923  1.1  christos 		    return '?';
   2924  1.1  christos 		  value1 = s;
   2925  1.1  christos 		}
   2926  1.1  christos 	      if (value != value1)
   2927  1.1  christos 		return '?';
   2928  1.1  christos 
   2929  1.1  christos 	      /* Accumulate fraction, to ns precision.  */
   2930  1.1  christos 	      p++;
   2931  1.1  christos 	      ns = *p++ - '0';
   2932  1.1  christos 	      for (digits = 2; digits <= LOG10_BILLION; digits++)
   2933  1.1  christos 		{
   2934  1.1  christos 		  ns *= 10;
   2935  1.1  christos 		  if (ISDIGIT (*p))
   2936  1.1  christos 		    ns += *p++ - '0';
   2937  1.1  christos 		}
   2938  1.1  christos 
   2939  1.1  christos 	      /* Skip excess digits, truncating toward -Infinity.  */
   2940  1.1  christos 	      if (sign < 0)
   2941  1.1  christos 		for (; ISDIGIT (*p); p++)
   2942  1.1  christos 		  if (*p != '0')
   2943  1.1  christos 		    {
   2944  1.1  christos 		      ns++;
   2945  1.1  christos 		      break;
   2946  1.1  christos 		    }
   2947  1.1  christos 	      while (ISDIGIT (*p))
   2948  1.1  christos 		p++;
   2949  1.1  christos 
   2950  1.1  christos 	      /* Adjust to the timespec convention, which is that
   2951  1.1  christos 		 tv_nsec is always a positive offset even if tv_sec is
   2952  1.1  christos 		 negative.  */
   2953  1.1  christos 	      if (sign < 0 && ns)
   2954  1.1  christos 		{
   2955  1.1  christos 		  s--;
   2956  1.1  christos 		  if (! (s < 0))
   2957  1.1  christos 		    return '?';
   2958  1.1  christos 		  ns = BILLION - ns;
   2959  1.1  christos 		}
   2960  1.1  christos 
   2961  1.1  christos 	      lvalp->timespec.tv_sec = s;
   2962  1.1  christos 	      lvalp->timespec.tv_nsec = ns;
   2963  1.1  christos 	      pc->input = p;
   2964  1.1  christos 	      return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER;
   2965  1.1  christos 	    }
   2966  1.1  christos 	  else
   2967  1.1  christos 	    {
   2968  1.1  christos 	      lvalp->textintval.negative = sign < 0;
   2969  1.1  christos 	      if (sign < 0)
   2970  1.1  christos 		{
   2971  1.1  christos 		  lvalp->textintval.value = - value;
   2972  1.1  christos 		  if (0 < lvalp->textintval.value)
   2973  1.1  christos 		    return '?';
   2974  1.1  christos 		}
   2975  1.1  christos 	      else
   2976  1.1  christos 		{
   2977  1.1  christos 		  lvalp->textintval.value = value;
   2978  1.1  christos 		  if (lvalp->textintval.value < 0)
   2979  1.1  christos 		    return '?';
   2980  1.1  christos 		}
   2981  1.1  christos 	      lvalp->textintval.digits = p - pc->input;
   2982  1.1  christos 	      pc->input = p;
   2983  1.1  christos 	      return sign ? tSNUMBER : tUNUMBER;
   2984  1.1  christos 	    }
   2985  1.1  christos 	}
   2986  1.1  christos 
   2987  1.1  christos       if (ISALPHA (c))
   2988  1.1  christos 	{
   2989  1.1  christos 	  char buff[20];
   2990  1.1  christos 	  char *p = buff;
   2991  1.1  christos 	  table const *tp;
   2992  1.1  christos 
   2993  1.1  christos 	  do
   2994  1.1  christos 	    {
   2995  1.1  christos 	      if (p < buff + sizeof buff - 1)
   2996  1.1  christos 		*p++ = c;
   2997  1.1  christos 	      c = *++pc->input;
   2998  1.1  christos 	    }
   2999  1.1  christos 	  while (ISALPHA (c) || c == '.');
   3000  1.1  christos 
   3001  1.1  christos 	  *p = '\0';
   3002  1.1  christos 	  tp = lookup_word (pc, buff);
   3003  1.1  christos 	  if (! tp)
   3004  1.1  christos 	    return '?';
   3005  1.1  christos 	  lvalp->intval = tp->value;
   3006  1.1  christos 	  return tp->type;
   3007  1.1  christos 	}
   3008  1.1  christos 
   3009  1.1  christos       if (c != '(')
   3010  1.1  christos 	return *pc->input++;
   3011  1.1  christos       count = 0;
   3012  1.1  christos       do
   3013  1.1  christos 	{
   3014  1.1  christos 	  c = *pc->input++;
   3015  1.1  christos 	  if (c == '\0')
   3016  1.1  christos 	    return c;
   3017  1.1  christos 	  if (c == '(')
   3018  1.1  christos 	    count++;
   3019  1.1  christos 	  else if (c == ')')
   3020  1.1  christos 	    count--;
   3021  1.1  christos 	}
   3022  1.1  christos       while (count != 0);
   3023  1.1  christos     }
   3024  1.1  christos }
   3025  1.1  christos 
   3026  1.1  christos /* Do nothing if the parser reports an error.  */
   3027  1.1  christos static int
   3028  1.1  christos yyerror (parser_control *pc ATTRIBUTE_UNUSED, char *s ATTRIBUTE_UNUSED)
   3029  1.1  christos {
   3030  1.1  christos   return 0;
   3031  1.1  christos }
   3032  1.1  christos 
   3033  1.1  christos /* If *TM0 is the old and *TM1 is the new value of a struct tm after
   3034  1.1  christos    passing it to mktime, return true if it's OK that mktime returned T.
   3035  1.1  christos    It's not OK if *TM0 has out-of-range members.  */
   3036  1.1  christos 
   3037  1.1  christos static bool
   3038  1.1  christos mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t)
   3039  1.1  christos {
   3040  1.1  christos   if (t == (time_t) -1)
   3041  1.1  christos     {
   3042  1.1  christos       /* Guard against falsely reporting an error when parsing a time
   3043  1.1  christos 	 stamp that happens to equal (time_t) -1, on a host that
   3044  1.1  christos 	 supports such a time stamp.  */
   3045  1.1  christos       tm1 = localtime (&t);
   3046  1.1  christos       if (!tm1)
   3047  1.1  christos 	return false;
   3048  1.1  christos     }
   3049  1.1  christos 
   3050  1.1  christos   return ! ((tm0->tm_sec ^ tm1->tm_sec)
   3051  1.1  christos 	    | (tm0->tm_min ^ tm1->tm_min)
   3052  1.1  christos 	    | (tm0->tm_hour ^ tm1->tm_hour)
   3053  1.1  christos 	    | (tm0->tm_mday ^ tm1->tm_mday)
   3054  1.1  christos 	    | (tm0->tm_mon ^ tm1->tm_mon)
   3055  1.1  christos 	    | (tm0->tm_year ^ tm1->tm_year));
   3056  1.1  christos }
   3057  1.1  christos 
   3058  1.1  christos /* A reasonable upper bound for the size of ordinary TZ strings.
   3059  1.1  christos    Use heap allocation if TZ's length exceeds this.  */
   3060  1.1  christos enum { TZBUFSIZE = 100 };
   3061  1.1  christos 
   3062  1.1  christos /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated
   3063  1.1  christos    otherwise.  */
   3064  1.1  christos static char *
   3065  1.1  christos get_tz (char tzbuf[TZBUFSIZE])
   3066  1.1  christos {
   3067  1.1  christos   char *tz = getenv ("TZ");
   3068  1.1  christos   if (tz)
   3069  1.1  christos     {
   3070  1.1  christos       size_t tzsize = strlen (tz) + 1;
   3071  1.1  christos       tz = (tzsize <= TZBUFSIZE
   3072  1.1  christos 	    ? memcpy (tzbuf, tz, tzsize)
   3073  1.1  christos 	    : xmemdup (tz, tzsize));
   3074  1.1  christos     }
   3075  1.1  christos   return tz;
   3076  1.1  christos }
   3077  1.1  christos 
   3078  1.1  christos /* Parse a date/time string, storing the resulting time value into *RESULT.
   3079  1.1  christos    The string itself is pointed to by P.  Return true if successful.
   3080  1.1  christos    P can be an incomplete or relative time specification; if so, use
   3081  1.1  christos    *NOW as the basis for the returned time.  */
   3082  1.1  christos bool
   3083  1.1  christos get_date (struct timespec *result, char const *p, struct timespec const *now)
   3084  1.1  christos {
   3085  1.1  christos   time_t Start;
   3086  1.1  christos   long int Start_ns;
   3087  1.1  christos   struct tm const *tmp;
   3088  1.1  christos   struct tm tm;
   3089  1.1  christos   struct tm tm0;
   3090  1.1  christos   parser_control pc;
   3091  1.1  christos   struct timespec gettime_buffer;
   3092  1.1  christos   unsigned char c;
   3093  1.1  christos   bool tz_was_altered = false;
   3094  1.1  christos   char *tz0 = NULL;
   3095  1.1  christos   char tz0buf[TZBUFSIZE];
   3096  1.1  christos   bool ok = true;
   3097  1.1  christos 
   3098  1.1  christos   if (! now)
   3099  1.1  christos     {
   3100  1.1  christos       gettime (&gettime_buffer);
   3101  1.1  christos       now = &gettime_buffer;
   3102  1.1  christos     }
   3103  1.1  christos 
   3104  1.1  christos   Start = now->tv_sec;
   3105  1.1  christos   Start_ns = now->tv_nsec;
   3106  1.1  christos 
   3107  1.1  christos   tmp = localtime (&now->tv_sec);
   3108  1.1  christos   if (! tmp)
   3109  1.1  christos     return false;
   3110  1.1  christos 
   3111  1.1  christos   while (c = *p, ISSPACE (c))
   3112  1.1  christos     p++;
   3113  1.1  christos 
   3114  1.1  christos   if (strncmp (p, "TZ=\"", 4) == 0)
   3115  1.1  christos     {
   3116  1.1  christos       char const *tzbase = p + 4;
   3117  1.1  christos       size_t tzsize = 1;
   3118  1.1  christos       char const *s;
   3119  1.1  christos 
   3120  1.1  christos       for (s = tzbase; *s; s++, tzsize++)
   3121  1.1  christos 	if (*s == '\\')
   3122  1.1  christos 	  {
   3123  1.1  christos 	    s++;
   3124  1.1  christos 	    if (! (*s == '\\' || *s == '"'))
   3125  1.1  christos 	      break;
   3126  1.1  christos 	  }
   3127  1.1  christos 	else if (*s == '"')
   3128  1.1  christos 	  {
   3129  1.1  christos 	    char *z;
   3130  1.1  christos 	    char *tz1;
   3131  1.1  christos 	    char tz1buf[TZBUFSIZE];
   3132  1.1  christos 	    bool large_tz = TZBUFSIZE < tzsize;
   3133  1.1  christos 	    bool setenv_ok;
   3134  1.1  christos 	    tz0 = get_tz (tz0buf);
   3135  1.1  christos 	    z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
   3136  1.1  christos 	    for (s = tzbase; *s != '"'; s++)
   3137  1.1  christos 	      *z++ = *(s += *s == '\\');
   3138  1.1  christos 	    *z = '\0';
   3139  1.1  christos 	    setenv_ok = setenv ("TZ", tz1, 1) == 0;
   3140  1.1  christos 	    if (large_tz)
   3141  1.1  christos 	      free (tz1);
   3142  1.1  christos 	    if (!setenv_ok)
   3143  1.1  christos 	      goto fail;
   3144  1.1  christos 	    tz_was_altered = true;
   3145  1.1  christos 	    p = s + 1;
   3146  1.1  christos 	  }
   3147  1.1  christos     }
   3148  1.1  christos 
   3149  1.1  christos   pc.input = p;
   3150  1.1  christos   pc.year.value = tmp->tm_year;
   3151  1.1  christos   pc.year.value += TM_YEAR_BASE;
   3152  1.1  christos   pc.year.digits = 0;
   3153  1.1  christos   pc.month = tmp->tm_mon + 1;
   3154  1.1  christos   pc.day = tmp->tm_mday;
   3155  1.1  christos   pc.hour = tmp->tm_hour;
   3156  1.1  christos   pc.minutes = tmp->tm_min;
   3157  1.1  christos   pc.seconds.tv_sec = tmp->tm_sec;
   3158  1.1  christos   pc.seconds.tv_nsec = Start_ns;
   3159  1.1  christos   tm.tm_isdst = tmp->tm_isdst;
   3160  1.1  christos 
   3161  1.1  christos   pc.meridian = MER24;
   3162  1.1  christos   pc.rel_ns = 0;
   3163  1.1  christos   pc.rel_seconds = 0;
   3164  1.1  christos   pc.rel_minutes = 0;
   3165  1.1  christos   pc.rel_hour = 0;
   3166  1.1  christos   pc.rel_day = 0;
   3167  1.1  christos   pc.rel_month = 0;
   3168  1.1  christos   pc.rel_year = 0;
   3169  1.1  christos   pc.timespec_seen = false;
   3170  1.1  christos   pc.rels_seen = false;
   3171  1.1  christos   pc.dates_seen = 0;
   3172  1.1  christos   pc.days_seen = 0;
   3173  1.1  christos   pc.times_seen = 0;
   3174  1.1  christos   pc.local_zones_seen = 0;
   3175  1.1  christos   pc.dsts_seen = 0;
   3176  1.1  christos   pc.zones_seen = 0;
   3177  1.1  christos 
   3178  1.1  christos #if HAVE_STRUCT_TM_TM_ZONE
   3179  1.1  christos   pc.local_time_zone_table[0].name = tmp->tm_zone;
   3180  1.1  christos   pc.local_time_zone_table[0].type = tLOCAL_ZONE;
   3181  1.1  christos   pc.local_time_zone_table[0].value = tmp->tm_isdst;
   3182  1.1  christos   pc.local_time_zone_table[1].name = NULL;
   3183  1.1  christos 
   3184  1.1  christos   /* Probe the names used in the next three calendar quarters, looking
   3185  1.1  christos      for a tm_isdst different from the one we already have.  */
   3186  1.1  christos   {
   3187  1.1  christos     int quarter;
   3188  1.1  christos     for (quarter = 1; quarter <= 3; quarter++)
   3189  1.1  christos       {
   3190  1.1  christos 	time_t probe = Start + quarter * (90 * 24 * 60 * 60);
   3191  1.1  christos 	struct tm const *probe_tm = localtime (&probe);
   3192  1.1  christos 	if (probe_tm && probe_tm->tm_zone
   3193  1.1  christos 	    && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
   3194  1.1  christos 	  {
   3195  1.1  christos 	      {
   3196  1.1  christos 		pc.local_time_zone_table[1].name = probe_tm->tm_zone;
   3197  1.1  christos 		pc.local_time_zone_table[1].type = tLOCAL_ZONE;
   3198  1.1  christos 		pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
   3199  1.1  christos 		pc.local_time_zone_table[2].name = NULL;
   3200  1.1  christos 	      }
   3201  1.1  christos 	    break;
   3202  1.1  christos 	  }
   3203  1.1  christos       }
   3204  1.1  christos   }
   3205  1.1  christos #else
   3206  1.1  christos #if HAVE_TZNAME
   3207  1.1  christos   {
   3208  1.1  christos # ifndef tzname
   3209  1.1  christos     extern char *tzname[];
   3210  1.1  christos # endif
   3211  1.1  christos     int i;
   3212  1.1  christos     for (i = 0; i < 2; i++)
   3213  1.1  christos       {
   3214  1.1  christos 	pc.local_time_zone_table[i].name = tzname[i];
   3215  1.1  christos 	pc.local_time_zone_table[i].type = tLOCAL_ZONE;
   3216  1.1  christos 	pc.local_time_zone_table[i].value = i;
   3217  1.1  christos       }
   3218  1.1  christos     pc.local_time_zone_table[i].name = NULL;
   3219  1.1  christos   }
   3220  1.1  christos #else
   3221  1.1  christos   pc.local_time_zone_table[0].name = NULL;
   3222  1.1  christos #endif
   3223  1.1  christos #endif
   3224  1.1  christos 
   3225  1.1  christos   if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
   3226  1.1  christos       && ! strcmp (pc.local_time_zone_table[0].name,
   3227  1.1  christos 		   pc.local_time_zone_table[1].name))
   3228  1.1  christos     {
   3229  1.1  christos       /* This locale uses the same abbrevation for standard and
   3230  1.1  christos 	 daylight times.  So if we see that abbreviation, we don't
   3231  1.1  christos 	 know whether it's daylight time.  */
   3232  1.1  christos       pc.local_time_zone_table[0].value = -1;
   3233  1.1  christos       pc.local_time_zone_table[1].name = NULL;
   3234  1.1  christos     }
   3235  1.1  christos 
   3236  1.1  christos   if (yyparse (&pc) != 0)
   3237  1.1  christos     goto fail;
   3238  1.1  christos 
   3239  1.1  christos   if (pc.timespec_seen)
   3240  1.1  christos     *result = pc.seconds;
   3241  1.1  christos   else
   3242  1.1  christos     {
   3243  1.1  christos       if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen
   3244  1.1  christos 	       | (pc.local_zones_seen + pc.zones_seen)))
   3245  1.1  christos 	goto fail;
   3246  1.1  christos 
   3247  1.1  christos       tm.tm_year = to_year (pc.year) - TM_YEAR_BASE;
   3248  1.1  christos       tm.tm_mon = pc.month - 1;
   3249  1.1  christos       tm.tm_mday = pc.day;
   3250  1.1  christos       if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
   3251  1.1  christos 	{
   3252  1.1  christos 	  tm.tm_hour = to_hour (pc.hour, pc.meridian);
   3253  1.1  christos 	  if (tm.tm_hour < 0)
   3254  1.1  christos 	    goto fail;
   3255  1.1  christos 	  tm.tm_min = pc.minutes;
   3256  1.1  christos 	  tm.tm_sec = pc.seconds.tv_sec;
   3257  1.1  christos 	}
   3258  1.1  christos       else
   3259  1.1  christos 	{
   3260  1.1  christos 	  tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
   3261  1.1  christos 	  pc.seconds.tv_nsec = 0;
   3262  1.1  christos 	}
   3263  1.1  christos 
   3264  1.1  christos       /* Let mktime deduce tm_isdst if we have an absolute time stamp.  */
   3265  1.1  christos       if (!pc.rels_seen)
   3266  1.1  christos 	tm.tm_isdst = -1;
   3267  1.1  christos 
   3268  1.1  christos       /* But if the input explicitly specifies local time with or without
   3269  1.1  christos 	 DST, give mktime that information.  */
   3270  1.1  christos       if (pc.local_zones_seen)
   3271  1.1  christos 	tm.tm_isdst = pc.local_isdst;
   3272  1.1  christos 
   3273  1.1  christos       tm0 = tm;
   3274  1.1  christos 
   3275  1.1  christos       Start = mktime (&tm);
   3276  1.1  christos 
   3277  1.1  christos       if (! mktime_ok (&tm0, &tm, Start))
   3278  1.1  christos 	{
   3279  1.1  christos 	  if (! pc.zones_seen)
   3280  1.1  christos 	    goto fail;
   3281  1.1  christos 	  else
   3282  1.1  christos 	    {
   3283  1.1  christos 	      /* Guard against falsely reporting errors near the time_t
   3284  1.1  christos 		 boundaries when parsing times in other time zones.  For
   3285  1.1  christos 		 example, suppose the input string "1969-12-31 23:00:00 -0100",
   3286  1.1  christos 		 the current time zone is 8 hours ahead of UTC, and the min
   3287  1.1  christos 		 time_t value is 1970-01-01 00:00:00 UTC.  Then the min
   3288  1.1  christos 		 localtime value is 1970-01-01 08:00:00, and mktime will
   3289  1.1  christos 		 therefore fail on 1969-12-31 23:00:00.  To work around the
   3290  1.1  christos 		 problem, set the time zone to 1 hour behind UTC temporarily
   3291  1.1  christos 		 by setting TZ="XXX1:00" and try mktime again.  */
   3292  1.1  christos 
   3293  1.1  christos 	      long int time_zone = pc.time_zone;
   3294  1.1  christos 	      long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone;
   3295  1.1  christos 	      long int abs_time_zone_hour = abs_time_zone / 60;
   3296  1.1  christos 	      int abs_time_zone_min = abs_time_zone % 60;
   3297  1.1  christos 	      char tz1buf[sizeof "XXX+0:00"
   3298  1.1  christos 			  + sizeof pc.time_zone * CHAR_BIT / 3];
   3299  1.1  christos 	      if (!tz_was_altered)
   3300  1.1  christos 		tz0 = get_tz (tz0buf);
   3301  1.1  christos 	      sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0),
   3302  1.1  christos 		       abs_time_zone_hour, abs_time_zone_min);
   3303  1.1  christos 	      if (setenv ("TZ", tz1buf, 1) != 0)
   3304  1.1  christos 		goto fail;
   3305  1.1  christos 	      tz_was_altered = true;
   3306  1.1  christos 	      tm = tm0;
   3307  1.1  christos 	      Start = mktime (&tm);
   3308  1.1  christos 	      if (! mktime_ok (&tm0, &tm, Start))
   3309  1.1  christos 		goto fail;
   3310  1.1  christos 	    }
   3311  1.1  christos 	}
   3312  1.1  christos 
   3313  1.1  christos       if (pc.days_seen && ! pc.dates_seen)
   3314  1.1  christos 	{
   3315  1.1  christos 	  tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
   3316  1.1  christos 			 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
   3317  1.1  christos 	  tm.tm_isdst = -1;
   3318  1.1  christos 	  Start = mktime (&tm);
   3319  1.1  christos 	  if (Start == (time_t) -1)
   3320  1.1  christos 	    goto fail;
   3321  1.1  christos 	}
   3322  1.1  christos 
   3323  1.1  christos       if (pc.zones_seen)
   3324  1.1  christos 	{
   3325  1.1  christos 	  long int delta = pc.time_zone * 60;
   3326  1.1  christos 	  time_t t1;
   3327  1.1  christos #ifdef HAVE_TM_GMTOFF
   3328  1.1  christos 	  delta -= tm.tm_gmtoff;
   3329  1.1  christos #else
   3330  1.1  christos 	  time_t t = Start;
   3331  1.1  christos 	  struct tm const *gmt = gmtime (&t);
   3332  1.1  christos 	  if (! gmt)
   3333  1.1  christos 	    goto fail;
   3334  1.1  christos 	  delta -= tm_diff (&tm, gmt);
   3335  1.1  christos #endif
   3336  1.1  christos 	  t1 = Start - delta;
   3337  1.1  christos 	  if ((Start < t1) != (delta < 0))
   3338  1.1  christos 	    goto fail;	/* time_t overflow */
   3339  1.1  christos 	  Start = t1;
   3340  1.1  christos 	}
   3341  1.1  christos 
   3342  1.1  christos       /* Add relative date.  */
   3343  1.1  christos       if (pc.rel_year | pc.rel_month | pc.rel_day)
   3344  1.1  christos 	{
   3345  1.1  christos 	  int year = tm.tm_year + pc.rel_year;
   3346  1.1  christos 	  int month = tm.tm_mon + pc.rel_month;
   3347  1.1  christos 	  int day = tm.tm_mday + pc.rel_day;
   3348  1.1  christos 	  if (((year < tm.tm_year) ^ (pc.rel_year < 0))
   3349  1.1  christos 	      | ((month < tm.tm_mon) ^ (pc.rel_month < 0))
   3350  1.1  christos 	      | ((day < tm.tm_mday) ^ (pc.rel_day < 0)))
   3351  1.1  christos 	    goto fail;
   3352  1.1  christos 	  tm.tm_year = year;
   3353  1.1  christos 	  tm.tm_mon = month;
   3354  1.1  christos 	  tm.tm_mday = day;
   3355  1.1  christos 	  Start = mktime (&tm);
   3356  1.1  christos 	  if (Start == (time_t) -1)
   3357  1.1  christos 	    goto fail;
   3358  1.1  christos 	}
   3359  1.1  christos 
   3360  1.1  christos       /* Add relative hours, minutes, and seconds.  On hosts that support
   3361  1.1  christos 	 leap seconds, ignore the possibility of leap seconds; e.g.,
   3362  1.1  christos 	 "+ 10 minutes" adds 600 seconds, even if one of them is a
   3363  1.1  christos 	 leap second.  Typically this is not what the user wants, but it's
   3364  1.1  christos 	 too hard to do it the other way, because the time zone indicator
   3365  1.1  christos 	 must be applied before relative times, and if mktime is applied
   3366  1.1  christos 	 again the time zone will be lost.  */
   3367  1.1  christos       {
   3368  1.1  christos 	long int sum_ns = pc.seconds.tv_nsec + pc.rel_ns;
   3369  1.1  christos 	long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION;
   3370  1.1  christos 	time_t t0 = Start;
   3371  1.1  christos 	long int d1 = 60 * 60 * pc.rel_hour;
   3372  1.1  christos 	time_t t1 = t0 + d1;
   3373  1.1  christos 	long int d2 = 60 * pc.rel_minutes;
   3374  1.1  christos 	time_t t2 = t1 + d2;
   3375  1.1  christos 	long int d3 = pc.rel_seconds;
   3376  1.1  christos 	time_t t3 = t2 + d3;
   3377  1.1  christos 	long int d4 = (sum_ns - normalized_ns) / BILLION;
   3378  1.1  christos 	time_t t4 = t3 + d4;
   3379  1.1  christos 
   3380  1.1  christos 	if ((d1 / (60 * 60) ^ pc.rel_hour)
   3381  1.1  christos 	    | (d2 / 60 ^ pc.rel_minutes)
   3382  1.1  christos 	    | ((t1 < t0) ^ (d1 < 0))
   3383  1.1  christos 	    | ((t2 < t1) ^ (d2 < 0))
   3384  1.1  christos 	    | ((t3 < t2) ^ (d3 < 0))
   3385  1.1  christos 	    | ((t4 < t3) ^ (d4 < 0)))
   3386  1.1  christos 	  goto fail;
   3387  1.1  christos 
   3388  1.1  christos 	result->tv_sec = t4;
   3389  1.1  christos 	result->tv_nsec = normalized_ns;
   3390  1.1  christos       }
   3391  1.1  christos     }
   3392  1.1  christos 
   3393  1.1  christos   goto done;
   3394  1.1  christos 
   3395  1.1  christos  fail:
   3396  1.1  christos   ok = false;
   3397  1.1  christos  done:
   3398  1.1  christos   if (tz_was_altered)
   3399  1.1  christos     ok &= (tz0 ? setenv ("TZ", tz0, 1) : unsetenv ("TZ")) == 0;
   3400  1.1  christos   if (tz0 != tz0buf)
   3401  1.1  christos     free (tz0);
   3402  1.1  christos   return ok;
   3403  1.1  christos }
   3404  1.1  christos 
   3405  1.1  christos #if TEST
   3406  1.1  christos 
   3407  1.1  christos int
   3408  1.1  christos main (int ac, char **av)
   3409  1.1  christos {
   3410  1.1  christos   char buff[BUFSIZ];
   3411  1.1  christos 
   3412  1.1  christos   printf ("Enter date, or blank line to exit.\n\t> ");
   3413  1.1  christos   fflush (stdout);
   3414  1.1  christos 
   3415  1.1  christos   buff[BUFSIZ - 1] = '\0';
   3416  1.1  christos   while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
   3417  1.1  christos     {
   3418  1.1  christos       struct timespec d;
   3419  1.1  christos       struct tm const *tm;
   3420  1.1  christos       if (! get_date (&d, buff, NULL))
   3421  1.1  christos 	printf ("Bad format - couldn't convert.\n");
   3422  1.1  christos       else if (! (tm = localtime (&d.tv_sec)))
   3423  1.1  christos 	{
   3424  1.1  christos 	  long int sec = d.tv_sec;
   3425  1.1  christos 	  printf ("localtime (%ld) failed\n", sec);
   3426  1.1  christos 	}
   3427  1.1  christos       else
   3428  1.1  christos 	{
   3429  1.1  christos 	  int ns = d.tv_nsec;
   3430  1.1  christos 	  printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n",
   3431  1.1  christos 		  tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
   3432  1.1  christos 		  tm->tm_hour, tm->tm_min, tm->tm_sec, ns);
   3433  1.1  christos 	}
   3434  1.1  christos       printf ("\t> ");
   3435  1.1  christos       fflush (stdout);
   3436  1.1  christos     }
   3437  1.1  christos   return 0;
   3438                }
   3439                #endif /* TEST */
   3440                
   3441