xref: /titanic_41/usr/src/lib/gss_mechs/mech_krb5/krb5/krb/deltat.c (revision 505d05c73a6e56769f263d4803b22eddd168ee24)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 
3 /*  A Bison parser, made from ./x-deltat.y
4     by GNU Bison version 1.28  */
5 
6 #define YYBISON 1  /* Identify Bison output.  */
7 
8 #define	NUM	257
9 #define	LONGNUM	258
10 #define	OVERFLOW	259
11 #define	WS	260
12 
13 #line 38 "./x-deltat.y"
14 
15 
16 #include <ctype.h>
17 #include <errno.h>
18 #include <k5-int.h>
19 
20 struct param {
21     krb5_int32 delta;
22     char *p;
23 };
24 
25 #define YYPARSE_PARAM tmv
26 
27 #define MAX_TIME KRB5_INT32_MAX
28 #define MIN_TIME KRB5_INT32_MIN
29 
30 #define DAY (24 * 3600)
31 #define HOUR 3600
32 
33 #define MAX_DAY (MAX_TIME / DAY)
34 #define MIN_DAY (MIN_TIME / DAY)
35 #define MAX_HOUR (MAX_TIME / HOUR)
36 #define MIN_HOUR (MIN_TIME / HOUR)
37 #define MAX_MIN (MAX_TIME / 60)
38 #define MIN_MIN (MIN_TIME / 60)
39 
40 /* An explanation of the tests being performed.
41    We do not want to overflow a 32 bit integer with out manipulations,
42    even for testing for overflow. Therefore we rely on the following:
43 
44    The lex parser will not return a number > MAX_TIME (which is out 32
45    bit limit).
46 
47    Therefore, seconds (s) will require
48        MIN_TIME < s < MAX_TIME
49 
50    For subsequent tests, the logic is as follows:
51 
52       If A < MAX_TIME and  B < MAX_TIME
53 
54       If we want to test if A+B < MAX_TIME, there are two cases
55         if (A > 0)
56          then A + B < MAX_TIME if B < MAX_TIME - A
57 	else A + B < MAX_TIME  always.
58 
59       if we want to test if MIN_TIME < A + B
60           if A > 0 - then nothing to test
61           otherwise, we test if MIN_TIME - A < B.
62 
63    We of course are testing for:
64           MIN_TIME < A + B < MAX_TIME
65 */
66 
67 
68 #define DAY_NOT_OK(d) (d) > MAX_DAY || (d) < MIN_DAY
69 #define HOUR_NOT_OK(h) (h) > MAX_HOUR || (h) < MIN_HOUR
70 #define MIN_NOT_OK(m) (m) > MAX_MIN || (m) < MIN_MIN
71 #define SUM_OK(a, b) (((a) > 0) ? ( (b) <= MAX_TIME - (a)) : (MIN_TIME - (a) <= (b)))
72 #define DO_SUM(res, a, b) if (!SUM_OK((a), (b))) YYERROR; \
73                           res = (a) + (b)
74 
75 
76 #define OUT_D ((struct param *)tmv)->delta
77 #define DO(D,H,M,S) \
78  { \
79      /* Overflow testing - this does not handle negative values well.. */ \
80      if (DAY_NOT_OK(D) || HOUR_NOT_OK(H) || MIN_NOT_OK(M)) YYERROR; \
81      OUT_D = D * DAY; \
82      DO_SUM(OUT_D, OUT_D, H * HOUR); \
83      DO_SUM(OUT_D, OUT_D, M * 60); \
84      DO_SUM(OUT_D, OUT_D, S); \
85  }
86 
87 static int mylex (int *, char **);
88 #define YYLEX_PARAM (&((struct param *)tmv)->p)
89 #undef yylex
90 #define yylex(U, P)    mylex (&(U)->val, (P))
91 
92 #undef yyerror
93 #define yyerror(MSG)
94 
95 static int yyparse (void *);
96 
97 
98 #line 125 "./x-deltat.y"
99 typedef union { int val; } YYSTYPE;
100 #include <stdio.h>
101 
102 #ifndef __cplusplus
103 #ifndef __STDC__
104 #define const
105 #endif
106 #endif
107 
108 
109 
110 #define	YYFINAL		42
111 #define	YYFLAG		-32768
112 #define	YYNTBASE	13
113 
114 #define YYTRANSLATE(x) ((unsigned)(x) <= 260 ? yytranslate[x] : 22)
115 
116 static const char yytranslate[] = {     0,
117      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
118      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
119      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
120      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
121      2,     2,     2,     2,     6,     2,     2,     2,     2,     2,
122      2,     2,     2,     2,     2,     2,     2,     7,     2,     2,
123      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
124      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
125      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
126      2,     2,     2,     2,     2,     2,     2,     2,     2,     8,
127      2,     2,     2,     9,     2,     2,     2,     2,    10,     2,
128      2,     2,     2,     2,    11,     2,     2,     2,     2,     2,
129      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
130      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
131      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
132      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
133      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
134      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
135      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
136      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
137      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
138      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
139      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
140      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
141      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
142      2,     2,     2,     2,     2,     1,     3,     4,     5,    12
143 };
144 
145 #if YYDEBUG != 0
146 static const short yyprhs[] = {     0,
147      0,     2,     4,     6,     8,    11,    12,    14,    17,    20,
148     24,    28,    32,    35,    43,    49,    53,    55,    57,    61,
149     63,    67,    69
150 };
151 
152 static const short yyrhs[] = {    18,
153      0,     3,     0,     4,     0,    14,     0,     6,    14,     0,
154      0,    12,     0,    16,    15,     0,    16,     5,     0,    17,
155      8,    19,     0,    17,     9,    20,     0,    17,    10,    21,
156      0,    17,    11,     0,    17,     6,     3,     7,     3,     7,
157      3,     0,    17,     7,     3,     7,     3,     0,    17,     7,
158      3,     0,    17,     0,    20,     0,    17,     9,    20,     0,
159     21,     0,    17,    10,    21,     0,    16,     0,    17,    11,
160      0
161 };
162 
163 #endif
164 
165 #if YYDEBUG != 0
166 static const short yyrline[] = { 0,
167    136,   137,   137,   138,   138,   139,   139,   140,   141,   142,
168    144,   145,   146,   147,   148,   149,   150,   153,   155,   157,
169    159,   161,   163
170 };
171 #endif
172 
173 
174 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
175 
176 static const char * const yytname[] = {   "$","error","$undefined.","NUM","LONGNUM",
177 "OVERFLOW","'-'","':'","'d'","'h'","'m'","'s'","WS","start","posnum","num","ws",
178 "wsnum","deltat","opt_hms","opt_ms","opt_s", NULL
179 };
180 #endif
181 
182 static const short yyr1[] = {     0,
183     13,    14,    14,    15,    15,    16,    16,    17,    17,    18,
184     18,    18,    18,    18,    18,    18,    18,    19,    19,    20,
185     20,    21,    21
186 };
187 
188 static const short yyr2[] = {     0,
189      1,     1,     1,     1,     2,     0,     1,     2,     2,     3,
190      3,     3,     2,     7,     5,     3,     1,     1,     3,     1,
191      3,     1,     2
192 };
193 
194 static const short yydefact[] = {     6,
195      7,     0,    17,     1,     2,     3,     9,     0,     4,     8,
196      0,     0,     6,     6,     6,    13,     5,     0,    16,    22,
197      0,    10,    18,    20,     0,    11,     0,    12,     0,     0,
198      6,     6,    23,     0,    15,    19,    21,     0,    14,     0,
199      0,     0
200 };
201 
202 static const short yydefgoto[] = {    40,
203      9,    10,    20,    25,     4,    22,    23,    24
204 };
205 
206 static const short yypact[] = {   -10,
207 -32768,    18,    -2,-32768,-32768,-32768,-32768,    13,-32768,-32768,
208     11,    16,   -10,   -10,   -10,-32768,-32768,    20,    21,    18,
209      1,-32768,-32768,-32768,    15,-32768,    19,-32768,    26,    28,
210    -10,   -10,-32768,    27,-32768,-32768,-32768,    30,-32768,    35,
211     36,-32768
212 };
213 
214 static const short yypgoto[] = {-32768,
215     29,-32768,    38,     0,-32768,-32768,   -13,   -12
216 };
217 
218 
219 #define	YYLAST		38
220 
221 
222 static const short yytable[] = {     3,
223     26,     1,    28,    11,    12,    13,    14,    15,    16,    31,
224     32,    33,    21,    18,    27,     5,     6,    36,    19,    37,
225      5,     6,     7,     8,    32,    33,    29,    30,    34,    33,
226     35,    27,    39,    38,    41,    42,    17,     2
227 };
228 
229 static const short yycheck[] = {     0,
230     14,    12,    15,     6,     7,     8,     9,    10,    11,     9,
231     10,    11,    13,     3,    15,     3,     4,    31,     3,    32,
232      3,     4,     5,     6,    10,    11,     7,     7,     3,    11,
233      3,    32,     3,     7,     0,     0,     8,     0
234 };
235 #define YYPURE 1
236 
237 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
238 #line 3 "/usr/share/bison.simple"
239 /* This file comes from bison-1.28.  */
240 
241 /* Skeleton output parser for bison,
242    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
243 
244    This program is free software; you can redistribute it and/or modify
245    it under the terms of the GNU General Public License as published by
246    the Free Software Foundation; either version 2, or (at your option)
247    any later version.
248 
249    This program is distributed in the hope that it will be useful,
250    but WITHOUT ANY WARRANTY; without even the implied warranty of
251    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
252    GNU General Public License for more details.
253 
254    You should have received a copy of the GNU General Public License
255    along with this program; if not, write to the Free Software
256    Foundation, Inc., 59 Temple Place - Suite 330,
257    Boston, MA 02111-1307, USA.  */
258 
259 /* As a special exception, when this file is copied by Bison into a
260    Bison output file, you may use that output file without restriction.
261    This special exception was added by the Free Software Foundation
262    in version 1.24 of Bison.  */
263 
264 /* This is the parser code that is written into each bison parser
265   when the %semantic_parser declaration is not specified in the grammar.
266   It was written by Richard Stallman by simplifying the hairy parser
267   used when %semantic_parser is specified.  */
268 
269 #ifndef YYSTACK_USE_ALLOCA
270 #ifdef alloca
271 #define YYSTACK_USE_ALLOCA
272 #else /* alloca not defined */
273 #ifdef __GNUC__
274 #define YYSTACK_USE_ALLOCA
275 #define alloca __builtin_alloca
276 #else /* not GNU C.  */
277 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
278 #define YYSTACK_USE_ALLOCA
279 #include <alloca.h>
280 #else /* not sparc */
281 /* We think this test detects Watcom and Microsoft C.  */
282 /* This used to test MSDOS, but that is a bad idea
283    since that symbol is in the user namespace.  */
284 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
285 #if 0 /* No need for malloc.h, which pollutes the namespace;
286 	 instead, just don't use alloca.  */
287 #include <malloc.h>
288 #endif
289 #else /* not MSDOS, or __TURBOC__ */
290 #if defined(_AIX)
291 /* I don't know what this was needed for, but it pollutes the namespace.
292    So I turned it off.   rms, 2 May 1997.  */
293 /* #include <malloc.h>  */
294  #pragma alloca
295 #define YYSTACK_USE_ALLOCA
296 #else /* not MSDOS, or __TURBOC__, or _AIX */
297 #if 0
298 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
299 		 and on HPUX 10.  Eventually we can turn this on.  */
300 #define YYSTACK_USE_ALLOCA
301 #define alloca __builtin_alloca
302 #endif /* __hpux */
303 #endif
304 #endif /* not _AIX */
305 #endif /* not MSDOS, or __TURBOC__ */
306 #endif /* not sparc */
307 #endif /* not GNU C */
308 #endif /* alloca not defined */
309 #endif /* YYSTACK_USE_ALLOCA not defined */
310 
311 #ifdef YYSTACK_USE_ALLOCA
312 #define YYSTACK_ALLOC alloca
313 #else
314 #define YYSTACK_ALLOC malloc
315 #endif
316 
317 /* Note: there must be only one dollar sign in this file.
318    It is replaced by the list of actions, each action
319    as one case of the switch.  */
320 
321 #define yyerrok		(yyerrstatus = 0)
322 #define yyclearin	(yychar = YYEMPTY)
323 #define YYEMPTY		-2
324 #define YYEOF		0
325 #define YYACCEPT	goto yyacceptlab
326 #define YYABORT 	goto yyabortlab
327 #define YYERROR		goto yyerrlab1
328 /* Like YYERROR except do call yyerror.
329    This remains here temporarily to ease the
330    transition to the new meaning of YYERROR, for GCC.
331    Once GCC version 2 has supplanted version 1, this can go.  */
332 #define YYFAIL		goto yyerrlab
333 #define YYRECOVERING()  (!!yyerrstatus)
334 #define YYBACKUP(token, value) \
335 do								\
336   if (yychar == YYEMPTY && yylen == 1)				\
337     { yychar = (token), yylval = (value);			\
338       yychar1 = YYTRANSLATE (yychar);				\
339       YYPOPSTACK;						\
340       goto yybackup;						\
341     }								\
342   else								\
343     { yyerror ("syntax error: cannot back up"); YYERROR; }	\
344 while (0)
345 
346 #define YYTERROR	1
347 #define YYERRCODE	256
348 
349 #ifndef YYPURE
350 #define YYLEX		yylex()
351 #endif
352 
353 #ifdef YYPURE
354 #ifdef YYLSP_NEEDED
355 #ifdef YYLEX_PARAM
356 #define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
357 #else
358 #define YYLEX		yylex(&yylval, &yylloc)
359 #endif
360 #else /* not YYLSP_NEEDED */
361 #ifdef YYLEX_PARAM
362 #define YYLEX		yylex(&yylval, YYLEX_PARAM)
363 #else
364 #define YYLEX		yylex(&yylval)
365 #endif
366 #endif /* not YYLSP_NEEDED */
367 #endif
368 
369 /* If nonreentrant, generate the variables here */
370 
371 #ifndef YYPURE
372 
373 int	yychar;			/*  the lookahead symbol		*/
374 YYSTYPE	yylval;			/*  the semantic value of the		*/
375 				/*  lookahead symbol			*/
376 
377 #ifdef YYLSP_NEEDED
378 YYLTYPE yylloc;			/*  location data for the lookahead	*/
379 				/*  symbol				*/
380 #endif
381 
382 int yynerrs;			/*  number of parse errors so far       */
383 #endif  /* not YYPURE */
384 
385 #if YYDEBUG != 0
386 int yydebug;			/*  nonzero means print parse trace	*/
387 /* Since this is uninitialized, it does not stop multiple parsers
388    from coexisting.  */
389 #endif
390 
391 /*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
392 
393 #ifndef	YYINITDEPTH
394 #define YYINITDEPTH 200
395 #endif
396 
397 /*  YYMAXDEPTH is the maximum size the stacks can grow to
398     (effective only if the built-in stack extension method is used).  */
399 
400 #if YYMAXDEPTH == 0
401 #undef YYMAXDEPTH
402 #endif
403 
404 #ifndef YYMAXDEPTH
405 #define YYMAXDEPTH 10000
406 #endif
407 
408 /* Define __yy_memcpy.  Note that the size argument
409    should be passed with type unsigned int, because that is what the non-GCC
410    definitions require.  With GCC, __builtin_memcpy takes an arg
411    of type size_t, but it can handle unsigned int.  */
412 
413 #if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
414 #define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
415 #else				/* not GNU C or C++ */
416 #ifndef __cplusplus
417 
418 /* This is the most reliable way to avoid incompatibilities
419    in available built-in functions on various systems.  */
420 static void
__yy_memcpy(to,from,count)421 __yy_memcpy (to, from, count)
422      char *to;
423      char *from;
424      unsigned int count;
425 {
426   register char *f = from;
427   register char *t = to;
428   register int i = count;
429 
430   while (i-- > 0)
431     *t++ = *f++;
432 }
433 
434 #else /* __cplusplus */
435 
436 /* This is the most reliable way to avoid incompatibilities
437    in available built-in functions on various systems.  */
438 static void
__yy_memcpy(char * to,char * from,unsigned int count)439 __yy_memcpy (char *to, char *from, unsigned int count)
440 {
441   register char *t = to;
442   register char *f = from;
443   register int i = count;
444 
445   while (i-- > 0)
446     *t++ = *f++;
447 }
448 
449 #endif
450 #endif
451 
452 #line 217 "/usr/share/bison.simple"
453 
454 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
455    into yyparse.  The argument should have type void *.
456    It should actually point to an object.
457    Grammar actions can access the variable by casting it
458    to the proper pointer type.  */
459 
460 #ifdef YYPARSE_PARAM
461 #ifdef __cplusplus
462 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
463 #define YYPARSE_PARAM_DECL
464 #else /* not __cplusplus */
465 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
466 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
467 #endif /* not __cplusplus */
468 #else /* not YYPARSE_PARAM */
469 #define YYPARSE_PARAM_ARG
470 #define YYPARSE_PARAM_DECL
471 #endif /* not YYPARSE_PARAM */
472 
473 /* Prevent warning if -Wstrict-prototypes.  */
474 #ifdef __GNUC__
475 #ifdef YYPARSE_PARAM
476 int yyparse (void *);
477 #else
478 int yyparse (void);
479 #endif
480 #endif
481 
482 int
yyparse(YYPARSE_PARAM_ARG)483 yyparse(YYPARSE_PARAM_ARG)
484      YYPARSE_PARAM_DECL
485 {
486   register int yystate;
487   register int yyn;
488   register short *yyssp;
489   register YYSTYPE *yyvsp;
490   int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
491   int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
492 
493   short	yyssa[YYINITDEPTH];	/*  the state stack			*/
494   YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
495 
496   short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
497   YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
498 
499 #ifdef YYLSP_NEEDED
500   YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
501   YYLTYPE *yyls = yylsa;
502   YYLTYPE *yylsp;
503 
504 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
505 #else
506 #define YYPOPSTACK   (yyvsp--, yyssp--)
507 #endif
508 
509   int yystacksize = YYINITDEPTH;
510   int yyfree_stacks = 0;
511 
512 #ifdef YYPURE
513   int yychar;
514   YYSTYPE yylval;
515   int yynerrs;
516 #ifdef YYLSP_NEEDED
517   YYLTYPE yylloc;
518 #endif
519 #endif
520 
521   YYSTYPE yyval;		/*  the variable used to return		*/
522 				/*  semantic values from the action	*/
523 				/*  routines				*/
524 
525   int yylen;
526 
527 #if YYDEBUG != 0
528   if (yydebug)
529     fprintf(stderr, "Starting parse\n");
530 #endif
531 
532   yystate = 0;
533   yyerrstatus = 0;
534   yynerrs = 0;
535   yychar = YYEMPTY;		/* Cause a token to be read.  */
536 
537   /* Initialize stack pointers.
538      Waste one element of value and location stack
539      so that they stay on the same level as the state stack.
540      The wasted elements are never initialized.  */
541 
542   yyssp = yyss - 1;
543   yyvsp = yyvs;
544 #ifdef YYLSP_NEEDED
545   yylsp = yyls;
546 #endif
547 
548 /* Push a new state, which is found in  yystate  .  */
549 /* In all cases, when you get here, the value and location stacks
550    have just been pushed. so pushing a state here evens the stacks.  */
551 yynewstate:
552 
553   *++yyssp = yystate;
554 
555   if (yyssp >= yyss + yystacksize - 1)
556     {
557       /* Give user a chance to reallocate the stack */
558       /* Use copies of these so that the &'s don't force the real ones into memory. */
559       YYSTYPE *yyvs1 = yyvs;
560       short *yyss1 = yyss;
561 #ifdef YYLSP_NEEDED
562       YYLTYPE *yyls1 = yyls;
563 #endif
564 
565       /* Get the current used size of the three stacks, in elements.  */
566       int size = yyssp - yyss + 1;
567 
568 #ifdef yyoverflow
569       /* Each stack pointer address is followed by the size of
570 	 the data in use in that stack, in bytes.  */
571 #ifdef YYLSP_NEEDED
572       /* This used to be a conditional around just the two extra args,
573 	 but that might be undefined if yyoverflow is a macro.  */
574       yyoverflow("parser stack overflow",
575 		 &yyss1, size * sizeof (*yyssp),
576 		 &yyvs1, size * sizeof (*yyvsp),
577 		 &yyls1, size * sizeof (*yylsp),
578 		 &yystacksize);
579 #else
580       yyoverflow("parser stack overflow",
581 		 &yyss1, size * sizeof (*yyssp),
582 		 &yyvs1, size * sizeof (*yyvsp),
583 		 &yystacksize);
584 #endif
585 
586       yyss = yyss1; yyvs = yyvs1;
587 #ifdef YYLSP_NEEDED
588       yyls = yyls1;
589 #endif
590 #else /* no yyoverflow */
591       /* Extend the stack our own way.  */
592       if (yystacksize >= YYMAXDEPTH)
593 	{
594 	  yyerror("parser stack overflow");
595 	  if (yyfree_stacks)
596 	    {
597 	      free (yyss);
598 	      free (yyvs);
599 #ifdef YYLSP_NEEDED
600 	      free (yyls);
601 #endif
602 	    }
603 	  return 2;
604 	}
605       yystacksize *= 2;
606       if (yystacksize > YYMAXDEPTH)
607 	yystacksize = YYMAXDEPTH;
608 #ifndef YYSTACK_USE_ALLOCA
609       yyfree_stacks = 1;
610 #endif
611       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
612       __yy_memcpy ((char *)yyss, (char *)yyss1,
613 		   size * (unsigned int) sizeof (*yyssp));
614       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
615       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
616 		   size * (unsigned int) sizeof (*yyvsp));
617 #ifdef YYLSP_NEEDED
618       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
619       __yy_memcpy ((char *)yyls, (char *)yyls1,
620 		   size * (unsigned int) sizeof (*yylsp));
621 #endif
622 #endif /* no yyoverflow */
623 
624       yyssp = yyss + size - 1;
625       yyvsp = yyvs + size - 1;
626 #ifdef YYLSP_NEEDED
627       yylsp = yyls + size - 1;
628 #endif
629 
630 #if YYDEBUG != 0
631       if (yydebug)
632 	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
633 #endif
634 
635       if (yyssp >= yyss + yystacksize - 1)
636 	YYABORT;
637     }
638 
639 #if YYDEBUG != 0
640   if (yydebug)
641     fprintf(stderr, "Entering state %d\n", yystate);
642 #endif
643 
644   goto yybackup;
645  yybackup:
646 
647 /* Do appropriate processing given the current state.  */
648 /* Read a lookahead token if we need one and don't already have one.  */
649 /* yyresume: */
650 
651   /* First try to decide what to do without reference to lookahead token.  */
652 
653   yyn = yypact[yystate];
654   if (yyn == YYFLAG)
655     goto yydefault;
656 
657   /* Not known => get a lookahead token if don't already have one.  */
658 
659   /* yychar is either YYEMPTY or YYEOF
660      or a valid token in external form.  */
661 
662   if (yychar == YYEMPTY)
663     {
664 #if YYDEBUG != 0
665       if (yydebug)
666 	fprintf(stderr, "Reading a token: ");
667 #endif
668       yychar = YYLEX;
669     }
670 
671   /* Convert token to internal form (in yychar1) for indexing tables with */
672 
673   if (yychar <= 0)		/* This means end of input. */
674     {
675       yychar1 = 0;
676       yychar = YYEOF;		/* Don't call YYLEX any more */
677 
678 #if YYDEBUG != 0
679       if (yydebug)
680 	fprintf(stderr, "Now at end of input.\n");
681 #endif
682     }
683   else
684     {
685       yychar1 = YYTRANSLATE(yychar);
686 
687 #if YYDEBUG != 0
688       if (yydebug)
689 	{
690 	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
691 	  /* Give the individual parser a way to print the precise meaning
692 	     of a token, for further debugging info.  */
693 #ifdef YYPRINT
694 	  YYPRINT (stderr, yychar, yylval);
695 #endif
696 	  fprintf (stderr, ")\n");
697 	}
698 #endif
699     }
700 
701   yyn += yychar1;
702   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
703     goto yydefault;
704 
705   yyn = yytable[yyn];
706 
707   /* yyn is what to do for this token type in this state.
708      Negative => reduce, -yyn is rule number.
709      Positive => shift, yyn is new state.
710        New state is final state => don't bother to shift,
711        just return success.
712      0, or most negative number => error.  */
713 
714   if (yyn < 0)
715     {
716       if (yyn == YYFLAG)
717 	goto yyerrlab;
718       yyn = -yyn;
719       goto yyreduce;
720     }
721   else if (yyn == 0)
722     goto yyerrlab;
723 
724   if (yyn == YYFINAL)
725     YYACCEPT;
726 
727   /* Shift the lookahead token.  */
728 
729 #if YYDEBUG != 0
730   if (yydebug)
731     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
732 #endif
733 
734   /* Discard the token being shifted unless it is eof.  */
735   if (yychar != YYEOF)
736     yychar = YYEMPTY;
737 
738   *++yyvsp = yylval;
739 #ifdef YYLSP_NEEDED
740   *++yylsp = yylloc;
741 #endif
742 
743   /* count tokens shifted since error; after three, turn off error status.  */
744   if (yyerrstatus) yyerrstatus--;
745 
746   yystate = yyn;
747   goto yynewstate;
748 
749 /* Do the default action for the current state.  */
750 yydefault:
751 
752   yyn = yydefact[yystate];
753   if (yyn == 0)
754     goto yyerrlab;
755 
756 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
757 yyreduce:
758   yylen = yyr2[yyn];
759   if (yylen > 0)
760     yyval = yyvsp[1-yylen]; /* implement default value of the action */
761 
762 #if YYDEBUG != 0
763   if (yydebug)
764     {
765       int i;
766 
767       fprintf (stderr, "Reducing via rule %d (line %d), ",
768 	       yyn, yyrline[yyn]);
769 
770       /* Print the symbols being reduced, and their result.  */
771       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
772 	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
773       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
774     }
775 #endif
776 
777 
778   switch (yyn) {
779 
780 case 5:
781 #line 138 "./x-deltat.y"
782 { yyval.val = - yyvsp[0].val; ;
783     break;}
784 case 8:
785 #line 140 "./x-deltat.y"
786 { yyval.val = yyvsp[0].val; ;
787     break;}
788 case 9:
789 #line 141 "./x-deltat.y"
790 { YYERROR ;
791     break;}
792 case 10:
793 #line 143 "./x-deltat.y"
794 { DO (yyvsp[-2].val,  0,  0, yyvsp[0].val); ;
795     break;}
796 case 11:
797 #line 144 "./x-deltat.y"
798 { DO ( 0, yyvsp[-2].val,  0, yyvsp[0].val); ;
799     break;}
800 case 12:
801 #line 145 "./x-deltat.y"
802 { DO ( 0,  0, yyvsp[-2].val, yyvsp[0].val); ;
803     break;}
804 case 13:
805 #line 146 "./x-deltat.y"
806 { DO ( 0,  0,  0, yyvsp[-1].val); ;
807     break;}
808 case 14:
809 #line 147 "./x-deltat.y"
810 { DO (yyvsp[-6].val, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ;
811     break;}
812 case 15:
813 #line 148 "./x-deltat.y"
814 { DO ( 0, yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val); ;
815     break;}
816 case 16:
817 #line 149 "./x-deltat.y"
818 { DO ( 0, yyvsp[-2].val, yyvsp[0].val,  0); ;
819     break;}
820 case 17:
821 #line 150 "./x-deltat.y"
822 { DO ( 0,  0,  0, yyvsp[0].val); ;
823     break;}
824 case 19:
825 #line 155 "./x-deltat.y"
826 { if (HOUR_NOT_OK(yyvsp[-2].val)) YYERROR;
827 	                                  DO_SUM(yyval.val, yyvsp[-2].val * 3600, yyvsp[0].val); ;
828     break;}
829 case 21:
830 #line 159 "./x-deltat.y"
831 { if (MIN_NOT_OK(yyvsp[-2].val)) YYERROR;
832 	                                  DO_SUM(yyval.val, yyvsp[-2].val * 60, yyvsp[0].val); ;
833     break;}
834 case 22:
835 #line 162 "./x-deltat.y"
836 { yyval.val = 0; ;
837     break;}
838 }
839    /* the action file gets copied in in place of this dollarsign */
840 #line 543 "/usr/share/bison.simple"
841 
842   yyvsp -= yylen;
843   yyssp -= yylen;
844 #ifdef YYLSP_NEEDED
845   yylsp -= yylen;
846 #endif
847 
848 #if YYDEBUG != 0
849   if (yydebug)
850     {
851       short *ssp1 = yyss - 1;
852       fprintf (stderr, "state stack now");
853       while (ssp1 != yyssp)
854 	fprintf (stderr, " %d", *++ssp1);
855       fprintf (stderr, "\n");
856     }
857 #endif
858 
859   *++yyvsp = yyval;
860 
861 #ifdef YYLSP_NEEDED
862   yylsp++;
863   if (yylen == 0)
864     {
865       yylsp->first_line = yylloc.first_line;
866       yylsp->first_column = yylloc.first_column;
867       yylsp->last_line = (yylsp-1)->last_line;
868       yylsp->last_column = (yylsp-1)->last_column;
869       yylsp->text = 0;
870     }
871   else
872     {
873       yylsp->last_line = (yylsp+yylen-1)->last_line;
874       yylsp->last_column = (yylsp+yylen-1)->last_column;
875     }
876 #endif
877 
878   /* Now "shift" the result of the reduction.
879      Determine what state that goes to,
880      based on the state we popped back to
881      and the rule number reduced by.  */
882 
883   yyn = yyr1[yyn];
884 
885   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
886   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
887     yystate = yytable[yystate];
888   else
889     yystate = yydefgoto[yyn - YYNTBASE];
890 
891   goto yynewstate;
892 
893 yyerrlab:   /* here on detecting error */
894 
895   if (! yyerrstatus)
896     /* If not already recovering from an error, report this error.  */
897     {
898       ++yynerrs;
899 
900 #ifdef YYERROR_VERBOSE
901       yyn = yypact[yystate];
902 
903       if (yyn > YYFLAG && yyn < YYLAST)
904 	{
905 	  int size = 0;
906 	  char *msg;
907 	  int x, count;
908 
909 	  count = 0;
910 	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
911 	  for (x = (yyn < 0 ? -yyn : 0);
912 	       x < (sizeof(yytname) / sizeof(char *)); x++)
913 	    if (yycheck[x + yyn] == x)
914 	      size += strlen(yytname[x]) + 15, count++;
915 	  msg = (char *) malloc(size + 15);
916 	  if (msg != 0)
917 	    {
918 	      strcpy(msg, "parse error");
919 
920 	      if (count < 5)
921 		{
922 		  count = 0;
923 		  for (x = (yyn < 0 ? -yyn : 0);
924 		       x < (sizeof(yytname) / sizeof(char *)); x++)
925 		    if (yycheck[x + yyn] == x)
926 		      {
927 			strcat(msg, count == 0 ? ", expecting `" : " or `");
928 			strcat(msg, yytname[x]);
929 			strcat(msg, "'");
930 			count++;
931 		      }
932 		}
933 	      yyerror(msg);
934 	      free(msg);
935 	    }
936 	  else
937 	    yyerror ("parse error; also virtual memory exceeded");
938 	}
939       else
940 #endif /* YYERROR_VERBOSE */
941 	yyerror("parse error");
942     }
943 
944   goto yyerrlab1;
945 yyerrlab1:   /* here on error raised explicitly by an action */
946 
947   if (yyerrstatus == 3)
948     {
949       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
950 
951       /* return failure if at end of input */
952       if (yychar == YYEOF)
953 	YYABORT;
954 
955 #if YYDEBUG != 0
956       if (yydebug)
957 	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
958 #endif
959 
960       yychar = YYEMPTY;
961     }
962 
963   /* Else will try to reuse lookahead token
964      after shifting the error token.  */
965 
966   yyerrstatus = 3;		/* Each real token shifted decrements this */
967 
968   goto yyerrhandle;
969 
970 yyerrdefault:  /* current state does not do anything special for the error token. */
971 
972 #if 0
973   /* This is wrong; only states that explicitly want error tokens
974      should shift them.  */
975   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
976   if (yyn) goto yydefault;
977 #endif
978 
979 yyerrpop:   /* pop the current state because it cannot handle the error token */
980 
981   if (yyssp == yyss) YYABORT;
982   yyvsp--;
983   yystate = *--yyssp;
984 #ifdef YYLSP_NEEDED
985   yylsp--;
986 #endif
987 
988 #if YYDEBUG != 0
989   if (yydebug)
990     {
991       short *ssp1 = yyss - 1;
992       fprintf (stderr, "Error: state stack now");
993       while (ssp1 != yyssp)
994 	fprintf (stderr, " %d", *++ssp1);
995       fprintf (stderr, "\n");
996     }
997 #endif
998 
999 yyerrhandle:
1000 
1001   yyn = yypact[yystate];
1002   if (yyn == YYFLAG)
1003     goto yyerrdefault;
1004 
1005   yyn += YYTERROR;
1006   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1007     goto yyerrdefault;
1008 
1009   yyn = yytable[yyn];
1010   if (yyn < 0)
1011     {
1012       if (yyn == YYFLAG)
1013 	goto yyerrpop;
1014       yyn = -yyn;
1015       goto yyreduce;
1016     }
1017   else if (yyn == 0)
1018     goto yyerrpop;
1019 
1020   if (yyn == YYFINAL)
1021     YYACCEPT;
1022 
1023 #if YYDEBUG != 0
1024   if (yydebug)
1025     fprintf(stderr, "Shifting error token, ");
1026 #endif
1027 
1028   *++yyvsp = yylval;
1029 #ifdef YYLSP_NEEDED
1030   *++yylsp = yylloc;
1031 #endif
1032 
1033   yystate = yyn;
1034   goto yynewstate;
1035 
1036  yyacceptlab:
1037   /* YYACCEPT comes here.  */
1038   if (yyfree_stacks)
1039     {
1040       free (yyss);
1041       free (yyvs);
1042 #ifdef YYLSP_NEEDED
1043       free (yyls);
1044 #endif
1045     }
1046   return 0;
1047 
1048  yyabortlab:
1049   /* YYABORT comes here.  */
1050   if (yyfree_stacks)
1051     {
1052       free (yyss);
1053       free (yyvs);
1054 #ifdef YYLSP_NEEDED
1055       free (yyls);
1056 #endif
1057     }
1058   return 1;
1059 }
1060 #line 165 "./x-deltat.y"
1061 
1062 
1063 static int
mylex(krb5_int32 * intp,char ** pp)1064 mylex (krb5_int32 *intp, char **pp)
1065 {
1066     int num, c;
1067 #define P (*pp)
1068     char *orig_p = P;
1069 
1070 #ifdef isascii
1071     if (!isascii (*P))
1072 	return 0;
1073 #endif
1074     switch (c = *P++) {
1075     case '-':
1076     case ':':
1077     case 'd':
1078     case 'h':
1079     case 'm':
1080     case 's':
1081 	return c;
1082     case '0':
1083     case '1':
1084     case '2':
1085     case '3':
1086     case '4':
1087     case '5':
1088     case '6':
1089     case '7':
1090     case '8':
1091     case '9':
1092 	/* XXX assumes ASCII */
1093 	num = c - '0';
1094 	while (isdigit ((int) *P)) {
1095 	  if (num > MAX_TIME / 10)
1096 	    return OVERFLOW;
1097 	    num *= 10;
1098 	    if (num > MAX_TIME - (*P - '0'))
1099 	      return OVERFLOW;
1100 	    num += *P++ - '0';
1101 	}
1102 	*intp = num;
1103 	return (P - orig_p > 2) ? LONGNUM : NUM;
1104     case ' ':
1105     case '\t':
1106     case '\n':
1107 	while (isspace ((int) *P))
1108 	    P++;
1109 	return WS;
1110     default:
1111 	return YYEOF;
1112     }
1113 }
1114 
1115 krb5_error_code KRB5_CALLCONV
krb5_string_to_deltat(char * string,krb5_deltat * deltatp)1116 krb5_string_to_deltat(char *string, krb5_deltat *deltatp)
1117 {
1118     struct param p;
1119     p.delta = 0;
1120     p.p = string;
1121     if (yyparse (&p))
1122 	return KRB5_DELTAT_BADFORMAT;
1123     *deltatp = p.delta;
1124     return 0;
1125 }
1126