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>
23 * If __STDC__ is defined, function prototypes in the SunOS 5.5.1 lex
24 * and yacc templates are visible. We turn this on explicitly on
25 * NT because the prototypes help supress certain warning from the
26 * Microsoft C compiler.
42 char *current_token = (char *)NULL;
43 extern char *table_name;
45 char *ds(const char *string);
46 char *quote(const char *string);
47 void set_table_1num(char *string);
48 int char_to_1num(char c);
49 void add_ec(const char *name, const char *description);
50 void add_ec_val(const char *name, const char *val, const char *description);
52 void set_table_num(char *string);
53 void set_table_fun(char *astring);
56 #line 38 "error_table.y"
60 #line 45 "error_table.y"
74 #define YYLTYPE yyltype
91 #define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 18)
93 static const char yytranslate[] = { 0,
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, 8, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
100 9, 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, 2, 2, 2, 2, 2,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
124 static const short yyprhs[] = { 0,
125 0, 5, 8, 10, 12, 14, 17, 19, 24, 31,
129 static const short yyrhs[] = { 3,
130 11, 14, 5, 0, 12, 13, 0, 13, 0, 6,
131 0, 6, 0, 14, 15, 0, 15, 0, 4, 16,
132 8, 17, 0, 4, 16, 9, 6, 8, 17, 0,
139 static const short yyrline[] = { 0,
140 50, 56, 59, 66, 73, 79, 80, 83, 87, 95,
144 static const char *const yytname[] =
145 { "$", "error", "$undefined.", "ERROR_TABLE",
146 "ERROR_CODE_ENTRY", "END", "STRING", "QUOTED_STRING", "','", "'='",
148 "header", "table_fun", "table_id", "error_codes", "ec_entry", "ec_name",
154 static const short yyr1[] = { 0,
155 10, 11, 11, 12, 13, 14, 14, 15, 15, 16,
159 static const short yyr2[] = { 0,
160 4, 2, 1, 1, 1, 2, 1, 4, 6, 1,
164 static const short yydefact[] = { 0,
165 0, 4, 0, 0, 3, 0, 0, 7, 5, 2,
166 10, 0, 1, 6, 0, 0, 11, 8, 0, 0,
170 static const short yydefgoto[] = { 22,
171 3, 4, 5, 7, 8, 12, 18
174 static const short yypact[] = { 1,
175 -1, 2, 3, 4, -32768, 5, -4, -32768, -32768, -32768,
176 -32768, -6, -32768, -32768, 6, 8, -32768, -32768, 0, 6,
177 -32768, 9, 12, -32768
180 static const short yypgoto[] = { -32768,
181 -32768, -32768, 11, -32768, 10, -32768, -2
188 static const short yytable[] = { 6,
189 13, 15, 16, 1, 2, -5, 6, 20, 23, 9,
190 11, 24, 17, 19, 10, 0, 14, 21
193 static const short yycheck[] = { 4,
194 5, 8, 9, 3, 6, 4, 4, 8, 0, 6,
195 6, 0, 7, 6, 4, -1, 7, 20
198 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
199 #line 3 "bison.simple"
201 /* Skeleton output parser for bison,
202 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
204 This program is free software; you can redistribute it and/or modify
205 it under the terms of the GNU General Public License as published by
206 the Free Software Foundation; either version 2, or (at your option)
209 This program is distributed in the hope that it will be useful,
210 but WITHOUT ANY WARRANTY; without even the implied warranty of
211 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212 GNU General Public License for more details.
214 You should have received a copy of the GNU General Public License
215 along with this program; if not, write to the Free Software
216 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
218 /* As a special exception, when this file is copied by Bison into a
219 Bison output file, you may use that output file without restriction.
220 This special exception was added by the Free Software Foundation
221 in version 1.24 of Bison. */
225 #define alloca __builtin_alloca
226 #else /* not GNU C. */
227 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
229 #else /* not sparc */
230 #if defined (MSDOS) && !defined (__TURBOC__)
232 #else /* not MSDOS, or __TURBOC__ */
236 #else /* not MSDOS, __TURBOC__, or _AIX */
240 void *alloca(unsigned int);
242 #else /* not __cplusplus */
244 #endif /* not __cplusplus */
246 #endif /* not _AIX */
247 #endif /* not MSDOS, or __TURBOC__ */
248 #endif /* not sparc. */
249 #endif /* not GNU C. */
250 #endif /* alloca not defined. */
252 /* This is the parser code that is written into each bison parser
253 when the %semantic_parser declaration is not specified in the grammar.
254 It was written by Richard Stallman by simplifying the hairy parser
255 used when %semantic_parser is specified. */
257 /* Note: there must be only one dollar sign in this file.
258 It is replaced by the list of actions, each action
259 as one case of the switch. */
261 #define yyerrok (yyerrstatus = 0)
262 #define yyclearin (yychar = YYEMPTY)
265 #define YYACCEPT return(0)
266 #define YYABORT return(1)
267 #define YYERROR goto yyerrlab1
268 /* Like YYERROR except do call yyerror.
269 This remains here temporarily to ease the
270 transition to the new meaning of YYERROR, for GCC.
271 Once GCC version 2 has supplanted version 1, this can go. */
272 #define YYFAIL goto yyerrlab
273 #define YYRECOVERING() (!!yyerrstatus)
274 #define YYBACKUP(token, value) \
276 if (yychar == YYEMPTY && yylen == 1) \
277 { yychar = (token), yylval = (value); \
278 yychar1 = YYTRANSLATE (yychar); \
283 { yyerror ("syntax error: cannot back up"); YYERROR; } \
287 #define YYERRCODE 256
290 #define YYLEX yylex()
296 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
298 #define YYLEX yylex(&yylval, &yylloc)
300 #else /* not YYLSP_NEEDED */
302 #define YYLEX yylex(&yylval, YYLEX_PARAM)
304 #define YYLEX yylex(&yylval)
306 #endif /* not YYLSP_NEEDED */
309 /* If nonreentrant, generate the variables here */
313 int yychar; /* the lookahead symbol */
314 YYSTYPE yylval; /* the semantic value of the */
315 /* lookahead symbol */
318 YYLTYPE yylloc; /* location data for the lookahead */
322 int yynerrs; /* number of parse errors so far */
323 #endif /* not YYPURE */
326 int yydebug; /* nonzero means print parse trace */
327 /* Since this is uninitialized, it does not stop multiple parsers
331 /* YYINITDEPTH indicates the initial size of the parser's stacks */
334 #define YYINITDEPTH 200
337 /* YYMAXDEPTH is the maximum size the stacks can grow to
338 (effective only if the built-in stack extension method is used). */
345 #define YYMAXDEPTH 10000
348 /* Prevent warning if -Wstrict-prototypes. */
353 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
354 #define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
355 #else /* not GNU C or C++ */
358 /* This is the most reliable way to avoid incompatibilities
359 in available built-in functions on various systems. */
361 __yy_memcpy(from, to, count)
366 register char *f = from;
367 register char *t = to;
368 register int i = count;
374 #else /* __cplusplus */
376 /* This is the most reliable way to avoid incompatibilities
377 in available built-in functions on various systems. */
379 __yy_memcpy(char *from, char *to, int count)
381 register char *f = from;
382 register char *t = to;
383 register int i = count;
392 #line 192 "bison.simple"
394 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
395 into yyparse. The argument should have type void *.
396 It should actually point to an object.
397 Grammar actions can access the variable by casting it
398 to the proper pointer type. */
401 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
403 #define YYPARSE_PARAM
404 #define YYPARSE_PARAM_DECL
408 yyparse(YYPARSE_PARAM)
411 register int yystate;
413 register short *yyssp;
414 register YYSTYPE *yyvsp;
415 int yyerrstatus; /* number of tokens to shift before error messages enabled */
416 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
418 short yyssa[YYINITDEPTH]; /* the state stack */
419 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
421 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
422 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
425 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
426 YYLTYPE *yyls = yylsa;
429 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
431 #define YYPOPSTACK (yyvsp--, yyssp--)
434 int yystacksize = YYINITDEPTH;
445 YYSTYPE yyval; /* the variable used to return */
446 /* semantic values from the action */
453 fprintf(stderr, "Starting parse\n");
459 yychar = YYEMPTY; /* Cause a token to be read. */
461 /* Initialize stack pointers.
462 * Waste one element of value and location stack
463 * so that they stay on the same level as the state stack.
464 * The wasted elements are never initialized. */
472 /* Push a new state, which is found in yystate . */
473 /* In all cases, when you get here, the value and location stacks
474 have just been pushed. so pushing a state here evens the stacks. */
479 if (yyssp >= yyss + yystacksize - 1) {
480 /* Give user a chance to reallocate the stack */
481 /* Use copies of these so that the &'s don't force the real ones into memory. */
482 YYSTYPE *yyvs1 = yyvs;
485 YYLTYPE *yyls1 = yyls;
488 /* Get the current used size of the three stacks, in elements. */
489 int size = yyssp - yyss + 1;
492 /* Each stack pointer address is followed by the size of
493 * the data in use in that stack, in bytes. */
495 /* This used to be a conditional around just the two extra args,
496 * but that might be undefined if yyoverflow is a macro. */
497 yyoverflow("parser stack overflow", &yyss1, size * sizeof(*yyssp),
498 &yyvs1, size * sizeof(*yyvsp), &yyls1,
499 size * sizeof(*yylsp), &yystacksize);
501 yyoverflow("parser stack overflow", &yyss1, size * sizeof(*yyssp),
502 &yyvs1, size * sizeof(*yyvsp), &yystacksize);
510 #else /* no yyoverflow */
511 /* Extend the stack our own way. */
512 if (yystacksize >= YYMAXDEPTH) {
513 yyerror("parser stack overflow");
517 if (yystacksize > YYMAXDEPTH)
518 yystacksize = YYMAXDEPTH;
519 yyss = (short *)alloca(yystacksize * sizeof(*yyssp));
520 __yy_memcpy((char *)yyss1, (char *)yyss, size * sizeof(*yyssp));
521 yyvs = (YYSTYPE *) alloca(yystacksize * sizeof(*yyvsp));
522 __yy_memcpy((char *)yyvs1, (char *)yyvs, size * sizeof(*yyvsp));
524 yyls = (YYLTYPE *) alloca(yystacksize * sizeof(*yylsp));
525 __yy_memcpy((char *)yyls1, (char *)yyls, size * sizeof(*yylsp));
527 #endif /* no yyoverflow */
529 yyssp = yyss + size - 1;
530 yyvsp = yyvs + size - 1;
532 yylsp = yyls + size - 1;
537 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
540 if (yyssp >= yyss + yystacksize - 1)
545 fprintf(stderr, "Entering state %d\n", yystate);
551 /* Do appropriate processing given the current state. */
552 /* Read a lookahead token if we need one and don't already have one. */
555 /* First try to decide what to do without reference to lookahead token. */
557 yyn = yypact[yystate];
561 /* Not known => get a lookahead token if don't already have one. */
563 /* yychar is either YYEMPTY or YYEOF
564 * or a valid token in external form. */
566 if (yychar == YYEMPTY) {
569 fprintf(stderr, "Reading a token: ");
574 /* Convert token to internal form (in yychar1) for indexing tables with */
576 if (yychar <= 0) { /* This means end of input. */
578 yychar = YYEOF; /* Don't call YYLEX any more */
582 fprintf(stderr, "Now at end of input.\n");
585 yychar1 = YYTRANSLATE(yychar);
589 fprintf(stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
590 /* Give the individual parser a way to print the precise meaning
591 * of a token, for further debugging info. */
593 YYPRINT(stderr, yychar, yylval);
595 fprintf(stderr, ")\n");
601 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
606 /* yyn is what to do for this token type in this state.
607 * Negative => reduce, -yyn is rule number.
608 * Positive => shift, yyn is new state.
609 * New state is final state => don't bother to shift,
610 * just return success.
611 * 0, or most negative number => error. */
624 /* Shift the lookahead token. */
628 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
631 /* Discard the token being shifted unless it is eof. */
640 /* count tokens shifted since error; after three, turn off error status. */
647 /* Do the default action for the current state. */
650 yyn = yydefact[yystate];
654 /* Do a reduction. yyn is the number of a rule to reduce with. */
658 yyval = yyvsp[1 - yylen]; /* implement default value of the action */
664 fprintf(stderr, "Reducing via rule %d (line %d), ", yyn,
667 /* Print the symbols being reduced, and their result. */
668 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
669 fprintf(stderr, "%s ", yytname[yyrhs[i]]);
670 fprintf(stderr, " -> %s\n", yytname[yyr1[yyn]]);
678 #line 51 "error_table.y"
680 table_name = ds(yyvsp[-2].dynstr);
681 current_token = table_name;
686 #line 57 "error_table.y"
688 current_token = yyvsp[-1].dynstr;
689 yyval.dynstr = yyvsp[0].dynstr;;
693 #line 60 "error_table.y"
695 current_token = yyvsp[0].dynstr;
696 set_table_fun(ds("1"));
697 yyval.dynstr = yyvsp[0].dynstr;
702 #line 67 "error_table.y"
704 current_token = yyvsp[0].dynstr;
705 set_table_fun(yyvsp[0].dynstr);
706 yyval.dynstr = yyvsp[0].dynstr;;
710 #line 74 "error_table.y"
712 current_token = yyvsp[0].dynstr;
713 set_table_num(yyvsp[0].dynstr);
714 yyval.dynstr = yyvsp[0].dynstr;;
718 #line 84 "error_table.y"
720 add_ec(yyvsp[-2].dynstr, yyvsp[0].dynstr);
721 free(yyvsp[-2].dynstr);
722 free(yyvsp[0].dynstr);;
726 #line 88 "error_table.y"
728 add_ec_val(yyvsp[-4].dynstr, yyvsp[-2].dynstr, yyvsp[0].dynstr);
729 free(yyvsp[-4].dynstr);
730 free(yyvsp[-2].dynstr);
731 free(yyvsp[0].dynstr);
736 #line 96 "error_table.y"
738 yyval.dynstr = ds(yyvsp[0].dynstr);
739 current_token = yyval.dynstr;;
743 #line 101 "error_table.y"
745 yyval.dynstr = ds(yyvsp[0].dynstr);
746 current_token = yyval.dynstr;;
750 /* the action file gets copied in in place of this dollarsign */
751 #line 487 "bison.simple"
761 short *ssp1 = yyss - 1;
762 fprintf(stderr, "state stack now");
763 while (ssp1 != yyssp)
764 fprintf(stderr, " %d", *++ssp1);
765 fprintf(stderr, "\n");
774 yylsp->first_line = yylloc.first_line;
775 yylsp->first_column = yylloc.first_column;
776 yylsp->last_line = (yylsp - 1)->last_line;
777 yylsp->last_column = (yylsp - 1)->last_column;
780 yylsp->last_line = (yylsp + yylen - 1)->last_line;
781 yylsp->last_column = (yylsp + yylen - 1)->last_column;
785 /* Now "shift" the result of the reduction.
786 * Determine what state that goes to,
787 * based on the state we popped back to
788 * and the rule number reduced by. */
792 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
793 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
794 yystate = yytable[yystate];
796 yystate = yydefgoto[yyn - YYNTBASE];
800 yyerrlab: /* here on detecting error */
803 /* If not already recovering from an error, report this error. */
807 #ifdef YYERROR_VERBOSE
808 yyn = yypact[yystate];
810 if (yyn > YYFLAG && yyn < YYLAST) {
816 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
817 for (x = (yyn < 0 ? -yyn : 0);
818 x < (sizeof(yytname) / sizeof(char *)); x++)
819 if (yycheck[x + yyn] == x)
820 size += strlen(yytname[x]) + 15, count++;
821 msg = (char *)malloc(size + 15);
823 strcpy(msg, "parse error");
827 for (x = (yyn < 0 ? -yyn : 0);
828 x < (sizeof(yytname) / sizeof(char *)); x++)
829 if (yycheck[x + yyn] == x) {
831 count == 0 ? ", expecting `" : " or `");
832 strcat(msg, yytname[x]);
840 yyerror("parse error; also virtual memory exceeded");
842 #endif /* YYERROR_VERBOSE */
843 yyerror("parse error");
847 yyerrlab1: /* here on error raised explicitly by an action */
849 if (yyerrstatus == 3) {
850 /* if just tried and failed to reuse lookahead token after an error, discard it. */
852 /* return failure if at end of input */
858 fprintf(stderr, "Discarding token %d (%s).\n", yychar,
865 /* Else will try to reuse lookahead token
866 * after shifting the error token. */
868 yyerrstatus = 3; /* Each real token shifted decrements this */
872 yyerrdefault: /* current state does not do anything special for the error token. */
875 /* This is wrong; only states that explicitly want error tokens
876 * should shift them. */
877 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it. */
882 yyerrpop: /* pop the current state because it cannot handle the error token */
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)
926 fprintf(stderr, "Shifting error token, ");
938 #line 105 "error_table.y"
942 * Copyright 1986, 1987 by the MIT Student Information Processing Board
944 * For copyright info, see mit-sipb-cr.h.
949 #include <afs/param.h>
954 #include <sys/types.h>
955 #include <afs/afsutil.h>
957 #include <sys/time.h>
959 #include <sys/timeb.h>
960 #include "error_table.h"
961 #include "mit-sipb-cr.h"
965 * Copyright 2000, International Business Machines Corporation and others.
966 * All Rights Reserved.
968 * This software has been released under the terms of the IBM Public
969 * License. For details, see the LICENSE file in the top-level source
970 * directory or online at http://www.openafs.org/dl/license10.html
973 extern FILE *hfile, *cfile, *msfile;
976 static afs_int32 gensym_n = 0;
979 gensym(const char *x)
984 gettimeofday(&tv, (void *)0);
985 gensym_n = (tv.tv_sec % 10000) * 100 + tv.tv_usec / 10000;
987 symbol = (char *)malloc(32 * sizeof(char));
989 sprintf(symbol, "et%ld", gensym_n);
994 ds(const char *string)
997 rv = (char *)malloc(strlen(string) + 1);
1003 quote(const char *string)
1006 rv = (char *)malloc(strlen(string) + 3);
1013 afs_int32 table_number = 0;
1015 char **error_codes = (char **)NULL;
1018 add_ec(const char *name, const char *description)
1023 fprintf(msfile, "%d\t%s\n", current, description);
1025 fprintf(msfile, "%d %s\n", current, description);
1028 fprintf(cfile, "\t\"%s\",\n", description);
1030 if (error_codes == (char **)NULL) {
1031 error_codes = (char **)malloc(sizeof(char *));
1032 *error_codes = (char *)NULL;
1035 (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
1036 error_codes[current++] = ds(name);
1037 error_codes[current] = (char *)NULL;
1041 add_ec_val(const char *name, const char *val, const char *description)
1043 const int ncurrent = atoi(val);
1044 if (ncurrent < current) {
1045 printf("Error code %s (%d) out of order", name, current);
1049 while (ncurrent > current) {
1051 fputs("\t(char *)NULL,\n", cfile);
1057 fprintf(msfile, "%d\t%s\n", current, description);
1059 fprintf(msfile, "%d %s\n", current, description);
1062 fprintf(cfile, "\t\"%s\",\n", description);
1064 if (error_codes == (char **)NULL) {
1065 error_codes = (char **)malloc(sizeof(char *));
1066 *error_codes = (char *)NULL;
1069 (char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
1070 error_codes[current++] = ds(name);
1071 error_codes[current] = (char *)NULL;
1078 for (i = 0; i < current; i++) {
1079 if (error_codes[i] != (char *)NULL)
1080 fprintf(hfile, "#define %-40s (%ldL)\n", error_codes[i],
1086 * char_to_num -- maps letters and numbers into a small numbering space
1088 * lowercase -> 27-52
1093 static const char char_set[] =
1094 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
1102 where = strchr(char_set, c);
1104 diff = where - char_set + 1;
1105 assert(diff < (1 << ERRCODE_RANGE));
1107 } else if (isprint(c))
1108 fprintf(stderr, "Illegal character `%c' in error table name\n", c);
1110 fprintf(stderr, "Illegal character %03o in error table name\n", c);
1115 set_table_num(char *string)
1118 set_table_1num(string);
1121 if (strlen(string) > 4) {
1122 fprintf(stderr, "Table name %s too long, truncated ", string);
1124 fprintf(stderr, "to %s\n", string);
1126 if (char_to_num(string[0]) > char_to_num('z')) {
1127 fprintf(stderr, "%s%s%s%s",
1128 "First character of error table name must be ",
1129 "a letter; name ``", string, "'' rejected\n");
1132 while (*string != '\0') {
1133 table_number = (table_number << BITS_PER_CHAR)
1134 + char_to_num(*string);
1137 table_number = table_number << ERRCODE_RANGE;
1141 set_table_fun(char *astring)
1146 for (tp = astring; (tc = *tp) != 0; tp++) {
1149 "Table function '%s' must be a decimal integer.\n",
1155 table_number += (atoi(astring)) << 28;
1158 /* for compatibility with old comerr's, we truncate package name to 4
1159 * characters, but only store first 3 in the error code. Note that this
1160 * function, as a side effect, truncates the table name down to 4 chars.
1163 set_table_1num(char *string)
1168 if ((temp = strlen(string)) > 4) {
1169 fprintf(stderr, "Table name %s too long, truncated ", string);
1171 fprintf(stderr, "to %s\n", string);
1175 "Table name %s too long, only 3 characters fit in error code.\n",
1178 if (char_to_1num(string[0]) > char_to_1num('z')) {
1179 fprintf(stderr, "%s%s%s%s",
1180 "First character of error table name must be ",
1181 "a letter; name ``", string, "'' rejected\n");
1185 for (ctr = 0; ctr < 3; ctr++) { /* copy at most 3 chars to integer */
1186 if (*string == '\0')
1187 break; /* and watch for early end */
1188 temp = (temp * 050) /* "radix fifty" is base 050 = 40 */
1189 +char_to_1num(*string);
1192 table_number += temp << 12;
1196 * char_to_num -- maps letters and numbers into very small space
1198 * mixed case -> 10-35
1200 * others are reserved
1203 static const char char_1set[] = "abcdefghijklmnopqrstuvwxyz_0123456789";
1206 char_to_1num(char c)
1214 where = strchr(char_1set, c);
1216 /* start at 1 so we can decode */
1217 diff = where - char_1set;
1218 assert(diff < 050); /* it is radix 50, after all */
1220 } else if (isprint(c))
1221 fprintf(stderr, "Illegal character `%c' in error table name\n", c);
1223 fprintf(stderr, "Illegal character %03o in error table name\n", c);
1228 #include "et_lex.lex_nt.c"
1230 #include "et_lex.lex.c"