2 /* A Bison parser, made from error_table.y with Bison version GNU Bison version 1.24
5 #define YYBISON 1 /* Identify Bison output. */
7 #define ERROR_TABLE 258
8 #define ERROR_CODE_ENTRY 259
11 #define QUOTED_STRING 262
13 #line 1 "error_table.y"
15 #include <afsconfig.h>
16 #include <afs/param.h>
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.
41 char *current_token = (char *)NULL;
42 extern char *table_name;
44 char *ds(const char *string);
45 char *quote(const char *string);
46 void set_table_1num(char *string);
47 int char_to_1num(char c);
48 void add_ec(const char *name, const char *description);
49 void add_ec_val(const char *name, const char *val, const char *description);
51 void set_table_num(char *string);
52 void set_table_fun(char *astring);
55 #line 38 "error_table.y"
59 #line 45 "error_table.y"
75 #define YYLTYPE yyltype
92 #define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 18)
94 static const char yytranslate[] = { 0,
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, 8, 2, 2, 2, 2, 2, 2,
100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 9, 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, 2, 2, 2, 2, 2,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
125 static const short yyprhs[] = { 0,
126 0, 5, 8, 10, 12, 14, 17, 19, 24, 31,
130 static const short yyrhs[] = { 3,
131 11, 14, 5, 0, 12, 13, 0, 13, 0, 6,
132 0, 6, 0, 14, 15, 0, 15, 0, 4, 16,
133 8, 17, 0, 4, 16, 9, 6, 8, 17, 0,
140 static const short yyrline[] = { 0,
141 50, 56, 59, 66, 73, 79, 80, 83, 87, 95,
145 static const char * const yytname[] = { "$","error","$undefined.","ERROR_TABLE",
146 "ERROR_CODE_ENTRY","END","STRING","QUOTED_STRING","','","'='","error_table",
147 "header","table_fun","table_id","error_codes","ec_entry","ec_name","description",
152 static const short yyr1[] = { 0,
153 10, 11, 11, 12, 13, 14, 14, 15, 15, 16,
157 static const short yyr2[] = { 0,
158 4, 2, 1, 1, 1, 2, 1, 4, 6, 1,
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,
168 static const short yydefgoto[] = { 22,
169 3, 4, 5, 7, 8, 12, 18
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,
178 static const short yypgoto[] = {-32768,
179 -32768,-32768, 11,-32768, 10,-32768, -2
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
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
195 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
196 #line 3 "bison.simple"
198 /* Skeleton output parser for bison,
199 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
201 This program is free software; you can redistribute it and/or modify
202 it under the terms of the GNU General Public License as published by
203 the Free Software Foundation; either version 2, or (at your option)
206 This program is distributed in the hope that it will be useful,
207 but WITHOUT ANY WARRANTY; without even the implied warranty of
208 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
209 GNU General Public License for more details.
211 You should have received a copy of the GNU General Public License
212 along with this program; if not, write to the Free Software
213 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
215 /* As a special exception, when this file is copied by Bison into a
216 Bison output file, you may use that output file without restriction.
217 This special exception was added by the Free Software Foundation
218 in version 1.24 of Bison. */
222 #define alloca __builtin_alloca
223 #else /* not GNU C. */
224 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
226 #else /* not sparc */
227 #if defined (MSDOS) && !defined (__TURBOC__)
229 #else /* not MSDOS, or __TURBOC__ */
233 #else /* not MSDOS, __TURBOC__, or _AIX */
237 void *alloca (unsigned int);
239 #else /* not __cplusplus */
241 #endif /* not __cplusplus */
243 #endif /* not _AIX */
244 #endif /* not MSDOS, or __TURBOC__ */
245 #endif /* not sparc. */
246 #endif /* not GNU C. */
247 #endif /* alloca not defined. */
249 /* This is the parser code that is written into each bison parser
250 when the %semantic_parser declaration is not specified in the grammar.
251 It was written by Richard Stallman by simplifying the hairy parser
252 used when %semantic_parser is specified. */
254 /* Note: there must be only one dollar sign in this file.
255 It is replaced by the list of actions, each action
256 as one case of the switch. */
258 #define yyerrok (yyerrstatus = 0)
259 #define yyclearin (yychar = YYEMPTY)
262 #define YYACCEPT return(0)
263 #define YYABORT return(1)
264 #define YYERROR goto yyerrlab1
265 /* Like YYERROR except do call yyerror.
266 This remains here temporarily to ease the
267 transition to the new meaning of YYERROR, for GCC.
268 Once GCC version 2 has supplanted version 1, this can go. */
269 #define YYFAIL goto yyerrlab
270 #define YYRECOVERING() (!!yyerrstatus)
271 #define YYBACKUP(token, value) \
273 if (yychar == YYEMPTY && yylen == 1) \
274 { yychar = (token), yylval = (value); \
275 yychar1 = YYTRANSLATE (yychar); \
280 { yyerror ("syntax error: cannot back up"); YYERROR; } \
284 #define YYERRCODE 256
287 #define YYLEX yylex()
293 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
295 #define YYLEX yylex(&yylval, &yylloc)
297 #else /* not YYLSP_NEEDED */
299 #define YYLEX yylex(&yylval, YYLEX_PARAM)
301 #define YYLEX yylex(&yylval)
303 #endif /* not YYLSP_NEEDED */
306 /* If nonreentrant, generate the variables here */
310 int yychar; /* the lookahead symbol */
311 YYSTYPE yylval; /* the semantic value of the */
312 /* lookahead symbol */
315 YYLTYPE yylloc; /* location data for the lookahead */
319 int yynerrs; /* number of parse errors so far */
320 #endif /* not YYPURE */
323 int yydebug; /* nonzero means print parse trace */
324 /* Since this is uninitialized, it does not stop multiple parsers
328 /* YYINITDEPTH indicates the initial size of the parser's stacks */
331 #define YYINITDEPTH 200
334 /* YYMAXDEPTH is the maximum size the stacks can grow to
335 (effective only if the built-in stack extension method is used). */
342 #define YYMAXDEPTH 10000
345 /* Prevent warning if -Wstrict-prototypes. */
350 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
351 #define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
352 #else /* not GNU C or C++ */
355 /* This is the most reliable way to avoid incompatibilities
356 in available built-in functions on various systems. */
358 __yy_memcpy (from, to, count)
363 register char *f = from;
364 register char *t = to;
365 register int i = count;
371 #else /* __cplusplus */
373 /* This is the most reliable way to avoid incompatibilities
374 in available built-in functions on various systems. */
376 __yy_memcpy (char *from, char *to, int count)
378 register char *f = from;
379 register char *t = to;
380 register int i = count;
389 #line 192 "bison.simple"
391 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
392 into yyparse. The argument should have type void *.
393 It should actually point to an object.
394 Grammar actions can access the variable by casting it
395 to the proper pointer type. */
398 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
400 #define YYPARSE_PARAM
401 #define YYPARSE_PARAM_DECL
405 yyparse(YYPARSE_PARAM)
408 register int yystate;
410 register short *yyssp;
411 register YYSTYPE *yyvsp;
412 int yyerrstatus; /* number of tokens to shift before error messages enabled */
413 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
415 short yyssa[YYINITDEPTH]; /* the state stack */
416 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
418 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
419 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
422 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
423 YYLTYPE *yyls = yylsa;
426 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
428 #define YYPOPSTACK (yyvsp--, yyssp--)
431 int yystacksize = YYINITDEPTH;
442 YYSTYPE yyval; /* the variable used to return */
443 /* semantic values from the action */
450 fprintf(stderr, "Starting parse\n");
456 yychar = YYEMPTY; /* Cause a token to be read. */
458 /* Initialize stack pointers.
459 Waste one element of value and location stack
460 so that they stay on the same level as the state stack.
461 The wasted elements are never initialized. */
469 /* Push a new state, which is found in yystate . */
470 /* In all cases, when you get here, the value and location stacks
471 have just been pushed. so pushing a state here evens the stacks. */
476 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;
483 YYLTYPE *yyls1 = yyls;
486 /* Get the current used size of the three stacks, in elements. */
487 int size = yyssp - yyss + 1;
490 /* Each stack pointer address is followed by the size of
491 the data in use in that stack, in bytes. */
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",
496 &yyss1, size * sizeof (*yyssp),
497 &yyvs1, size * sizeof (*yyvsp),
498 &yyls1, size * sizeof (*yylsp),
501 yyoverflow("parser stack overflow",
502 &yyss1, size * sizeof (*yyssp),
503 &yyvs1, size * sizeof (*yyvsp),
507 yyss = yyss1; yyvs = yyvs1;
511 #else /* no yyoverflow */
512 /* Extend the stack our own way. */
513 if (yystacksize >= YYMAXDEPTH)
515 yyerror("parser stack overflow");
519 if (yystacksize > YYMAXDEPTH)
520 yystacksize = YYMAXDEPTH;
521 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
522 __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
523 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
524 __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
526 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
527 __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
529 #endif /* no yyoverflow */
531 yyssp = yyss + size - 1;
532 yyvsp = yyvs + size - 1;
534 yylsp = yyls + size - 1;
539 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
542 if (yyssp >= yyss + yystacksize - 1)
548 fprintf(stderr, "Entering state %d\n", yystate);
554 /* Do appropriate processing given the current state. */
555 /* Read a lookahead token if we need one and don't already have one. */
558 /* First try to decide what to do without reference to lookahead token. */
560 yyn = yypact[yystate];
564 /* Not known => get a lookahead token if don't already have one. */
566 /* yychar is either YYEMPTY or YYEOF
567 or a valid token in external form. */
569 if (yychar == YYEMPTY)
573 fprintf(stderr, "Reading a token: ");
578 /* Convert token to internal form (in yychar1) for indexing tables with */
580 if (yychar <= 0) /* This means end of input. */
583 yychar = YYEOF; /* Don't call YYLEX any more */
587 fprintf(stderr, "Now at end of input.\n");
592 yychar1 = YYTRANSLATE(yychar);
597 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
598 /* Give the individual parser a way to print the precise meaning
599 of a token, for further debugging info. */
601 YYPRINT (stderr, yychar, yylval);
603 fprintf (stderr, ")\n");
609 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
614 /* yyn is what to do for this token type in this state.
615 Negative => reduce, -yyn is rule number.
616 Positive => shift, yyn is new state.
617 New state is final state => don't bother to shift,
619 0, or most negative number => error. */
634 /* Shift the lookahead token. */
638 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
641 /* Discard the token being shifted unless it is eof. */
650 /* count tokens shifted since error; after three, turn off error status. */
651 if (yyerrstatus) yyerrstatus--;
656 /* Do the default action for the current state. */
659 yyn = yydefact[yystate];
663 /* Do a reduction. yyn is the number of a rule to reduce with. */
667 yyval = yyvsp[1-yylen]; /* implement default value of the action */
674 fprintf (stderr, "Reducing via rule %d (line %d), ",
677 /* Print the symbols being reduced, and their result. */
678 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
679 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
680 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
688 #line 51 "error_table.y"
689 { table_name = ds(yyvsp[-2].dynstr);
690 current_token = table_name;
694 #line 57 "error_table.y"
695 { current_token = yyvsp[-1].dynstr;
696 yyval.dynstr = yyvsp[0].dynstr; ;
699 #line 60 "error_table.y"
700 { current_token = yyvsp[0].dynstr;
701 set_table_fun(ds("1"));
702 yyval.dynstr = yyvsp[0].dynstr;
706 #line 67 "error_table.y"
707 { current_token = yyvsp[0].dynstr;
708 set_table_fun(yyvsp[0].dynstr);
709 yyval.dynstr = yyvsp[0].dynstr; ;
712 #line 74 "error_table.y"
713 { current_token = yyvsp[0].dynstr;
714 set_table_num(yyvsp[0].dynstr);
715 yyval.dynstr = yyvsp[0].dynstr; ;
718 #line 84 "error_table.y"
719 { add_ec(yyvsp[-2].dynstr, yyvsp[0].dynstr);
720 free(yyvsp[-2].dynstr);
721 free(yyvsp[0].dynstr); ;
724 #line 88 "error_table.y"
725 { add_ec_val(yyvsp[-4].dynstr, yyvsp[-2].dynstr, yyvsp[0].dynstr);
726 free(yyvsp[-4].dynstr);
727 free(yyvsp[-2].dynstr);
728 free(yyvsp[0].dynstr);
732 #line 96 "error_table.y"
733 { yyval.dynstr = ds(yyvsp[0].dynstr);
734 current_token = yyval.dynstr; ;
737 #line 101 "error_table.y"
738 { yyval.dynstr = ds(yyvsp[0].dynstr);
739 current_token = yyval.dynstr; ;
742 /* the action file gets copied in in place of this dollarsign */
743 #line 487 "bison.simple"
754 short *ssp1 = yyss - 1;
755 fprintf (stderr, "state stack now");
756 while (ssp1 != yyssp)
757 fprintf (stderr, " %d", *++ssp1);
758 fprintf (stderr, "\n");
768 yylsp->first_line = yylloc.first_line;
769 yylsp->first_column = yylloc.first_column;
770 yylsp->last_line = (yylsp-1)->last_line;
771 yylsp->last_column = (yylsp-1)->last_column;
776 yylsp->last_line = (yylsp+yylen-1)->last_line;
777 yylsp->last_column = (yylsp+yylen-1)->last_column;
781 /* Now "shift" the result of the reduction.
782 Determine what state that goes to,
783 based on the state we popped back to
784 and the rule number reduced by. */
788 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
789 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
790 yystate = yytable[yystate];
792 yystate = yydefgoto[yyn - YYNTBASE];
796 yyerrlab: /* here on detecting error */
799 /* If not already recovering from an error, report this error. */
803 #ifdef YYERROR_VERBOSE
804 yyn = yypact[yystate];
806 if (yyn > YYFLAG && yyn < YYLAST)
813 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
814 for (x = (yyn < 0 ? -yyn : 0);
815 x < (sizeof(yytname) / sizeof(char *)); x++)
816 if (yycheck[x + yyn] == x)
817 size += strlen(yytname[x]) + 15, count++;
818 msg = (char *) malloc(size + 15);
821 strcpy(msg, "parse error");
826 for (x = (yyn < 0 ? -yyn : 0);
827 x < (sizeof(yytname) / sizeof(char *)); x++)
828 if (yycheck[x + yyn] == x)
830 strcat(msg, count == 0 ? ", expecting `" : " or `");
831 strcat(msg, yytname[x]);
840 yyerror ("parse error; also virtual memory exceeded");
843 #endif /* YYERROR_VERBOSE */
844 yyerror("parse error");
848 yyerrlab1: /* here on error raised explicitly by an action */
850 if (yyerrstatus == 3)
852 /* if just tried and failed to reuse lookahead token after an error, discard it. */
854 /* return failure if at end of input */
860 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
866 /* Else will try to reuse lookahead token
867 after shifting the error token. */
869 yyerrstatus = 3; /* Each real token shifted decrements this */
873 yyerrdefault: /* current state does not do anything special for the error token. */
876 /* This is wrong; only states that explicitly want error tokens
877 should shift them. */
878 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
879 if (yyn) goto yydefault;
882 yyerrpop: /* pop the current state because it cannot handle the error token */
884 if (yyssp == yyss) YYABORT;
894 short *ssp1 = yyss - 1;
895 fprintf (stderr, "Error: state stack now");
896 while (ssp1 != yyssp)
897 fprintf (stderr, " %d", *++ssp1);
898 fprintf (stderr, "\n");
904 yyn = yypact[yystate];
909 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
928 fprintf(stderr, "Shifting error token, ");
939 #line 105 "error_table.y"
943 * Copyright 1986, 1987 by the MIT Student Information Processing Board
945 * For copyright info, see mit-sipb-cr.h.
950 #include <afs/param.h>
955 #include <sys/types.h>
956 #include <afs/afsutil.h>
958 #include <sys/time.h>
960 #include <sys/timeb.h>
961 #include "error_table.h"
962 #include "mit-sipb-cr.h"
965 /* Copyright (C) 1998 Transarc Corporation. All rights reserved.
969 extern FILE *hfile, *cfile, *msfile;
972 static afs_int32 gensym_n = 0;
974 char *gensym(const char *x)
979 gettimeofday(&tv, (void *)0);
980 gensym_n = (tv.tv_sec%10000)*100 + tv.tv_usec/10000;
982 symbol = (char *)malloc(32 * sizeof(char));
984 sprintf(symbol, "et%ld", gensym_n);
989 ds(const char *string)
992 rv = (char *)malloc(strlen(string)+1);
998 quote(const char *string)
1001 rv = (char *)malloc(strlen(string)+3);
1008 afs_int32 table_number = 0;
1010 char **error_codes = (char **)NULL;
1012 void add_ec(const char *name, const char *description)
1017 fprintf(msfile, "%d\t%s\n", current, description);
1019 fprintf(msfile, "%d %s\n", current, description);
1022 fprintf(cfile, "\t\"%s\",\n", description);
1024 if (error_codes == (char **)NULL) {
1025 error_codes = (char **)malloc(sizeof(char *));
1026 *error_codes = (char *)NULL;
1028 error_codes = (char **)realloc((char *)error_codes,
1029 (current + 2)*sizeof(char *));
1030 error_codes[current++] = ds(name);
1031 error_codes[current] = (char *)NULL;
1034 void add_ec_val(const char *name, const char *val, const char *description)
1036 const int ncurrent = atoi(val);
1037 if (ncurrent < current) {
1038 printf("Error code %s (%d) out of order", name,
1043 while (ncurrent > current) {
1045 fputs("\t(char *)NULL,\n", cfile);
1051 fprintf(msfile, "%d\t%s\n", current, description);
1053 fprintf(msfile, "%d %s\n", current, description);
1056 fprintf(cfile, "\t\"%s\",\n", description);
1058 if (error_codes == (char **)NULL) {
1059 error_codes = (char **)malloc(sizeof(char *));
1060 *error_codes = (char *)NULL;
1062 error_codes = (char **)realloc((char *)error_codes,
1063 (current + 2)*sizeof(char *));
1064 error_codes[current++] = ds(name);
1065 error_codes[current] = (char *)NULL;
1071 for (i = 0; i < current; i++) {
1072 if (error_codes[i] != (char *)NULL)
1073 fprintf(hfile, "#define %-40s (%ldL)\n",
1074 error_codes[i], table_number + i);
1079 * char_to_num -- maps letters and numbers into a small numbering space
1081 * lowercase -> 27-52
1086 static const char char_set[] =
1087 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
1089 int char_to_num(char c)
1094 where = strchr (char_set, c);
1096 diff = where - char_set + 1;
1097 assert (diff < (1 << ERRCODE_RANGE));
1100 else if (isprint (c))
1102 "Illegal character `%c' in error table name\n",
1106 "Illegal character %03o in error table name\n",
1111 void set_table_num(char *string)
1114 set_table_1num(string);
1117 if (strlen(string) > 4) {
1118 fprintf(stderr, "Table name %s too long, truncated ",
1121 fprintf(stderr, "to %s\n", string);
1123 if (char_to_num (string[0]) > char_to_num ('z')) {
1124 fprintf (stderr, "%s%s%s%s",
1125 "First character of error table name must be ",
1126 "a letter; name ``",
1127 string, "'' rejected\n");
1130 while (*string != '\0') {
1131 table_number = (table_number << BITS_PER_CHAR)
1132 + char_to_num(*string);
1135 table_number = table_number << ERRCODE_RANGE;
1138 void set_table_fun(char *astring)
1143 for(tp=astring; (tc = *tp) != 0; tp++) {
1145 fprintf(stderr, "Table function '%s' must be a decimal integer.\n",
1151 table_number += (atoi(astring)) << 28;
1154 /* for compatibility with old comerr's, we truncate package name to 4
1155 * characters, but only store first 3 in the error code. Note that this
1156 * function, as a side effect, truncates the table name down to 4 chars.
1158 void set_table_1num(char *string)
1163 if ((temp = strlen(string)) > 4) {
1164 fprintf(stderr, "Table name %s too long, truncated ",
1167 fprintf(stderr, "to %s\n", string);
1170 fprintf(stderr, "Table name %s too long, only 3 characters fit in error code.\n",
1173 if (char_to_1num (string[0]) > char_to_1num ('z')) {
1174 fprintf (stderr, "%s%s%s%s",
1175 "First character of error table name must be ",
1176 "a letter; name ``",
1177 string, "'' rejected\n");
1181 for(ctr=0; ctr < 3; ctr++) { /* copy at most 3 chars to integer */
1182 if (*string == '\0') break; /* and watch for early end */
1183 temp = (temp * 050) /* "radix fifty" is base 050 = 40 */
1184 + char_to_1num(*string);
1187 table_number += temp << 12;
1191 * char_to_num -- maps letters and numbers into very small space
1193 * mixed case -> 10-35
1195 * others are reserved
1198 static const char char_1set[] =
1199 "abcdefghijklmnopqrstuvwxyz_0123456789";
1201 int char_to_1num(char c)
1206 if (isupper(c)) c = tolower(c);
1208 where = strchr (char_1set, c);
1210 /* start at 1 so we can decode */
1211 diff = where - char_1set;
1212 assert (diff < 050); /* it is radix 50, after all */
1215 else if (isprint (c))
1217 "Illegal character `%c' in error table name\n",
1221 "Illegal character %03o in error table name\n",
1227 #include "et_lex.lex_nt.c"
1229 #include "et_lex.lex.c"