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