home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / useful / dist / gnu / fileutils / build / lib / posixtm.c < prev   
Encoding:
C/C++ Source or Header  |  1993-08-31  |  22.5 KB  |  961 lines

  1.  
  2. /*  A Bison parser, made from ./posixtm.y with Bison version GNU Bison version 1.21
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    DIGIT    258
  8.  
  9. #line 19 "./posixtm.y"
  10.  
  11. #ifdef __GNUC__
  12. #define alloca __builtin_alloca
  13. #else
  14. #ifdef HAVE_ALLOCA_H
  15. #include <alloca.h>
  16. #else
  17. #ifdef _AIX
  18.  #pragma alloca
  19. #else
  20. char *alloca ();
  21. #endif
  22. #endif
  23. #endif
  24.  
  25. #include <stdio.h>
  26. #include <sys/types.h>
  27.  
  28. #ifdef TM_IN_SYS_TIME
  29. #include <sys/time.h>
  30. #else
  31. #include <time.h>
  32. #endif
  33.  
  34. /* Some old versions of bison generate parsers that use bcopy.
  35.    That loses on systems that don't provide the function, so we have
  36.    to redefine it here.  */
  37. #if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
  38. #define bcopy(from, to, len) memcpy ((to), (from), (len))
  39. #endif
  40.  
  41. #define YYDEBUG 1
  42.  
  43. /* Lexical analyzer's current scan position in the input string. */
  44. static char *curpos;
  45.  
  46. /* The return value. */
  47. static struct tm t;
  48.  
  49. time_t mktime ();
  50.  
  51. #define zzparse posixtime_zzparse
  52. static int zzlex ();
  53. static int zzerror ();
  54.  
  55. #ifndef YYLTYPE
  56. typedef
  57.   struct zzltype
  58.     {
  59.       int timestamp;
  60.       int first_line;
  61.       int first_column;
  62.       int last_line;
  63.       int last_column;
  64.       char *text;
  65.    }
  66.   zzltype;
  67.  
  68. #define YYLTYPE zzltype
  69. #endif
  70.  
  71. #ifndef YYSTYPE
  72. #define YYSTYPE int
  73. #endif
  74. #include <stdio.h>
  75.  
  76. #ifndef __cplusplus
  77. #ifndef __STDC__
  78. #define const
  79. #endif
  80. #endif
  81.  
  82.  
  83.  
  84. #define    YYFINAL        15
  85. #define    YYFLAG        -32768
  86. #define    YYNTBASE    5
  87.  
  88. #define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? zztranslate[x] : 9)
  89.  
  90. static const char zztranslate[] = {     0,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     4,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     1,     2,     3
  117. };
  118.  
  119. #if YYDEBUG != 0
  120. static const short zzprhs[] = {     0,
  121.      0,     7,     9,    12,    13,    14,    17
  122. };
  123.  
  124. static const short zzrhs[] = {     8,
  125.      8,     8,     8,     6,     7,     0,     8,     0,     8,     8,
  126.      0,     0,     0,     4,     8,     0,     3,     3,     0
  127. };
  128.  
  129. #endif
  130.  
  131. #if YYDEBUG != 0
  132. static const short zzrline[] = { 0,
  133.     68,    97,   104,   111,   122,   125,   134
  134. };
  135.  
  136. static const char * const zztname[] = {   "$","error","$illegal.","DIGIT","'.'",
  137. "date","year","seconds","digitpair",""
  138. };
  139. #endif
  140.  
  141. static const short zzr1[] = {     0,
  142.      5,     6,     6,     6,     7,     7,     8
  143. };
  144.  
  145. static const short zzr2[] = {     0,
  146.      6,     1,     2,     0,     0,     2,     2
  147. };
  148.  
  149. static const short zzdefact[] = {     0,
  150.      0,     0,     7,     0,     0,     4,     5,     2,     0,     1,
  151.      3,     6,     0,     0,     0
  152. };
  153.  
  154. static const short zzdefgoto[] = {    13,
  155.      7,    10,     2
  156. };
  157.  
  158. static const short zzpact[] = {     2,
  159.      5,     2,-32768,     2,     2,     2,    -3,     2,     2,-32768,
  160. -32768,-32768,     9,    10,-32768
  161. };
  162.  
  163. static const short zzpgoto[] = {-32768,
  164. -32768,-32768,    -2
  165. };
  166.  
  167.  
  168. #define    YYLAST        10
  169.  
  170.  
  171. static const short zztable[] = {     4,
  172.      9,     5,     6,     8,     1,    11,    12,     3,    14,    15
  173. };
  174.  
  175. static const short zzcheck[] = {     2,
  176.      4,     4,     5,     6,     3,     8,     9,     3,     0,     0
  177. };
  178. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  179. #line 3 "/usr/lib/bison.simple"
  180.  
  181. /* Skeleton output parser for bison,
  182.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  183.  
  184.    This program is free software; you can redistribute it and/or modify
  185.    it under the terms of the GNU General Public License as published by
  186.    the Free Software Foundation; either version 1, or (at your option)
  187.    any later version.
  188.  
  189.    This program is distributed in the hope that it will be useful,
  190.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  191.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  192.    GNU General Public License for more details.
  193.  
  194.    You should have received a copy of the GNU General Public License
  195.    along with this program; if not, write to the Free Software
  196.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  197.  
  198.  
  199. #ifndef alloca
  200. #ifdef __GNUC__
  201. #define alloca __builtin_alloca
  202. #else /* not GNU C.  */
  203. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  204. #include <alloca.h>
  205. #else /* not sparc */
  206. #if defined (MSDOS) && !defined (__TURBOC__)
  207. #include <malloc.h>
  208. #else /* not MSDOS, or __TURBOC__ */
  209. #if defined(_AIX)
  210. #include <malloc.h>
  211.  #pragma alloca
  212. #else /* not MSDOS, __TURBOC__, or _AIX */
  213. #ifdef __hpux
  214. #ifdef __cplusplus
  215. extern "C" {
  216. void *alloca (unsigned int);
  217. };
  218. #else /* not __cplusplus */
  219. void *alloca (unsigned int);
  220. #endif /* not __cplusplus */
  221. #endif /* __hpux */
  222. #endif /* not _AIX */
  223. #endif /* not MSDOS, or __TURBOC__ */
  224. #endif /* not sparc.  */
  225. #endif /* not GNU C.  */
  226. #endif /* alloca not defined.  */
  227.  
  228. /* This is the parser code that is written into each bison parser
  229.   when the %semantic_parser declaration is not specified in the grammar.
  230.   It was written by Richard Stallman by simplifying the hairy parser
  231.   used when %semantic_parser is specified.  */
  232.  
  233. /* Note: there must be only one dollar sign in this file.
  234.    It is replaced by the list of actions, each action
  235.    as one case of the switch.  */
  236.  
  237. #define zzerrok        (zzerrstatus = 0)
  238. #define zzclearin    (zzchar = YYEMPTY)
  239. #define YYEMPTY        -2
  240. #define YYEOF        0
  241. #define YYACCEPT    return(0)
  242. #define YYABORT     return(1)
  243. #define YYERROR        goto zzerrlab1
  244. /* Like YYERROR except do call zzerror.
  245.    This remains here temporarily to ease the
  246.    transition to the new meaning of YYERROR, for GCC.
  247.    Once GCC version 2 has supplanted version 1, this can go.  */
  248. #define YYFAIL        goto zzerrlab
  249. #define YYRECOVERING()  (!!zzerrstatus)
  250. #define YYBACKUP(token, value) \
  251. do                                \
  252.   if (zzchar == YYEMPTY && zzlen == 1)                \
  253.     { zzchar = (token), zzlval = (value);            \
  254.       zzchar1 = YYTRANSLATE (zzchar);                \
  255.       YYPOPSTACK;                        \
  256.       goto zzbackup;                        \
  257.     }                                \
  258.   else                                \
  259.     { zzerror ("syntax error: cannot back up"); YYERROR; }    \
  260. while (0)
  261.  
  262. #define YYTERROR    1
  263. #define YYERRCODE    256
  264.  
  265. #ifndef YYPURE
  266. #define YYLEX        zzlex()
  267. #endif
  268.  
  269. #ifdef YYPURE
  270. #ifdef YYLSP_NEEDED
  271. #define YYLEX        zzlex(&zzlval, &zzlloc)
  272. #else
  273. #define YYLEX        zzlex(&zzlval)
  274. #endif
  275. #endif
  276.  
  277. /* If nonreentrant, generate the variables here */
  278.  
  279. #ifndef YYPURE
  280.  
  281. int    zzchar;            /*  the lookahead symbol        */
  282. YYSTYPE    zzlval;            /*  the semantic value of the        */
  283.                 /*  lookahead symbol            */
  284.  
  285. #ifdef YYLSP_NEEDED
  286. YYLTYPE zzlloc;            /*  location data for the lookahead    */
  287.                 /*  symbol                */
  288. #endif
  289.  
  290. int zznerrs;            /*  number of parse errors so far       */
  291. #endif  /* not YYPURE */
  292.  
  293. #if YYDEBUG != 0
  294. int zzdebug;            /*  nonzero means print parse trace    */
  295. /* Since this is uninitialized, it does not stop multiple parsers
  296.    from coexisting.  */
  297. #endif
  298.  
  299. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  300.  
  301. #ifndef    YYINITDEPTH
  302. #define YYINITDEPTH 200
  303. #endif
  304.  
  305. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  306.     (effective only if the built-in stack extension method is used).  */
  307.  
  308. #if YYMAXDEPTH == 0
  309. #undef YYMAXDEPTH
  310. #endif
  311.  
  312. #ifndef YYMAXDEPTH
  313. #define YYMAXDEPTH 10000
  314. #endif
  315.  
  316. /* Prevent warning if -Wstrict-prototypes.  */
  317. #ifdef __GNUC__
  318. int zzparse (void);
  319. #endif
  320.  
  321. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  322. #define __zz_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  323. #else                /* not GNU C or C++ */
  324. #ifndef __cplusplus
  325.  
  326. /* This is the most reliable way to avoid incompatibilities
  327.    in available built-in functions on various systems.  */
  328. static void
  329. __zz_bcopy (from, to, count)
  330.      char *from;
  331.      char *to;
  332.      int count;
  333. {
  334.   register char *f = from;
  335.   register char *t = to;
  336.   register int i = count;
  337.  
  338.   while (i-- > 0)
  339.     *t++ = *f++;
  340. }
  341.  
  342. #else /* __cplusplus */
  343.  
  344. /* This is the most reliable way to avoid incompatibilities
  345.    in available built-in functions on various systems.  */
  346. static void
  347. __zz_bcopy (char *from, char *to, int count)
  348. {
  349.   register char *f = from;
  350.   register char *t = to;
  351.   register int i = count;
  352.  
  353.   while (i-- > 0)
  354.     *t++ = *f++;
  355. }
  356.  
  357. #endif
  358. #endif
  359.  
  360. #line 184 "/usr/lib/bison.simple"
  361. int
  362. zzparse()
  363. {
  364.   register int zzstate;
  365.   register int zzn;
  366.   register short *zzssp;
  367.   register YYSTYPE *zzvsp;
  368.   int zzerrstatus;    /*  number of tokens to shift before error messages enabled */
  369.   int zzchar1;        /*  lookahead token as an internal (translated) token number */
  370.  
  371.   short    zzssa[YYINITDEPTH];    /*  the state stack            */
  372.   YYSTYPE zzvsa[YYINITDEPTH];    /*  the semantic value stack        */
  373.  
  374.   short *zzss = zzssa;        /*  refer to the stacks thru separate pointers */
  375.   YYSTYPE *zzvs = zzvsa;    /*  to allow zzoverflow to reallocate them elsewhere */
  376.  
  377. #ifdef YYLSP_NEEDED
  378.   YYLTYPE zzlsa[YYINITDEPTH];    /*  the location stack            */
  379.   YYLTYPE *zzls = zzlsa;
  380.   YYLTYPE *zzlsp;
  381.  
  382. #define YYPOPSTACK   (zzvsp--, zzssp--, zzlsp--)
  383. #else
  384. #define YYPOPSTACK   (zzvsp--, zzssp--)
  385. #endif
  386.  
  387.   int zzstacksize = YYINITDEPTH;
  388.  
  389. #ifdef YYPURE
  390.   int zzchar;
  391.   YYSTYPE zzlval;
  392.   int zznerrs;
  393. #ifdef YYLSP_NEEDED
  394.   YYLTYPE zzlloc;
  395. #endif
  396. #endif
  397.  
  398.   YYSTYPE zzval;        /*  the variable used to return        */
  399.                 /*  semantic values from the action    */
  400.                 /*  routines                */
  401.  
  402.   int zzlen;
  403.  
  404. #if YYDEBUG != 0
  405.   if (zzdebug)
  406.     fprintf(stderr, "Starting parse\n");
  407. #endif
  408.  
  409.   zzstate = 0;
  410.   zzerrstatus = 0;
  411.   zznerrs = 0;
  412.   zzchar = YYEMPTY;        /* Cause a token to be read.  */
  413.  
  414.   /* Initialize stack pointers.
  415.      Waste one element of value and location stack
  416.      so that they stay on the same level as the state stack.
  417.      The wasted elements are never initialized.  */
  418.  
  419.   zzssp = zzss - 1;
  420.   zzvsp = zzvs;
  421. #ifdef YYLSP_NEEDED
  422.   zzlsp = zzls;
  423. #endif
  424.  
  425. /* Push a new state, which is found in  zzstate  .  */
  426. /* In all cases, when you get here, the value and location stacks
  427.    have just been pushed. so pushing a state here evens the stacks.  */
  428. zznewstate:
  429.  
  430.   *++zzssp = zzstate;
  431.  
  432.   if (zzssp >= zzss + zzstacksize - 1)
  433.     {
  434.       /* Give user a chance to reallocate the stack */
  435.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  436.       YYSTYPE *zzvs1 = zzvs;
  437.       short *zzss1 = zzss;
  438. #ifdef YYLSP_NEEDED
  439.       YYLTYPE *zzls1 = zzls;
  440. #endif
  441.  
  442.       /* Get the current used size of the three stacks, in elements.  */
  443.       int size = zzssp - zzss + 1;
  444.  
  445. #ifdef zzoverflow
  446.       /* Each stack pointer address is followed by the size of
  447.      the data in use in that stack, in bytes.  */
  448.       zzoverflow("parser stack overflow",
  449.          &zzss1, size * sizeof (*zzssp),
  450.          &zzvs1, size * sizeof (*zzvsp),
  451. #ifdef YYLSP_NEEDED
  452.          &zzls1, size * sizeof (*zzlsp),
  453. #endif
  454.          &zzstacksize);
  455.  
  456.       zzss = zzss1; zzvs = zzvs1;
  457. #ifdef YYLSP_NEEDED
  458.       zzls = zzls1;
  459. #endif
  460. #else /* no zzoverflow */
  461.       /* Extend the stack our own way.  */
  462.       if (zzstacksize >= YYMAXDEPTH)
  463.     {
  464.       zzerror("parser stack overflow");
  465.       return 2;
  466.     }
  467.       zzstacksize *= 2;
  468.       if (zzstacksize > YYMAXDEPTH)
  469.     zzstacksize = YYMAXDEPTH;
  470.       zzss = (short *) alloca (zzstacksize * sizeof (*zzssp));
  471.       __zz_bcopy ((char *)zzss1, (char *)zzss, size * sizeof (*zzssp));
  472.       zzvs = (YYSTYPE *) alloca (zzstacksize * sizeof (*zzvsp));
  473.       __zz_bcopy ((char *)zzvs1, (char *)zzvs, size * sizeof (*zzvsp));
  474. #ifdef YYLSP_NEEDED
  475.       zzls = (YYLTYPE *) alloca (zzstacksize * sizeof (*zzlsp));
  476.       __zz_bcopy ((char *)zzls1, (char *)zzls, size * sizeof (*zzlsp));
  477. #endif
  478. #endif /* no zzoverflow */
  479.  
  480.       zzssp = zzss + size - 1;
  481.       zzvsp = zzvs + size - 1;
  482. #ifdef YYLSP_NEEDED
  483.       zzlsp = zzls + size - 1;
  484. #endif
  485.  
  486. #if YYDEBUG != 0
  487.       if (zzdebug)
  488.     fprintf(stderr, "Stack size increased to %d\n", zzstacksize);
  489. #endif
  490.  
  491.       if (zzssp >= zzss + zzstacksize - 1)
  492.     YYABORT;
  493.     }
  494.  
  495. #if YYDEBUG != 0
  496.   if (zzdebug)
  497.     fprintf(stderr, "Entering state %d\n", zzstate);
  498. #endif
  499.  
  500.   goto zzbackup;
  501.  zzbackup:
  502.  
  503. /* Do appropriate processing given the current state.  */
  504. /* Read a lookahead token if we need one and don't already have one.  */
  505. /* zzresume: */
  506.  
  507.   /* First try to decide what to do without reference to lookahead token.  */
  508.  
  509.   zzn = zzpact[zzstate];
  510.   if (zzn == YYFLAG)
  511.     goto zzdefault;
  512.  
  513.   /* Not known => get a lookahead token if don't already have one.  */
  514.  
  515.   /* zzchar is either YYEMPTY or YYEOF
  516.      or a valid token in external form.  */
  517.  
  518.   if (zzchar == YYEMPTY)
  519.     {
  520. #if YYDEBUG != 0
  521.       if (zzdebug)
  522.     fprintf(stderr, "Reading a token: ");
  523. #endif
  524.       zzchar = YYLEX;
  525.     }
  526.  
  527.   /* Convert token to internal form (in zzchar1) for indexing tables with */
  528.  
  529.   if (zzchar <= 0)        /* This means end of input. */
  530.     {
  531.       zzchar1 = 0;
  532.       zzchar = YYEOF;        /* Don't call YYLEX any more */
  533.  
  534. #if YYDEBUG != 0
  535.       if (zzdebug)
  536.     fprintf(stderr, "Now at end of input.\n");
  537. #endif
  538.     }
  539.   else
  540.     {
  541.       zzchar1 = YYTRANSLATE(zzchar);
  542.  
  543. #if YYDEBUG != 0
  544.       if (zzdebug)
  545.     {
  546.       fprintf (stderr, "Next token is %d (%s", zzchar, zztname[zzchar1]);
  547.       /* Give the individual parser a way to print the precise meaning
  548.          of a token, for further debugging info.  */
  549. #ifdef YYPRINT
  550.       YYPRINT (stderr, zzchar, zzlval);
  551. #endif
  552.       fprintf (stderr, ")\n");
  553.     }
  554. #endif
  555.     }
  556.  
  557.   zzn += zzchar1;
  558.   if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != zzchar1)
  559.     goto zzdefault;
  560.  
  561.   zzn = zztable[zzn];
  562.  
  563.   /* zzn is what to do for this token type in this state.
  564.      Negative => reduce, -zzn is rule number.
  565.      Positive => shift, zzn is new state.
  566.        New state is final state => don't bother to shift,
  567.        just return success.
  568.      0, or most negative number => error.  */
  569.  
  570.   if (zzn < 0)
  571.     {
  572.       if (zzn == YYFLAG)
  573.     goto zzerrlab;
  574.       zzn = -zzn;
  575.       goto zzreduce;
  576.     }
  577.   else if (zzn == 0)
  578.     goto zzerrlab;
  579.  
  580.   if (zzn == YYFINAL)
  581.     YYACCEPT;
  582.  
  583.   /* Shift the lookahead token.  */
  584.  
  585. #if YYDEBUG != 0
  586.   if (zzdebug)
  587.     fprintf(stderr, "Shifting token %d (%s), ", zzchar, zztname[zzchar1]);
  588. #endif
  589.  
  590.   /* Discard the token being shifted unless it is eof.  */
  591.   if (zzchar != YYEOF)
  592.     zzchar = YYEMPTY;
  593.  
  594.   *++zzvsp = zzlval;
  595. #ifdef YYLSP_NEEDED
  596.   *++zzlsp = zzlloc;
  597. #endif
  598.  
  599.   /* count tokens shifted since error; after three, turn off error status.  */
  600.   if (zzerrstatus) zzerrstatus--;
  601.  
  602.   zzstate = zzn;
  603.   goto zznewstate;
  604.  
  605. /* Do the default action for the current state.  */
  606. zzdefault:
  607.  
  608.   zzn = zzdefact[zzstate];
  609.   if (zzn == 0)
  610.     goto zzerrlab;
  611.  
  612. /* Do a reduction.  zzn is the number of a rule to reduce with.  */
  613. zzreduce:
  614.   zzlen = zzr2[zzn];
  615.   zzval = zzvsp[1-zzlen]; /* implement default value of the action */
  616.  
  617. #if YYDEBUG != 0
  618.   if (zzdebug)
  619.     {
  620.       int i;
  621.  
  622.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  623.            zzn, zzrline[zzn]);
  624.  
  625.       /* Print the symbols being reduced, and their result.  */
  626.       for (i = zzprhs[zzn]; zzrhs[i] > 0; i++)
  627.     fprintf (stderr, "%s ", zztname[zzrhs[i]]);
  628.       fprintf (stderr, " -> %s\n", zztname[zzr1[zzn]]);
  629.     }
  630. #endif
  631.  
  632.  
  633.   switch (zzn) {
  634.  
  635. case 1:
  636. #line 74 "./posixtm.y"
  637. {
  638.              if (zzvsp[-5] >= 1 && zzvsp[-5] <= 12)
  639.            t.tm_mon = zzvsp[-5] - 1;
  640.          else {
  641.            YYABORT;
  642.          }
  643.          if (zzvsp[-4] >= 1 && zzvsp[-4] <= 31)
  644.            t.tm_mday = zzvsp[-4];
  645.          else {
  646.            YYABORT;
  647.          }
  648.          if (zzvsp[-3] >= 0 && zzvsp[-3] <= 23)
  649.            t.tm_hour = zzvsp[-3];
  650.          else {
  651.            YYABORT;
  652.          }
  653.          if (zzvsp[-2] >= 0 && zzvsp[-2] <= 59)
  654.            t.tm_min = zzvsp[-2];
  655.          else {
  656.            YYABORT;
  657.          }
  658.            ;
  659.     break;}
  660. case 2:
  661. #line 97 "./posixtm.y"
  662. {
  663.                    t.tm_year = zzvsp[0];
  664.            /* Deduce the century based on the year.
  665.               See POSIX.2 section 4.63.3.  */
  666.            if (zzvsp[0] <= 68)
  667.              t.tm_year += 100;
  668.          ;
  669.     break;}
  670. case 3:
  671. #line 104 "./posixtm.y"
  672. {
  673.                             t.tm_year = zzvsp[-1] * 100 + zzvsp[0];
  674.                 if (t.tm_year < 1900) {
  675.                   YYABORT;
  676.                 } else
  677.                   t.tm_year -= 1900;
  678.               ;
  679.     break;}
  680. case 4:
  681. #line 111 "./posixtm.y"
  682. {
  683.                     time_t now;
  684.             struct tm *tmp;
  685.  
  686.                     /* Use current year.  */
  687.                     time (&now);
  688.             tmp = localtime (&now);
  689.             t.tm_year = tmp->tm_year;
  690.           ;
  691.     break;}
  692. case 5:
  693. #line 122 "./posixtm.y"
  694. {
  695.                         t.tm_sec = 0;
  696.               ;
  697.     break;}
  698. case 6:
  699. #line 125 "./posixtm.y"
  700. {
  701.                       if (zzvsp[0] >= 0 && zzvsp[0] <= 61)
  702.                 t.tm_sec = zzvsp[0];
  703.               else {
  704.                 YYABORT;
  705.               }
  706.             ;
  707.     break;}
  708. case 7:
  709. #line 134 "./posixtm.y"
  710. {
  711.                           zzval = zzvsp[-1] * 10 + zzvsp[0];
  712.             ;
  713.     break;}
  714. }
  715.    /* the action file gets copied in in place of this dollarsign */
  716. #line 457 "/usr/lib/bison.simple"
  717.  
  718.   zzvsp -= zzlen;
  719.   zzssp -= zzlen;
  720. #ifdef YYLSP_NEEDED
  721.   zzlsp -= zzlen;
  722. #endif
  723.  
  724. #if YYDEBUG != 0
  725.   if (zzdebug)
  726.     {
  727.       short *ssp1 = zzss - 1;
  728.       fprintf (stderr, "state stack now");
  729.       while (ssp1 != zzssp)
  730.     fprintf (stderr, " %d", *++ssp1);
  731.       fprintf (stderr, "\n");
  732.     }
  733. #endif
  734.  
  735.   *++zzvsp = zzval;
  736.  
  737. #ifdef YYLSP_NEEDED
  738.   zzlsp++;
  739.   if (zzlen == 0)
  740.     {
  741.       zzlsp->first_line = zzlloc.first_line;
  742.       zzlsp->first_column = zzlloc.first_column;
  743.       zzlsp->last_line = (zzlsp-1)->last_line;
  744.       zzlsp->last_column = (zzlsp-1)->last_column;
  745.       zzlsp->text = 0;
  746.     }
  747.   else
  748.     {
  749.       zzlsp->last_line = (zzlsp+zzlen-1)->last_line;
  750.       zzlsp->last_column = (zzlsp+zzlen-1)->last_column;
  751.     }
  752. #endif
  753.  
  754.   /* Now "shift" the result of the reduction.
  755.      Determine what state that goes to,
  756.      based on the state we popped back to
  757.      and the rule number reduced by.  */
  758.  
  759.   zzn = zzr1[zzn];
  760.  
  761.   zzstate = zzpgoto[zzn - YYNTBASE] + *zzssp;
  762.   if (zzstate >= 0 && zzstate <= YYLAST && zzcheck[zzstate] == *zzssp)
  763.     zzstate = zztable[zzstate];
  764.   else
  765.     zzstate = zzdefgoto[zzn - YYNTBASE];
  766.  
  767.   goto zznewstate;
  768.  
  769. zzerrlab:   /* here on detecting error */
  770.  
  771.   if (! zzerrstatus)
  772.     /* If not already recovering from an error, report this error.  */
  773.     {
  774.       ++zznerrs;
  775.  
  776. #ifdef YYERROR_VERBOSE
  777.       zzn = zzpact[zzstate];
  778.  
  779.       if (zzn > YYFLAG && zzn < YYLAST)
  780.     {
  781.       int size = 0;
  782.       char *msg;
  783.       int x, count;
  784.  
  785.       count = 0;
  786.       /* Start X at -zzn if nec to avoid negative indexes in zzcheck.  */
  787.       for (x = (zzn < 0 ? -zzn : 0);
  788.            x < (sizeof(zztname) / sizeof(char *)); x++)
  789.         if (zzcheck[x + zzn] == x)
  790.           size += strlen(zztname[x]) + 15, count++;
  791.       msg = (char *) malloc(size + 15);
  792.       if (msg != 0)
  793.         {
  794.           strcpy(msg, "parse error");
  795.  
  796.           if (count < 5)
  797.         {
  798.           count = 0;
  799.           for (x = (zzn < 0 ? -zzn : 0);
  800.                x < (sizeof(zztname) / sizeof(char *)); x++)
  801.             if (zzcheck[x + zzn] == x)
  802.               {
  803.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  804.             strcat(msg, zztname[x]);
  805.             strcat(msg, "'");
  806.             count++;
  807.               }
  808.         }
  809.           zzerror(msg);
  810.           free(msg);
  811.         }
  812.       else
  813.         zzerror ("parse error; also virtual memory exceeded");
  814.     }
  815.       else
  816. #endif /* YYERROR_VERBOSE */
  817.     zzerror("parse error");
  818.     }
  819.  
  820.   goto zzerrlab1;
  821. zzerrlab1:   /* here on error raised explicitly by an action */
  822.  
  823.   if (zzerrstatus == 3)
  824.     {
  825.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  826.  
  827.       /* return failure if at end of input */
  828.       if (zzchar == YYEOF)
  829.     YYABORT;
  830.  
  831. #if YYDEBUG != 0
  832.       if (zzdebug)
  833.     fprintf(stderr, "Discarding token %d (%s).\n", zzchar, zztname[zzchar1]);
  834. #endif
  835.  
  836.       zzchar = YYEMPTY;
  837.     }
  838.  
  839.   /* Else will try to reuse lookahead token
  840.      after shifting the error token.  */
  841.  
  842.   zzerrstatus = 3;        /* Each real token shifted decrements this */
  843.  
  844.   goto zzerrhandle;
  845.  
  846. zzerrdefault:  /* current state does not do anything special for the error token. */
  847.  
  848. #if 0
  849.   /* This is wrong; only states that explicitly want error tokens
  850.      should shift them.  */
  851.   zzn = zzdefact[zzstate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  852.   if (zzn) goto zzdefault;
  853. #endif
  854.  
  855. zzerrpop:   /* pop the current state because it cannot handle the error token */
  856.  
  857.   if (zzssp == zzss) YYABORT;
  858.   zzvsp--;
  859.   zzstate = *--zzssp;
  860. #ifdef YYLSP_NEEDED
  861.   zzlsp--;
  862. #endif
  863.  
  864. #if YYDEBUG != 0
  865.   if (zzdebug)
  866.     {
  867.       short *ssp1 = zzss - 1;
  868.       fprintf (stderr, "Error: state stack now");
  869.       while (ssp1 != zzssp)
  870.     fprintf (stderr, " %d", *++ssp1);
  871.       fprintf (stderr, "\n");
  872.     }
  873. #endif
  874.  
  875. zzerrhandle:
  876.  
  877.   zzn = zzpact[zzstate];
  878.   if (zzn == YYFLAG)
  879.     goto zzerrdefault;
  880.  
  881.   zzn += YYTERROR;
  882.   if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != YYTERROR)
  883.     goto zzerrdefault;
  884.  
  885.   zzn = zztable[zzn];
  886.   if (zzn < 0)
  887.     {
  888.       if (zzn == YYFLAG)
  889.     goto zzerrpop;
  890.       zzn = -zzn;
  891.       goto zzreduce;
  892.     }
  893.   else if (zzn == 0)
  894.     goto zzerrpop;
  895.  
  896.   if (zzn == YYFINAL)
  897.     YYACCEPT;
  898.  
  899. #if YYDEBUG != 0
  900.   if (zzdebug)
  901.     fprintf(stderr, "Shifting error token, ");
  902. #endif
  903.  
  904.   *++zzvsp = zzlval;
  905. #ifdef YYLSP_NEEDED
  906.   *++zzlsp = zzlloc;
  907. #endif
  908.  
  909.   zzstate = zzn;
  910.   goto zznewstate;
  911. }
  912. #line 138 "./posixtm.y"
  913.  
  914. static int
  915. zzlex ()
  916. {
  917.   char ch = *curpos++;
  918.  
  919.   if (ch >= '0' && ch <= '9')
  920.     {
  921.       zzlval = ch - '0';
  922.       return DIGIT;
  923.     }
  924.   else if (ch == '.' || ch == 0)
  925.     return ch;
  926.   else
  927.     return '?';            /* Cause an error.  */
  928. }
  929.  
  930. static int
  931. zzerror ()
  932. {
  933.   return 0;
  934. }
  935.  
  936. /* Parse a POSIX-style date and return it, or (time_t)-1 for an error.  */
  937.  
  938. time_t
  939. posixtime (s)
  940.      char *s;
  941. {
  942.   curpos = s;
  943.   /* Let mktime decide whether it is daylight savings time.  */
  944.   t.tm_isdst = -1;
  945.   if (zzparse ())
  946.     return (time_t)-1;
  947.   else
  948.     return mktime (&t);
  949. }
  950.  
  951. /* Parse a POSIX-style date and return it, or NULL for an error.  */
  952.  
  953. struct tm *
  954. posixtm (s)
  955.      char *s;
  956. {
  957.   if (posixtime (s) == -1)
  958.     return NULL;
  959.   return &t;
  960. }
  961.