06eb3e84c75c7aef0906ae90d6c62a86a1224ece
[openafs.git] / src / comerr / error_table_nt.c
1
2 /*  A Bison parser, made from error_table.y with Bison version GNU Bison version 1.24
3   */
4
5 #define YYBISON 1               /* Identify Bison output.  */
6
7 #define ERROR_TABLE     258
8 #define ERROR_CODE_ENTRY        259
9 #define END     260
10 #define STRING  261
11 #define QUOTED_STRING   262
12
13 #line 1 "error_table.y"
14
15 #include <afsconfig.h>
16 #include <afs/param.h>
17
18 #include <roken.h>
19
20
21 /*
22  * If __STDC__ is defined, function prototypes in the SunOS 5.5.1 lex
23  * and yacc templates are visible.  We turn this on explicitly on
24  * NT because the prototypes help supress certain warning from the
25  * Microsoft C compiler.
26  */
27
28 #ifdef AFS_NT40_ENV
29 #include <malloc.h>
30 # ifndef __STDC__
31 #  define __STDC__ 1
32 # endif
33 #endif
34
35 #include "internal.h"
36
37 char *current_token = (char *)NULL;
38 extern char *table_name;
39
40 char *ds(const char *string);
41 char *quote(const char *string);
42 void set_table_1num(char *string);
43 int char_to_1num(char c);
44 void add_ec(const char *name, const char *description);
45 void add_ec_val(const char *name, const char *val, const char *description);
46 void put_ecs(void);
47 void set_table_num(char *string);
48 void set_table_fun(char *astring);
49
50
51 #line 38 "error_table.y"
52 typedef union {
53     char *dynstr;
54 } YYSTYPE;
55 #line 45 "error_table.y"
56
57
58 #ifndef YYLTYPE
59 typedef
60     struct yyltype {
61     int timestamp;
62     int first_line;
63     int first_column;
64     int last_line;
65     int last_column;
66     char *text;
67 } yyltype;
68
69 #define YYLTYPE yyltype
70 #endif
71
72 #ifndef __cplusplus
73 #ifndef __STDC__
74 #define const
75 #endif
76 #endif
77
78
79
80 #define YYFINAL         24
81 #define YYFLAG          -32768
82 #define YYNTBASE        10
83
84 #define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 18)
85
86 static const char yytranslate[] = { 0,
87     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
90     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
91     2, 2, 2, 8, 2, 2, 2, 2, 2, 2,
92     2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93     9, 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, 2, 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, 1, 2, 3, 4, 5,
113     6, 7
114 };
115
116 #if YYDEBUG != 0
117 static const short yyprhs[] = { 0,
118     0, 5, 8, 10, 12, 14, 17, 19, 24, 31,
119     33
120 };
121
122 static const short yyrhs[] = { 3,
123     11, 14, 5, 0, 12, 13, 0, 13, 0, 6,
124     0, 6, 0, 14, 15, 0, 15, 0, 4, 16,
125     8, 17, 0, 4, 16, 9, 6, 8, 17, 0,
126     6, 0, 7, 0
127 };
128
129 #endif
130
131 #if YYDEBUG != 0
132 static const short yyrline[] = { 0,
133     50, 56, 59, 66, 73, 79, 80, 83, 87, 95,
134     100
135 };
136
137 static const char *const yytname[] =
138     { "$", "error", "$undefined.", "ERROR_TABLE",
139     "ERROR_CODE_ENTRY", "END", "STRING", "QUOTED_STRING", "','", "'='",
140     "error_table",
141     "header", "table_fun", "table_id", "error_codes", "ec_entry", "ec_name",
142     "description",
143     ""
144 };
145 #endif
146
147 static const short yyr1[] = { 0,
148     10, 11, 11, 12, 13, 14, 14, 15, 15, 16,
149     17
150 };
151
152 static const short yyr2[] = { 0,
153     4, 2, 1, 1, 1, 2, 1, 4, 6, 1,
154     1
155 };
156
157 static const short yydefact[] = { 0,
158     0, 4, 0, 0, 3, 0, 0, 7, 5, 2,
159     10, 0, 1, 6, 0, 0, 11, 8, 0, 0,
160     9, 0, 0, 0
161 };
162
163 static const short yydefgoto[] = { 22,
164     3, 4, 5, 7, 8, 12, 18
165 };
166
167 static const short yypact[] = { 1,
168     -1, 2, 3, 4, -32768, 5, -4, -32768, -32768, -32768,
169     -32768, -6, -32768, -32768, 6, 8, -32768, -32768, 0, 6,
170     -32768, 9, 12, -32768
171 };
172
173 static const short yypgoto[] = { -32768,
174     -32768, -32768, 11, -32768, 10, -32768, -2
175 };
176
177
178 #define YYLAST          18
179
180
181 static const short yytable[] = { 6,
182     13, 15, 16, 1, 2, -5, 6, 20, 23, 9,
183     11, 24, 17, 19, 10, 0, 14, 21
184 };
185
186 static const short yycheck[] = { 4,
187     5, 8, 9, 3, 6, 4, 4, 8, 0, 6,
188     6, 0, 7, 6, 4, -1, 7, 20
189 };
190
191 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
192 #line 3 "bison.simple"
193
194 /* Skeleton output parser for bison,
195    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
196
197    This program is free software; you can redistribute it and/or modify
198    it under the terms of the GNU General Public License as published by
199    the Free Software Foundation; either version 2, or (at your option)
200    any later version.
201
202    This program is distributed in the hope that it will be useful,
203    but WITHOUT ANY WARRANTY; without even the implied warranty of
204    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
205    GNU General Public License for more details.
206
207    You should have received a copy of the GNU General Public License
208    along with this program; if not, write to the Free Software
209    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
210
211 /* As a special exception, when this file is copied by Bison into a
212    Bison output file, you may use that output file without restriction.
213    This special exception was added by the Free Software Foundation
214    in version 1.24 of Bison.  */
215
216 #ifndef alloca
217 #ifdef __GNUC__
218 #define alloca __builtin_alloca
219 #else /* not GNU C.  */
220 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
221 #include <alloca.h>
222 #else /* not sparc */
223 #if defined (MSDOS) && !defined (__TURBOC__)
224 #include <malloc.h>
225 #else /* not MSDOS, or __TURBOC__ */
226 #if defined(_AIX)
227 #include <malloc.h>
228 #pragma alloca
229 #else /* not MSDOS, __TURBOC__, or _AIX */
230 #ifdef __hpux
231 #ifdef __cplusplus
232 extern "C" {
233     void *alloca(unsigned int);
234 };
235 #else /* not __cplusplus */
236 void *alloca();
237 #endif /* not __cplusplus */
238 #endif /* __hpux */
239 #endif /* not _AIX */
240 #endif /* not MSDOS, or __TURBOC__ */
241 #endif /* not sparc.  */
242 #endif /* not GNU C.  */
243 #endif /* alloca not defined.  */
244
245 /* This is the parser code that is written into each bison parser
246   when the %semantic_parser declaration is not specified in the grammar.
247   It was written by Richard Stallman by simplifying the hairy parser
248   used when %semantic_parser is specified.  */
249
250 /* Note: there must be only one dollar sign in this file.
251    It is replaced by the list of actions, each action
252    as one case of the switch.  */
253
254 #define yyerrok         (yyerrstatus = 0)
255 #define yyclearin       (yychar = YYEMPTY)
256 #define YYEMPTY         -2
257 #define YYEOF           0
258 #define YYACCEPT        return(0)
259 #define YYABORT         return(1)
260 #define YYERROR         goto yyerrlab1
261 /* Like YYERROR except do call yyerror.
262    This remains here temporarily to ease the
263    transition to the new meaning of YYERROR, for GCC.
264    Once GCC version 2 has supplanted version 1, this can go.  */
265 #define YYFAIL          goto yyerrlab
266 #define YYRECOVERING()  (!!yyerrstatus)
267 #define YYBACKUP(token, value) \
268 do                                                              \
269   if (yychar == YYEMPTY && yylen == 1)                          \
270     { yychar = (token), yylval = (value);                       \
271       yychar1 = YYTRANSLATE (yychar);                           \
272       YYPOPSTACK;                                               \
273       goto yybackup;                                            \
274     }                                                           \
275   else                                                          \
276     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
277 while (0)
278
279 #define YYTERROR        1
280 #define YYERRCODE       256
281
282 #ifndef YYPURE
283 #define YYLEX           yylex()
284 #endif
285
286 #ifdef YYPURE
287 #ifdef YYLSP_NEEDED
288 #ifdef YYLEX_PARAM
289 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
290 #else
291 #define YYLEX           yylex(&yylval, &yylloc)
292 #endif
293 #else /* not YYLSP_NEEDED */
294 #ifdef YYLEX_PARAM
295 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
296 #else
297 #define YYLEX           yylex(&yylval)
298 #endif
299 #endif /* not YYLSP_NEEDED */
300 #endif
301
302 /* If nonreentrant, generate the variables here */
303
304 #ifndef YYPURE
305
306 int yychar;                     /*  the lookahead symbol                */
307 YYSTYPE yylval;                 /*  the semantic value of the           */
308                                 /*  lookahead symbol                    */
309
310 #ifdef YYLSP_NEEDED
311 YYLTYPE yylloc;                 /*  location data for the lookahead     */
312                                 /*  symbol                              */
313 #endif
314
315 int yynerrs;                    /*  number of parse errors so far       */
316 #endif /* not YYPURE */
317
318 #if YYDEBUG != 0
319 int yydebug;                    /*  nonzero means print parse trace     */
320 /* Since this is uninitialized, it does not stop multiple parsers
321    from coexisting.  */
322 #endif
323
324 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
325
326 #ifndef YYINITDEPTH
327 #define YYINITDEPTH 200
328 #endif
329
330 /*  YYMAXDEPTH is the maximum size the stacks can grow to
331     (effective only if the built-in stack extension method is used).  */
332
333 #if YYMAXDEPTH == 0
334 #undef YYMAXDEPTH
335 #endif
336
337 #ifndef YYMAXDEPTH
338 #define YYMAXDEPTH 10000
339 #endif
340
341 /* Prevent warning if -Wstrict-prototypes.  */
342 #ifdef __GNUC__
343 int yyparse(void);
344 #endif
345
346 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
347 #define __yy_memcpy(FROM,TO,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
348 #else /* not GNU C or C++ */
349 #ifndef __cplusplus
350
351 /* This is the most reliable way to avoid incompatibilities
352    in available built-in functions on various systems.  */
353 static void
354 __yy_memcpy(from, to, count)
355      char *from;
356      char *to;
357      int count;
358 {
359     char *f = from;
360     char *t = to;
361     int i = count;
362
363     while (i-- > 0)
364         *t++ = *f++;
365 }
366
367 #else /* __cplusplus */
368
369 /* This is the most reliable way to avoid incompatibilities
370    in available built-in functions on various systems.  */
371 static void
372 __yy_memcpy(char *from, char *to, int count)
373 {
374     char *f = from;
375     char *t = to;
376     int i = count;
377
378     while (i-- > 0)
379         *t++ = *f++;
380 }
381
382 #endif
383 #endif
384
385 #line 192 "bison.simple"
386
387 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
388    into yyparse.  The argument should have type void *.
389    It should actually point to an object.
390    Grammar actions can access the variable by casting it
391    to the proper pointer type.  */
392
393 #ifdef YYPARSE_PARAM
394 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
395 #else
396 #define YYPARSE_PARAM
397 #define YYPARSE_PARAM_DECL
398 #endif
399
400 int
401 yyparse(YYPARSE_PARAM)
402     YYPARSE_PARAM_DECL
403 {
404     int yystate;
405     int yyn;
406     short *yyssp;
407     YYSTYPE *yyvsp;
408     int yyerrstatus;            /*  number of tokens to shift before error messages enabled */
409     int yychar1 = 0;            /*  lookahead token as an internal (translated) token number */
410
411     short yyssa[YYINITDEPTH];   /*  the state stack                     */
412     YYSTYPE yyvsa[YYINITDEPTH]; /*  the semantic value stack            */
413
414     short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
415     YYSTYPE *yyvs = yyvsa;      /*  to allow yyoverflow to reallocate them elsewhere */
416
417 #ifdef YYLSP_NEEDED
418     YYLTYPE yylsa[YYINITDEPTH]; /*  the location stack                  */
419     YYLTYPE *yyls = yylsa;
420     YYLTYPE *yylsp;
421
422 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
423 #else
424 #define YYPOPSTACK   (yyvsp--, yyssp--)
425 #endif
426
427     int yystacksize = YYINITDEPTH;
428
429 #ifdef YYPURE
430     int yychar;
431     YYSTYPE yylval;
432     int yynerrs;
433 #ifdef YYLSP_NEEDED
434     YYLTYPE yylloc;
435 #endif
436 #endif
437
438     YYSTYPE yyval;              /*  the variable used to return         */
439     /*  semantic values from the action     */
440     /*  routines                            */
441
442     int yylen;
443
444 #if YYDEBUG != 0
445     if (yydebug)
446         fprintf(stderr, "Starting parse\n");
447 #endif
448
449     yystate = 0;
450     yyerrstatus = 0;
451     yynerrs = 0;
452     yychar = YYEMPTY;           /* Cause a token to be read.  */
453
454     /* Initialize stack pointers.
455      * Waste one element of value and location stack
456      * so that they stay on the same level as the state stack.
457      * The wasted elements are never initialized.  */
458
459     yyssp = yyss - 1;
460     yyvsp = yyvs;
461 #ifdef YYLSP_NEEDED
462     yylsp = yyls;
463 #endif
464
465 /* Push a new state, which is found in  yystate  .  */
466 /* In all cases, when you get here, the value and location stacks
467    have just been pushed. so pushing a state here evens the stacks.  */
468   yynewstate:
469
470     *++yyssp = yystate;
471
472     if (yyssp >= yyss + yystacksize - 1) {
473         /* Give user a chance to reallocate the stack */
474         /* Use copies of these so that the &'s don't force the real ones into memory. */
475         YYSTYPE *yyvs1 = yyvs;
476         short *yyss1 = yyss;
477 #ifdef YYLSP_NEEDED
478         YYLTYPE *yyls1 = yyls;
479 #endif
480
481         /* Get the current used size of the three stacks, in elements.  */
482         int size = yyssp - yyss + 1;
483
484 #ifdef yyoverflow
485         /* Each stack pointer address is followed by the size of
486          * the data in use in that stack, in bytes.  */
487 #ifdef YYLSP_NEEDED
488         /* This used to be a conditional around just the two extra args,
489          * but that might be undefined if yyoverflow is a macro.  */
490         yyoverflow("parser stack overflow", &yyss1, size * sizeof(*yyssp),
491                    &yyvs1, size * sizeof(*yyvsp), &yyls1,
492                    size * sizeof(*yylsp), &yystacksize);
493 #else
494         yyoverflow("parser stack overflow", &yyss1, size * sizeof(*yyssp),
495                    &yyvs1, size * sizeof(*yyvsp), &yystacksize);
496 #endif
497
498         yyss = yyss1;
499         yyvs = yyvs1;
500 #ifdef YYLSP_NEEDED
501         yyls = yyls1;
502 #endif
503 #else /* no yyoverflow */
504         /* Extend the stack our own way.  */
505         if (yystacksize >= YYMAXDEPTH) {
506             yyerror("parser stack overflow");
507             return 2;
508         }
509         yystacksize *= 2;
510         if (yystacksize > YYMAXDEPTH)
511             yystacksize = YYMAXDEPTH;
512         yyss = (short *)alloca(yystacksize * sizeof(*yyssp));
513         __yy_memcpy((char *)yyss1, (char *)yyss, size * sizeof(*yyssp));
514         yyvs = (YYSTYPE *) alloca(yystacksize * sizeof(*yyvsp));
515         __yy_memcpy((char *)yyvs1, (char *)yyvs, size * sizeof(*yyvsp));
516 #ifdef YYLSP_NEEDED
517         yyls = (YYLTYPE *) alloca(yystacksize * sizeof(*yylsp));
518         __yy_memcpy((char *)yyls1, (char *)yyls, size * sizeof(*yylsp));
519 #endif
520 #endif /* no yyoverflow */
521
522         yyssp = yyss + size - 1;
523         yyvsp = yyvs + size - 1;
524 #ifdef YYLSP_NEEDED
525         yylsp = yyls + size - 1;
526 #endif
527
528 #if YYDEBUG != 0
529         if (yydebug)
530             fprintf(stderr, "Stack size increased to %d\n", yystacksize);
531 #endif
532
533         if (yyssp >= yyss + yystacksize - 1)
534             YYABORT;
535     }
536 #if YYDEBUG != 0
537     if (yydebug)
538         fprintf(stderr, "Entering state %d\n", yystate);
539 #endif
540
541     goto yybackup;
542   yybackup:
543
544 /* Do appropriate processing given the current state.  */
545 /* Read a lookahead token if we need one and don't already have one.  */
546 /* yyresume: */
547
548     /* First try to decide what to do without reference to lookahead token.  */
549
550     yyn = yypact[yystate];
551     if (yyn == YYFLAG)
552         goto yydefault;
553
554     /* Not known => get a lookahead token if don't already have one.  */
555
556     /* yychar is either YYEMPTY or YYEOF
557      * or a valid token in external form.  */
558
559     if (yychar == YYEMPTY) {
560 #if YYDEBUG != 0
561         if (yydebug)
562             fprintf(stderr, "Reading a token: ");
563 #endif
564         yychar = YYLEX;
565     }
566
567     /* Convert token to internal form (in yychar1) for indexing tables with */
568
569     if (yychar <= 0) {          /* This means end of input. */
570         yychar1 = 0;
571         yychar = YYEOF;         /* Don't call YYLEX any more */
572
573 #if YYDEBUG != 0
574         if (yydebug)
575             fprintf(stderr, "Now at end of input.\n");
576 #endif
577     } else {
578         yychar1 = YYTRANSLATE(yychar);
579
580 #if YYDEBUG != 0
581         if (yydebug) {
582             fprintf(stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
583             /* Give the individual parser a way to print the precise meaning
584              * of a token, for further debugging info.  */
585 #ifdef YYPRINT
586             YYPRINT(stderr, yychar, yylval);
587 #endif
588             fprintf(stderr, ")\n");
589         }
590 #endif
591     }
592
593     yyn += yychar1;
594     if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
595         goto yydefault;
596
597     yyn = yytable[yyn];
598
599     /* yyn is what to do for this token type in this state.
600      * Negative => reduce, -yyn is rule number.
601      * Positive => shift, yyn is new state.
602      * New state is final state => don't bother to shift,
603      * just return success.
604      * 0, or most negative number => error.  */
605
606     if (yyn < 0) {
607         if (yyn == YYFLAG)
608             goto yyerrlab;
609         yyn = -yyn;
610         goto yyreduce;
611     } else if (yyn == 0)
612         goto yyerrlab;
613
614     if (yyn == YYFINAL)
615         YYACCEPT;
616
617     /* Shift the lookahead token.  */
618
619 #if YYDEBUG != 0
620     if (yydebug)
621         fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
622 #endif
623
624     /* Discard the token being shifted unless it is eof.  */
625     if (yychar != YYEOF)
626         yychar = YYEMPTY;
627
628     *++yyvsp = yylval;
629 #ifdef YYLSP_NEEDED
630     *++yylsp = yylloc;
631 #endif
632
633     /* count tokens shifted since error; after three, turn off error status.  */
634     if (yyerrstatus)
635         yyerrstatus--;
636
637     yystate = yyn;
638     goto yynewstate;
639
640 /* Do the default action for the current state.  */
641   yydefault:
642
643     yyn = yydefact[yystate];
644     if (yyn == 0)
645         goto yyerrlab;
646
647 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
648   yyreduce:
649     yylen = yyr2[yyn];
650     if (yylen > 0)
651         yyval = yyvsp[1 - yylen];       /* implement default value of the action */
652
653 #if YYDEBUG != 0
654     if (yydebug) {
655         int i;
656
657         fprintf(stderr, "Reducing via rule %d (line %d), ", yyn,
658                 yyrline[yyn]);
659
660         /* Print the symbols being reduced, and their result.  */
661         for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
662             fprintf(stderr, "%s ", yytname[yyrhs[i]]);
663         fprintf(stderr, " -> %s\n", yytname[yyr1[yyn]]);
664     }
665 #endif
666
667
668     switch (yyn) {
669
670     case 1:
671 #line 51 "error_table.y"
672         {
673             table_name = ds(yyvsp[-2].dynstr);
674             current_token = table_name;
675             put_ecs();;
676             break;
677         }
678     case 2:
679 #line 57 "error_table.y"
680         {
681             current_token = yyvsp[-1].dynstr;
682             yyval.dynstr = yyvsp[0].dynstr;;
683             break;
684         }
685     case 3:
686 #line 60 "error_table.y"
687         {
688             current_token = yyvsp[0].dynstr;
689             set_table_fun(ds("1"));
690             yyval.dynstr = yyvsp[0].dynstr;
691             ;
692             break;
693         }
694     case 4:
695 #line 67 "error_table.y"
696         {
697             current_token = yyvsp[0].dynstr;
698             set_table_fun(yyvsp[0].dynstr);
699             yyval.dynstr = yyvsp[0].dynstr;;
700             break;
701         }
702     case 5:
703 #line 74 "error_table.y"
704         {
705             current_token = yyvsp[0].dynstr;
706             set_table_num(yyvsp[0].dynstr);
707             yyval.dynstr = yyvsp[0].dynstr;;
708             break;
709         }
710     case 8:
711 #line 84 "error_table.y"
712         {
713             add_ec(yyvsp[-2].dynstr, yyvsp[0].dynstr);
714             free(yyvsp[-2].dynstr);
715             free(yyvsp[0].dynstr);;
716             break;
717         }
718     case 9:
719 #line 88 "error_table.y"
720         {
721             add_ec_val(yyvsp[-4].dynstr, yyvsp[-2].dynstr, yyvsp[0].dynstr);
722             free(yyvsp[-4].dynstr);
723             free(yyvsp[-2].dynstr);
724             free(yyvsp[0].dynstr);
725             ;
726             break;
727         }
728     case 10:
729 #line 96 "error_table.y"
730         {
731             yyval.dynstr = ds(yyvsp[0].dynstr);
732             current_token = yyval.dynstr;;
733             break;
734         }
735     case 11:
736 #line 101 "error_table.y"
737         {
738             yyval.dynstr = ds(yyvsp[0].dynstr);
739             current_token = yyval.dynstr;;
740             break;
741         }
742     }
743     /* the action file gets copied in in place of this dollarsign */
744 #line 487 "bison.simple"
745
746     yyvsp -= yylen;
747     yyssp -= yylen;
748 #ifdef YYLSP_NEEDED
749     yylsp -= yylen;
750 #endif
751
752 #if YYDEBUG != 0
753     if (yydebug) {
754         short *ssp1 = yyss - 1;
755         fprintf(stderr, "state stack now");
756         while (ssp1 != yyssp)
757             fprintf(stderr, " %d", *++ssp1);
758         fprintf(stderr, "\n");
759     }
760 #endif
761
762     *++yyvsp = yyval;
763
764 #ifdef YYLSP_NEEDED
765     yylsp++;
766     if (yylen == 0) {
767         yylsp->first_line = yylloc.first_line;
768         yylsp->first_column = yylloc.first_column;
769         yylsp->last_line = (yylsp - 1)->last_line;
770         yylsp->last_column = (yylsp - 1)->last_column;
771         yylsp->text = 0;
772     } else {
773         yylsp->last_line = (yylsp + yylen - 1)->last_line;
774         yylsp->last_column = (yylsp + yylen - 1)->last_column;
775     }
776 #endif
777
778     /* Now "shift" the result of the reduction.
779      * Determine what state that goes to,
780      * based on the state we popped back to
781      * and the rule number reduced by.  */
782
783     yyn = yyr1[yyn];
784
785     yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
786     if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
787         yystate = yytable[yystate];
788     else
789         yystate = yydefgoto[yyn - YYNTBASE];
790
791     goto yynewstate;
792
793   yyerrlab:                     /* here on detecting error */
794
795     if (!yyerrstatus)
796         /* If not already recovering from an error, report this error.  */
797     {
798         ++yynerrs;
799
800 #ifdef YYERROR_VERBOSE
801         yyn = yypact[yystate];
802
803         if (yyn > YYFLAG && yyn < YYLAST) {
804             int size = 0;
805             char *msg;
806             int x, count;
807
808             count = 0;
809             /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
810             for (x = (yyn < 0 ? -yyn : 0);
811                  x < (sizeof(yytname) / sizeof(char *)); x++)
812                 if (yycheck[x + yyn] == x)
813                     size += strlen(yytname[x]) + 15, count++;
814             msg = (char *)malloc(size + 15);
815             if (msg != 0) {
816                 strcpy(msg, "parse error");
817
818                 if (count < 5) {
819                     count = 0;
820                     for (x = (yyn < 0 ? -yyn : 0);
821                          x < (sizeof(yytname) / sizeof(char *)); x++)
822                         if (yycheck[x + yyn] == x) {
823                             strcat(msg,
824                                    count == 0 ? ", expecting `" : " or `");
825                             strcat(msg, yytname[x]);
826                             strcat(msg, "'");
827                             count++;
828                         }
829                 }
830                 yyerror(msg);
831                 free(msg);
832             } else
833                 yyerror("parse error; also virtual memory exceeded");
834         } else
835 #endif /* YYERROR_VERBOSE */
836             yyerror("parse error");
837     }
838
839     goto yyerrlab1;
840   yyerrlab1:                    /* here on error raised explicitly by an action */
841
842     if (yyerrstatus == 3) {
843         /* if just tried and failed to reuse lookahead token after an error, discard it.  */
844
845         /* return failure if at end of input */
846         if (yychar == YYEOF)
847             YYABORT;
848
849 #if YYDEBUG != 0
850         if (yydebug)
851             fprintf(stderr, "Discarding token %d (%s).\n", yychar,
852                     yytname[yychar1]);
853 #endif
854
855         yychar = YYEMPTY;
856     }
857
858     /* Else will try to reuse lookahead token
859      * after shifting the error token.  */
860
861     yyerrstatus = 3;            /* Each real token shifted decrements this */
862
863     goto yyerrhandle;
864
865   yyerrdefault:         /* current state does not do anything special for the error token. */
866
867 #if 0
868     /* This is wrong; only states that explicitly want error tokens
869      * should shift them.  */
870     yyn = yydefact[yystate];    /* If its default is to accept any token, ok.  Otherwise pop it. */
871     if (yyn)
872         goto yydefault;
873 #endif
874
875   yyerrpop:                     /* pop the current state because it cannot handle the error token */
876
877     if (yyssp == yyss)
878         YYABORT;
879     yyvsp--;
880     yystate = *--yyssp;
881 #ifdef YYLSP_NEEDED
882     yylsp--;
883 #endif
884
885 #if YYDEBUG != 0
886     if (yydebug) {
887         short *ssp1 = yyss - 1;
888         fprintf(stderr, "Error: state stack now");
889         while (ssp1 != yyssp)
890             fprintf(stderr, " %d", *++ssp1);
891         fprintf(stderr, "\n");
892     }
893 #endif
894
895   yyerrhandle:
896
897     yyn = yypact[yystate];
898     if (yyn == YYFLAG)
899         goto yyerrdefault;
900
901     yyn += YYTERROR;
902     if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
903         goto yyerrdefault;
904
905     yyn = yytable[yyn];
906     if (yyn < 0) {
907         if (yyn == YYFLAG)
908             goto yyerrpop;
909         yyn = -yyn;
910         goto yyreduce;
911     } else if (yyn == 0)
912         goto yyerrpop;
913
914     if (yyn == YYFINAL)
915         YYACCEPT;
916
917 #if YYDEBUG != 0
918     if (yydebug)
919         fprintf(stderr, "Shifting error token, ");
920 #endif
921
922     *++yyvsp = yylval;
923 #ifdef YYLSP_NEEDED
924     *++yylsp = yylloc;
925 #endif
926
927     yystate = yyn;
928     goto yynewstate;
929 }
930
931 #line 105 "error_table.y"
932
933 /*
934  *
935  * Copyright 1986, 1987 by the MIT Student Information Processing Board
936  *
937  * For copyright info, see mit-sipb-cr.h.
938  */
939 #include <afs/param.h>
940 #include <assert.h>
941 #include <ctype.h>
942 #ifdef AFS_NT40_ENV
943 #include <afs/afsutil.h>
944 #endif
945 #include <sys/timeb.h>
946 #include "error_table.h"
947 #include "mit-sipb-cr.h"
948
949 /*
950  * Copyright 2000, International Business Machines Corporation and others.
951  * All Rights Reserved.
952  *
953  * This software has been released under the terms of the IBM Public
954  * License.  For details, see the LICENSE file in the top-level source
955  * directory or online at http://www.openafs.org/dl/license10.html
956  */
957
958 extern FILE *hfile, *cfile, *msfile;
959 extern int use_msf;
960
961 static afs_int32 gensym_n = 0;
962
963 char *
964 gensym(const char *x)
965 {
966     char *symbol;
967     if (!gensym_n) {
968         struct timeval tv;
969         gettimeofday(&tv, NULL);
970         gensym_n = (tv.tv_sec % 10000) * 100 + tv.tv_usec / 10000;
971     }
972     symbol = (char *)malloc(32 * sizeof(char));
973     gensym_n++;
974     sprintf(symbol, "et%ld", gensym_n);
975     return (symbol);
976 }
977
978 char *
979 ds(const char *string)
980 {
981     char *rv;
982     rv = (char *)malloc(strlen(string) + 1);
983     strcpy(rv, string);
984     return (rv);
985 }
986
987 char *
988 quote(const char *string)
989 {
990     char *rv;
991     rv = (char *)malloc(strlen(string) + 3);
992     strcpy(rv, "\"");
993     strcat(rv, string);
994     strcat(rv, "\"");
995     return (rv);
996 }
997
998 afs_int32 table_number = 0;
999 int current = 0;
1000 char **error_codes = (char **)NULL;
1001
1002 void
1003 add_ec(const char *name, const char *description)
1004 {
1005     if (msfile) {
1006         if (current > 0)
1007 #ifndef sun
1008             fprintf(msfile, "%d\t%s\n", current, description);
1009 #else
1010             fprintf(msfile, "%d %s\n", current, description);
1011 #endif /* !sun */
1012     } else {
1013         fprintf(cfile, "\t\"%s\",\n", description);
1014     }
1015     if (error_codes == (char **)NULL) {
1016         error_codes = (char **)malloc(sizeof(char *));
1017         *error_codes = (char *)NULL;
1018     }
1019     error_codes =
1020         (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
1021     error_codes[current++] = ds(name);
1022     error_codes[current] = (char *)NULL;
1023 }
1024
1025 void
1026 add_ec_val(const char *name, const char *val, const char *description)
1027 {
1028     const int ncurrent = atoi(val);
1029     if (ncurrent < current) {
1030         printf("Error code %s (%d) out of order", name, current);
1031         return;
1032     }
1033
1034     while (ncurrent > current) {
1035         if (!msfile)
1036             fputs("\t(char *)NULL,\n", cfile);
1037         current++;
1038     }
1039     if (msfile) {
1040         if (current > 0)
1041 #ifndef sun
1042             fprintf(msfile, "%d\t%s\n", current, description);
1043 #else
1044             fprintf(msfile, "%d %s\n", current, description);
1045 #endif /* ! sun */
1046     } else {
1047         fprintf(cfile, "\t\"%s\",\n", description);
1048     }
1049     if (error_codes == (char **)NULL) {
1050         error_codes = (char **)malloc(sizeof(char *));
1051         *error_codes = (char *)NULL;
1052     }
1053     error_codes =
1054         (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
1055     error_codes[current++] = ds(name);
1056     error_codes[current] = (char *)NULL;
1057 }
1058
1059 void
1060 put_ecs(void)
1061 {
1062     int i;
1063     for (i = 0; i < current; i++) {
1064         if (error_codes[i] != (char *)NULL)
1065             fprintf(hfile, "#define %-40s (%ldL)\n", error_codes[i],
1066                     table_number + i);
1067     }
1068 }
1069
1070 /*
1071  * char_to_num -- maps letters and numbers into a small numbering space
1072  *      uppercase ->  1-26
1073  *      lowercase -> 27-52
1074  *      digits    -> 53-62
1075  *      underscore-> 63
1076  */
1077
1078 static const char char_set[] =
1079     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
1080
1081 int
1082 char_to_num(char c)
1083 {
1084     const char *where;
1085     int diff;
1086
1087     where = strchr(char_set, c);
1088     if (where) {
1089         diff = where - char_set + 1;
1090         assert(diff < (1 << ERRCODE_RANGE));
1091         return diff;
1092     } else if (isprint(c))
1093         fprintf(stderr, "Illegal character `%c' in error table name\n", c);
1094     else
1095         fprintf(stderr, "Illegal character %03o in error table name\n", c);
1096     exit(1);
1097 }
1098
1099 void
1100 set_table_num(char *string)
1101 {
1102     if (msfile) {
1103         set_table_1num(string);
1104         return;
1105     }
1106     if (strlen(string) > 4) {
1107         fprintf(stderr, "Table name %s too long, truncated ", string);
1108         string[4] = '\0';
1109         fprintf(stderr, "to %s\n", string);
1110     }
1111     if (char_to_num(string[0]) > char_to_num('z')) {
1112         fprintf(stderr, "%s%s%s%s",
1113                 "First character of error table name must be ",
1114                 "a letter; name ``", string, "'' rejected\n");
1115         exit(1);
1116     }
1117     while (*string != '\0') {
1118         table_number = (table_number << BITS_PER_CHAR)
1119             + char_to_num(*string);
1120         string++;
1121     }
1122     table_number = table_number << ERRCODE_RANGE;
1123 }
1124
1125 void
1126 set_table_fun(char *astring)
1127 {
1128     char *tp;
1129     unsigned int tc;
1130
1131     for (tp = astring; (tc = *tp) != 0; tp++) {
1132         if (!isdigit(tc)) {
1133             fprintf(stderr,
1134                     "Table function '%s' must be a decimal integer.\n",
1135                     astring);
1136             exit(1);
1137         }
1138     }
1139     if (msfile)
1140         table_number += (atoi(astring)) << 28;
1141 }
1142
1143 /* for compatibility with old comerr's, we truncate package name to 4
1144  * characters, but only store first 3 in the error code.  Note that this
1145  * function, as a side effect, truncates the table name down to 4 chars.
1146  */
1147 void
1148 set_table_1num(char *string)
1149 {
1150     afs_int32 temp;
1151     int ctr;
1152
1153     if ((temp = strlen(string)) > 4) {
1154         fprintf(stderr, "Table name %s too long, truncated ", string);
1155         string[4] = '\0';
1156         fprintf(stderr, "to %s\n", string);
1157     }
1158     if (temp == 4) {
1159         fprintf(stderr,
1160                 "Table name %s too long, only 3 characters fit in error code.\n",
1161                 string);
1162     }
1163     if (char_to_1num(string[0]) > char_to_1num('z')) {
1164         fprintf(stderr, "%s%s%s%s",
1165                 "First character of error table name must be ",
1166                 "a letter; name ``", string, "'' rejected\n");
1167         exit(1);
1168     }
1169     temp = 0;
1170     for (ctr = 0; ctr < 3; ctr++) {     /* copy at most 3 chars to integer */
1171         if (*string == '\0')
1172             break;              /* and watch for early end */
1173         temp = (temp * 050)     /* "radix fifty" is base 050 = 40 */
1174             +char_to_1num(*string);
1175         string++;
1176     }
1177     table_number += temp << 12;
1178 }
1179
1180 /*
1181  * char_to_num -- maps letters and numbers into very small space
1182  *      0-9        -> 0-9
1183  *      mixed case -> 10-35
1184  *      _          -> 36
1185  *      others are reserved
1186  */
1187
1188 static const char char_1set[] = "abcdefghijklmnopqrstuvwxyz_0123456789";
1189
1190 int
1191 char_to_1num(char c)
1192 {
1193     const char *where;
1194     int diff;
1195
1196     if (isupper(c))
1197         c = tolower(c);
1198
1199     where = strchr(char_1set, c);
1200     if (where) {
1201         /* start at 1 so we can decode */
1202         diff = where - char_1set;
1203         assert(diff < 050);     /* it is radix 50, after all */
1204         return diff;
1205     } else if (isprint(c))
1206         fprintf(stderr, "Illegal character `%c' in error table name\n", c);
1207     else
1208         fprintf(stderr, "Illegal character %03o in error table name\n", c);
1209     exit(1);
1210 }
1211
1212 #ifdef AFS_NT40_ENV
1213 #include "et_lex.lex_nt.c"
1214 #else
1215 #include "et_lex.lex.c"
1216 #endif