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.
37 char *current_token
= NULL
;
38 extern char *table_name
;
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
);
46 void set_table_num(char *string
);
47 void set_table_fun(char *astring
);
50 #line 38 "error_table.y"
54 #line 45 "error_table.y"
68 #define YYLTYPE yyltype
83 #define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 18)
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,
116 static const short yyprhs
[] = { 0,
117 0, 5, 8, 10, 12, 14, 17, 19, 24, 31,
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,
131 static const short yyrline
[] = { 0,
132 50, 56, 59, 66, 73, 79, 80, 83, 87, 95,
136 static const char *const yytname
[] =
137 { "$", "error", "$undefined.", "ERROR_TABLE",
138 "ERROR_CODE_ENTRY", "END", "STRING", "QUOTED_STRING", "','", "'='",
140 "header", "table_fun", "table_id", "error_codes", "ec_entry", "ec_name",
146 static const short yyr1
[] = { 0,
147 10, 11, 11, 12, 13, 14, 14, 15, 15, 16,
151 static const short yyr2
[] = { 0,
152 4, 2, 1, 1, 1, 2, 1, 4, 6, 1,
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,
162 static const short yydefgoto
[] = { 22,
163 3, 4, 5, 7, 8, 12, 18
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
172 static const short yypgoto
[] = { -32768,
173 -32768, -32768, 11, -32768, 10, -32768, -2
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
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
190 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
191 #line 3 "bison.simple"
193 /* Skeleton output parser for bison,
194 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
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)
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.
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. */
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. */
217 #define alloca __builtin_alloca
218 #else /* not GNU C. */
219 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
221 #else /* not sparc */
222 #if defined (MSDOS) && !defined (__TURBOC__)
224 #else /* not MSDOS, or __TURBOC__ */
228 #else /* not MSDOS, __TURBOC__, or _AIX */
232 void *alloca(unsigned int);
234 #else /* not __cplusplus */
236 #endif /* not __cplusplus */
238 #endif /* not _AIX */
239 #endif /* not MSDOS, or __TURBOC__ */
240 #endif /* not sparc. */
241 #endif /* not GNU C. */
242 #endif /* alloca not defined. */
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. */
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. */
253 #define yyerrok (yyerrstatus = 0)
254 #define yyclearin (yychar = YYEMPTY)
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) \
268 if (yychar == YYEMPTY && yylen == 1) \
269 { yychar = (token), yylval = (value); \
270 yychar1 = YYTRANSLATE (yychar); \
275 { yyerror ("syntax error: cannot back up"); YYERROR; } \
279 #define YYERRCODE 256
282 #define YYLEX yylex()
288 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
290 #define YYLEX yylex(&yylval, &yylloc)
292 #else /* not YYLSP_NEEDED */
294 #define YYLEX yylex(&yylval, YYLEX_PARAM)
296 #define YYLEX yylex(&yylval)
298 #endif /* not YYLSP_NEEDED */
301 /* If nonreentrant, generate the variables here */
305 int yychar
; /* the lookahead symbol */
306 YYSTYPE yylval
; /* the semantic value of the */
307 /* lookahead symbol */
310 YYLTYPE yylloc
; /* location data for the lookahead */
314 int yynerrs
; /* number of parse errors so far */
315 #endif /* not YYPURE */
318 int yydebug
; /* nonzero means print parse trace */
319 /* Since this is uninitialized, it does not stop multiple parsers
323 /* YYINITDEPTH indicates the initial size of the parser's stacks */
326 #define YYINITDEPTH 200
329 /* YYMAXDEPTH is the maximum size the stacks can grow to
330 (effective only if the built-in stack extension method is used). */
337 #define YYMAXDEPTH 10000
340 /* Prevent warning if -Wstrict-prototypes. */
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++ */
350 /* This is the most reliable way to avoid incompatibilities
351 in available built-in functions on various systems. */
353 __yy_memcpy(from
, to
, count
)
366 #else /* __cplusplus */
368 /* This is the most reliable way to avoid incompatibilities
369 in available built-in functions on various systems. */
371 __yy_memcpy(char *from
, char *to
, int count
)
384 #line 192 "bison.simple"
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. */
393 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
395 #define YYPARSE_PARAM
396 #define YYPARSE_PARAM_DECL
400 yyparse(YYPARSE_PARAM
)
407 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
408 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
410 short yyssa
[YYINITDEPTH
]; /* the state stack */
411 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
413 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
414 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
417 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
418 YYLTYPE
*yyls
= yylsa
;
421 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
423 #define YYPOPSTACK (yyvsp--, yyssp--)
426 int yystacksize
= YYINITDEPTH
;
437 YYSTYPE yyval
; /* the variable used to return */
438 /* semantic values from the action */
445 fprintf(stderr
, "Starting parse\n");
451 yychar
= YYEMPTY
; /* Cause a token to be read. */
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. */
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. */
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
;
477 YYLTYPE
*yyls1
= yyls
;
480 /* Get the current used size of the three stacks, in elements. */
481 int size
= yyssp
- yyss
+ 1;
484 /* Each stack pointer address is followed by the size of
485 * the data in use in that stack, in bytes. */
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
);
493 yyoverflow("parser stack overflow", &yyss1
, size
* sizeof(*yyssp
),
494 &yyvs1
, size
* sizeof(*yyvsp
), &yystacksize
);
502 #else /* no yyoverflow */
503 /* Extend the stack our own way. */
504 if (yystacksize
>= YYMAXDEPTH
) {
505 yyerror("parser stack overflow");
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
));
516 yyls
= (YYLTYPE
*) alloca(yystacksize
* sizeof(*yylsp
));
517 __yy_memcpy((char *)yyls1
, (char *)yyls
, size
* sizeof(*yylsp
));
519 #endif /* no yyoverflow */
521 yyssp
= yyss
+ size
- 1;
522 yyvsp
= yyvs
+ size
- 1;
524 yylsp
= yyls
+ size
- 1;
529 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
532 if (yyssp
>= yyss
+ yystacksize
- 1)
537 fprintf(stderr
, "Entering state %d\n", yystate
);
543 /* Do appropriate processing given the current state. */
544 /* Read a lookahead token if we need one and don't already have one. */
547 /* First try to decide what to do without reference to lookahead token. */
549 yyn
= yypact
[yystate
];
553 /* Not known => get a lookahead token if don't already have one. */
555 /* yychar is either YYEMPTY or YYEOF
556 * or a valid token in external form. */
558 if (yychar
== YYEMPTY
) {
561 fprintf(stderr
, "Reading a token: ");
566 /* Convert token to internal form (in yychar1) for indexing tables with */
568 if (yychar
<= 0) { /* This means end of input. */
570 yychar
= YYEOF
; /* Don't call YYLEX any more */
574 fprintf(stderr
, "Now at end of input.\n");
577 yychar1
= YYTRANSLATE(yychar
);
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. */
585 YYPRINT(stderr
, yychar
, yylval
);
587 fprintf(stderr
, ")\n");
593 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
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. */
616 /* Shift the lookahead token. */
620 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
623 /* Discard the token being shifted unless it is eof. */
632 /* count tokens shifted since error; after three, turn off error status. */
639 /* Do the default action for the current state. */
642 yyn
= yydefact
[yystate
];
646 /* Do a reduction. yyn is the number of a rule to reduce with. */
650 yyval
= yyvsp
[1 - yylen
]; /* implement default value of the action */
656 fprintf(stderr
, "Reducing via rule %d (line %d), ", yyn
,
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
]]);
670 #line 51 "error_table.y"
672 table_name
= strdup(yyvsp
[-2].dynstr
);
673 current_token
= table_name
;
678 #line 57 "error_table.y"
680 current_token
= yyvsp
[-1].dynstr
;
681 yyval
.dynstr
= yyvsp
[0].dynstr
;;
685 #line 60 "error_table.y"
687 current_token
= yyvsp
[0].dynstr
;
688 set_table_fun(strdup("1"));
689 yyval
.dynstr
= yyvsp
[0].dynstr
;
694 #line 67 "error_table.y"
696 current_token
= yyvsp
[0].dynstr
;
697 set_table_fun(yyvsp
[0].dynstr
);
698 yyval
.dynstr
= yyvsp
[0].dynstr
;;
702 #line 74 "error_table.y"
704 current_token
= yyvsp
[0].dynstr
;
705 set_table_num(yyvsp
[0].dynstr
);
706 yyval
.dynstr
= yyvsp
[0].dynstr
;;
710 #line 84 "error_table.y"
712 add_ec(yyvsp
[-2].dynstr
, yyvsp
[0].dynstr
);
713 free(yyvsp
[-2].dynstr
);
714 free(yyvsp
[0].dynstr
);;
718 #line 88 "error_table.y"
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
);
728 #line 96 "error_table.y"
730 yyval
.dynstr
= strdup(yyvsp
[0].dynstr
);
731 current_token
= yyval
.dynstr
;;
735 #line 101 "error_table.y"
737 yyval
.dynstr
= strdup(yyvsp
[0].dynstr
);
738 current_token
= yyval
.dynstr
;;
742 /* the action file gets copied in in place of this dollarsign */
743 #line 487 "bison.simple"
753 short *ssp1
= yyss
- 1;
754 fprintf(stderr
, "state stack now");
755 while (ssp1
!= yyssp
)
756 fprintf(stderr
, " %d", *++ssp1
);
757 fprintf(stderr
, "\n");
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
;
772 yylsp
->last_line
= (yylsp
+ yylen
- 1)->last_line
;
773 yylsp
->last_column
= (yylsp
+ yylen
- 1)->last_column
;
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. */
784 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
785 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
786 yystate
= yytable
[yystate
];
788 yystate
= yydefgoto
[yyn
- YYNTBASE
];
792 yyerrlab
: /* here on detecting error */
795 /* If not already recovering from an error, report this error. */
799 #ifdef YYERROR_VERBOSE
800 yyn
= yypact
[yystate
];
802 if (yyn
> YYFLAG
&& yyn
< YYLAST
) {
808 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
809 for (x
= (yyn
< 0 ? -yyn
: 0);
810 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
811 if (yycheck
[x
+ yyn
] == x
)
812 size
+= strlen(yytname
[x
]) + 15, count
++;
813 msg
= malloc(size
+ 15);
815 strcpy(msg
, "parse error");
819 for (x
= (yyn
< 0 ? -yyn
: 0);
820 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
821 if (yycheck
[x
+ yyn
] == x
) {
823 count
== 0 ? ", expecting `" : " or `");
824 strcat(msg
, yytname
[x
]);
832 yyerror("parse error; also virtual memory exceeded");
834 #endif /* YYERROR_VERBOSE */
835 yyerror("parse error");
839 yyerrlab1
: /* here on error raised explicitly by an action */
841 if (yyerrstatus
== 3) {
842 /* if just tried and failed to reuse lookahead token after an error, discard it. */
844 /* return failure if at end of input */
850 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
,
857 /* Else will try to reuse lookahead token
858 * after shifting the error token. */
860 yyerrstatus
= 3; /* Each real token shifted decrements this */
864 yyerrdefault
: /* current state does not do anything special for the error token. */
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. */
874 yyerrpop
: /* pop the current state because it cannot handle the error token */
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");
896 yyn
= yypact
[yystate
];
901 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
918 fprintf(stderr
, "Shifting error token, ");
930 #line 105 "error_table.y"
934 * Copyright 1986, 1987 by the MIT Student Information Processing Board
936 * For copyright info, see mit-sipb-cr.h.
938 #include <afs/param.h>
942 #include <afs/afsutil.h>
944 #include <sys/timeb.h>
945 #include "error_table.h"
946 #include "mit-sipb-cr.h"
949 * Copyright 2000, International Business Machines Corporation and others.
950 * All Rights Reserved.
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
957 extern FILE *hfile
, *cfile
, *msfile
;
960 static afs_int32 gensym_n
= 0;
963 gensym(const char *x
)
968 gettimeofday(&tv
, NULL
);
969 gensym_n
= (tv
.tv_sec
% 10000) * 100 + tv
.tv_usec
/ 10000;
971 symbol
= malloc(32 * sizeof(char));
973 sprintf(symbol
, "et%ld", gensym_n
);
978 quote(const char *string
)
981 rv
= (char *)malloc(strlen(string
) + 3);
988 afs_int32 table_number
= 0;
990 char **error_codes
= NULL
;
993 add_ec(const char *name
, const char *description
)
998 fprintf(msfile
, "%d\t%s\n", current
, description
);
1000 fprintf(msfile
, "%d %s\n", current
, description
);
1003 fprintf(cfile
, "\t\"%s\",\n", description
);
1005 if (error_codes
== NULL
) {
1006 error_codes
= malloc(sizeof(char *));
1007 *error_codes
= NULL
;
1009 error_codes
= realloc(error_codes
, (current
+ 2) * sizeof(char *));
1010 error_codes
[current
++] = strdup(name
);
1011 error_codes
[current
] = NULL
;
1015 add_ec_val(const char *name
, const char *val
, const char *description
)
1017 const int ncurrent
= atoi(val
);
1018 if (ncurrent
< current
) {
1019 printf("Error code %s (%d) out of order", name
, current
);
1023 while (ncurrent
> current
) {
1025 fputs("\tNULL,\n", cfile
);
1031 fprintf(msfile
, "%d\t%s\n", current
, description
);
1033 fprintf(msfile
, "%d %s\n", current
, description
);
1036 fprintf(cfile
, "\t\"%s\",\n", description
);
1038 if (error_codes
== NULL
) {
1039 error_codes
= malloc(sizeof(char *));
1040 *error_codes
= NULL
;
1042 error_codes
= realloc(error_codes
, (current
+ 2) * sizeof(char *));
1043 error_codes
[current
++] = strdup(name
);
1044 error_codes
[current
] = NULL
;
1053 for (i
= 0; i
< current
; i
++) {
1054 if (error_codes
[i
] != NULL
)
1055 fprintf(hfile
, "#define %-40s (%ldL)\n", error_codes
[i
],
1061 * char_to_num -- maps letters and numbers into a small numbering space
1063 * lowercase -> 27-52
1068 static const char char_set
[] =
1069 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
1077 where
= strchr(char_set
, c
);
1079 diff
= where
- char_set
+ 1;
1080 assert(diff
< (1 << ERRCODE_RANGE
));
1082 } else if (isprint(c
))
1083 fprintf(stderr
, "Illegal character `%c' in error table name\n", c
);
1085 fprintf(stderr
, "Illegal character %03o in error table name\n", c
);
1090 set_table_num(char *string
)
1093 set_table_1num(string
);
1096 if (strlen(string
) > 4) {
1097 fprintf(stderr
, "Table name %s too long, truncated ", string
);
1099 fprintf(stderr
, "to %s\n", string
);
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");
1107 while (*string
!= '\0') {
1108 table_number
= (table_number
<< BITS_PER_CHAR
)
1109 + char_to_num(*string
);
1112 table_number
= table_number
<< ERRCODE_RANGE
;
1116 set_table_fun(char *astring
)
1121 for (tp
= astring
; (tc
= *tp
) != 0; tp
++) {
1124 "Table function '%s' must be a decimal integer.\n",
1130 table_number
+= (atoi(astring
)) << 28;
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.
1138 set_table_1num(char *string
)
1143 if ((temp
= strlen(string
)) > 4) {
1144 fprintf(stderr
, "Table name %s too long, truncated ", string
);
1146 fprintf(stderr
, "to %s\n", string
);
1150 "Table name %s too long, only 3 characters fit in error code.\n",
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");
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
);
1167 table_number
+= temp
<< 12;
1171 * char_to_num -- maps letters and numbers into very small space
1173 * mixed case -> 10-35
1175 * others are reserved
1178 static const char char_1set
[] = "abcdefghijklmnopqrstuvwxyz_0123456789";
1181 char_to_1num(char c
)
1189 where
= strchr(char_1set
, c
);
1191 /* start at 1 so we can decode */
1192 diff
= where
- char_1set
;
1193 assert(diff
< 050); /* it is radix 50, after all */
1195 } else if (isprint(c
))
1196 fprintf(stderr
, "Illegal character `%c' in error table name\n", c
);
1198 fprintf(stderr
, "Illegal character %03o in error table name\n", c
);
1203 #include "et_lex.lex_nt.c"
1205 #include "et_lex.lex.c"