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