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