c5ea7435a9f4f4712fd454d1ae24a3a827448355
[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 *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 = (char *)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 #if 0
867     /* This is wrong; only states that explicitly want error tokens
868      * should shift them.  */
869     yyn = yydefact[yystate];    /* If its default is to accept any token, ok.  Otherwise pop it. */
870     if (yyn)
871         goto yydefault;
872 #endif
873
874   yyerrpop:                     /* pop the current state because it cannot handle the error token */
875
876     if (yyssp == yyss)
877         YYABORT;
878     yyvsp--;
879     yystate = *--yyssp;
880 #ifdef YYLSP_NEEDED
881     yylsp--;
882 #endif
883
884 #if YYDEBUG != 0
885     if (yydebug) {
886         short *ssp1 = yyss - 1;
887         fprintf(stderr, "Error: state stack now");
888         while (ssp1 != yyssp)
889             fprintf(stderr, " %d", *++ssp1);
890         fprintf(stderr, "\n");
891     }
892 #endif
893
894   yyerrhandle:
895
896     yyn = yypact[yystate];
897     if (yyn == YYFLAG)
898         goto yyerrdefault;
899
900     yyn += YYTERROR;
901     if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
902         goto yyerrdefault;
903
904     yyn = yytable[yyn];
905     if (yyn < 0) {
906         if (yyn == YYFLAG)
907             goto yyerrpop;
908         yyn = -yyn;
909         goto yyreduce;
910     } else if (yyn == 0)
911         goto yyerrpop;
912
913     if (yyn == YYFINAL)
914         YYACCEPT;
915
916 #if YYDEBUG != 0
917     if (yydebug)
918         fprintf(stderr, "Shifting error token, ");
919 #endif
920
921     *++yyvsp = yylval;
922 #ifdef YYLSP_NEEDED
923     *++yylsp = yylloc;
924 #endif
925
926     yystate = yyn;
927     goto yynewstate;
928 }
929
930 #line 105 "error_table.y"
931
932 /*
933  *
934  * Copyright 1986, 1987 by the MIT Student Information Processing Board
935  *
936  * For copyright info, see mit-sipb-cr.h.
937  */
938 #include <afs/param.h>
939 #include <assert.h>
940 #include <ctype.h>
941 #ifdef AFS_NT40_ENV
942 #include <afs/afsutil.h>
943 #endif
944 #include <sys/timeb.h>
945 #include "error_table.h"
946 #include "mit-sipb-cr.h"
947
948 /*
949  * Copyright 2000, International Business Machines Corporation and others.
950  * All Rights Reserved.
951  *
952  * This software has been released under the terms of the IBM Public
953  * License.  For details, see the LICENSE file in the top-level source
954  * directory or online at http://www.openafs.org/dl/license10.html
955  */
956
957 extern FILE *hfile, *cfile, *msfile;
958 extern int use_msf;
959
960 static afs_int32 gensym_n = 0;
961
962 char *
963 gensym(const char *x)
964 {
965     char *symbol;
966     if (!gensym_n) {
967         struct timeval tv;
968         gettimeofday(&tv, NULL);
969         gensym_n = (tv.tv_sec % 10000) * 100 + tv.tv_usec / 10000;
970     }
971     symbol = (char *)malloc(32 * sizeof(char));
972     gensym_n++;
973     sprintf(symbol, "et%ld", gensym_n);
974     return (symbol);
975 }
976
977 char *
978 quote(const char *string)
979 {
980     char *rv;
981     rv = (char *)malloc(strlen(string) + 3);
982     strcpy(rv, "\"");
983     strcat(rv, string);
984     strcat(rv, "\"");
985     return (rv);
986 }
987
988 afs_int32 table_number = 0;
989 int current = 0;
990 char **error_codes = (char **)NULL;
991
992 void
993 add_ec(const char *name, const char *description)
994 {
995     if (msfile) {
996         if (current > 0)
997 #ifndef sun
998             fprintf(msfile, "%d\t%s\n", current, description);
999 #else
1000             fprintf(msfile, "%d %s\n", current, description);
1001 #endif /* !sun */
1002     } else {
1003         fprintf(cfile, "\t\"%s\",\n", description);
1004     }
1005     if (error_codes == (char **)NULL) {
1006         error_codes = (char **)malloc(sizeof(char *));
1007         *error_codes = (char *)NULL;
1008     }
1009     error_codes =
1010         (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
1011     error_codes[current++] = strdup(name);
1012     error_codes[current] = (char *)NULL;
1013 }
1014
1015 void
1016 add_ec_val(const char *name, const char *val, const char *description)
1017 {
1018     const int ncurrent = atoi(val);
1019     if (ncurrent < current) {
1020         printf("Error code %s (%d) out of order", name, current);
1021         return;
1022     }
1023
1024     while (ncurrent > current) {
1025         if (!msfile)
1026             fputs("\t(char *)NULL,\n", cfile);
1027         current++;
1028     }
1029     if (msfile) {
1030         if (current > 0)
1031 #ifndef sun
1032             fprintf(msfile, "%d\t%s\n", current, description);
1033 #else
1034             fprintf(msfile, "%d %s\n", current, description);
1035 #endif /* ! sun */
1036     } else {
1037         fprintf(cfile, "\t\"%s\",\n", description);
1038     }
1039     if (error_codes == (char **)NULL) {
1040         error_codes = (char **)malloc(sizeof(char *));
1041         *error_codes = (char *)NULL;
1042     }
1043     error_codes =
1044         (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
1045     error_codes[current++] = strdup(name);
1046     error_codes[current] = (char *)NULL;
1047 }
1048
1049 void
1050 put_ecs(void)
1051 {
1052     int i;
1053     for (i = 0; i < current; i++) {
1054         if (error_codes[i] != (char *)NULL)
1055             fprintf(hfile, "#define %-40s (%ldL)\n", error_codes[i],
1056                     table_number + i);
1057     }
1058 }
1059
1060 /*
1061  * char_to_num -- maps letters and numbers into a small numbering space
1062  *      uppercase ->  1-26
1063  *      lowercase -> 27-52
1064  *      digits    -> 53-62
1065  *      underscore-> 63
1066  */
1067
1068 static const char char_set[] =
1069     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
1070
1071 int
1072 char_to_num(char c)
1073 {
1074     const char *where;
1075     int diff;
1076
1077     where = strchr(char_set, c);
1078     if (where) {
1079         diff = where - char_set + 1;
1080         assert(diff < (1 << ERRCODE_RANGE));
1081         return diff;
1082     } else if (isprint(c))
1083         fprintf(stderr, "Illegal character `%c' in error table name\n", c);
1084     else
1085         fprintf(stderr, "Illegal character %03o in error table name\n", c);
1086     exit(1);
1087 }
1088
1089 void
1090 set_table_num(char *string)
1091 {
1092     if (msfile) {
1093         set_table_1num(string);
1094         return;
1095     }
1096     if (strlen(string) > 4) {
1097         fprintf(stderr, "Table name %s too long, truncated ", string);
1098         string[4] = '\0';
1099         fprintf(stderr, "to %s\n", string);
1100     }
1101     if (char_to_num(string[0]) > char_to_num('z')) {
1102         fprintf(stderr, "%s%s%s%s",
1103                 "First character of error table name must be ",
1104                 "a letter; name ``", string, "'' rejected\n");
1105         exit(1);
1106     }
1107     while (*string != '\0') {
1108         table_number = (table_number << BITS_PER_CHAR)
1109             + char_to_num(*string);
1110         string++;
1111     }
1112     table_number = table_number << ERRCODE_RANGE;
1113 }
1114
1115 void
1116 set_table_fun(char *astring)
1117 {
1118     char *tp;
1119     unsigned int tc;
1120
1121     for (tp = astring; (tc = *tp) != 0; tp++) {
1122         if (!isdigit(tc)) {
1123             fprintf(stderr,
1124                     "Table function '%s' must be a decimal integer.\n",
1125                     astring);
1126             exit(1);
1127         }
1128     }
1129     if (msfile)
1130         table_number += (atoi(astring)) << 28;
1131 }
1132
1133 /* for compatibility with old comerr's, we truncate package name to 4
1134  * characters, but only store first 3 in the error code.  Note that this
1135  * function, as a side effect, truncates the table name down to 4 chars.
1136  */
1137 void
1138 set_table_1num(char *string)
1139 {
1140     afs_int32 temp;
1141     int ctr;
1142
1143     if ((temp = strlen(string)) > 4) {
1144         fprintf(stderr, "Table name %s too long, truncated ", string);
1145         string[4] = '\0';
1146         fprintf(stderr, "to %s\n", string);
1147     }
1148     if (temp == 4) {
1149         fprintf(stderr,
1150                 "Table name %s too long, only 3 characters fit in error code.\n",
1151                 string);
1152     }
1153     if (char_to_1num(string[0]) > char_to_1num('z')) {
1154         fprintf(stderr, "%s%s%s%s",
1155                 "First character of error table name must be ",
1156                 "a letter; name ``", string, "'' rejected\n");
1157         exit(1);
1158     }
1159     temp = 0;
1160     for (ctr = 0; ctr < 3; ctr++) {     /* copy at most 3 chars to integer */
1161         if (*string == '\0')
1162             break;              /* and watch for early end */
1163         temp = (temp * 050)     /* "radix fifty" is base 050 = 40 */
1164             +char_to_1num(*string);
1165         string++;
1166     }
1167     table_number += temp << 12;
1168 }
1169
1170 /*
1171  * char_to_num -- maps letters and numbers into very small space
1172  *      0-9        -> 0-9
1173  *      mixed case -> 10-35
1174  *      _          -> 36
1175  *      others are reserved
1176  */
1177
1178 static const char char_1set[] = "abcdefghijklmnopqrstuvwxyz_0123456789";
1179
1180 int
1181 char_to_1num(char c)
1182 {
1183     const char *where;
1184     int diff;
1185
1186     if (isupper(c))
1187         c = tolower(c);
1188
1189     where = strchr(char_1set, c);
1190     if (where) {
1191         /* start at 1 so we can decode */
1192         diff = where - char_1set;
1193         assert(diff < 050);     /* it is radix 50, after all */
1194         return diff;
1195     } else if (isprint(c))
1196         fprintf(stderr, "Illegal character `%c' in error table name\n", c);
1197     else
1198         fprintf(stderr, "Illegal character %03o in error table name\n", c);
1199     exit(1);
1200 }
1201
1202 #ifdef AFS_NT40_ENV
1203 #include "et_lex.lex_nt.c"
1204 #else
1205 #include "et_lex.lex.c"
1206 #endif