Index: stable/3/contrib/com_err/com_err.c =================================================================== --- stable/3/contrib/com_err/com_err.c (revision 62581) +++ stable/3/contrib/com_err/com_err.c (revision 62582) @@ -1,155 +1,156 @@ /* * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include RCSID("$Id: com_err.c,v 1.13 1999/03/12 15:17:08 bg Exp $"); #endif #include #include #include +#include #include "com_err.h" struct et_list *_et_list; const char * error_message (long code) { static char msg[128]; const char *p = com_right(_et_list, code); if (p == NULL) p = strerror(code); if (p != NULL && *p != '\0') { strncpy(msg, p, sizeof(msg) - 1); msg[sizeof(msg) - 1] = 0; } else sprintf(msg, "Unknown error %ld", code); return msg; } int init_error_table(const char **msgs, long base, int count) { initialize_error_table_r(&_et_list, msgs, count, base); return 0; } static void default_proc (const char *whoami, long code, const char *fmt, va_list args) { if (whoami) fprintf(stderr, "%s: ", whoami); if (code) fprintf(stderr, "%s ", error_message(code)); if (fmt) vfprintf(stderr, fmt, args); fprintf(stderr, "\r\n"); /* ??? */ } static errf com_err_hook = default_proc; void com_err_va (const char *whoami, long code, const char *fmt, va_list args) { (*com_err_hook) (whoami, code, fmt, args); } void com_err (const char *whoami, long code, const char *fmt, ...) { va_list ap; va_start(ap, fmt); com_err_va (whoami, code, fmt, ap); va_end(ap); } errf set_com_err_hook (errf new) { errf old = com_err_hook; if (new) com_err_hook = new; else com_err_hook = default_proc; return old; } errf reset_com_err_hook (void) { return set_com_err_hook(NULL); } #define ERRCODE_RANGE 8 /* # of bits to shift table number */ #define BITS_PER_CHAR 6 /* # bits to shift per character in name */ static const char char_set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; static char buf[6]; const char * error_table_name(int num) { int ch; int i; char *p; /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */ p = buf; num >>= ERRCODE_RANGE; /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */ num &= 077777777; /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */ for (i = 4; i >= 0; i--) { ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1); if (ch != 0) *p++ = char_set[ch-1]; } *p = '\0'; return(buf); } Index: stable/3/contrib/com_err/com_err.h =================================================================== --- stable/3/contrib/com_err/com_err.h (revision 62581) +++ stable/3/contrib/com_err/com_err.h (revision 62582) @@ -1,68 +1,73 @@ /* * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: com_err.h,v 1.3 1998/05/02 20:13:28 assar Exp $ */ -/* $FreeBSD$ */ /* MIT compatible com_err library */ #ifndef __COM_ERR_H__ #define __COM_ERR_H__ -#include - #ifdef __STDC__ #include #endif +#ifndef __P +#ifdef __STDC__ +#define __P(X) X +#else +#define __P(X) () +#endif +#endif + #include typedef void (*errf) __P((const char *, long, const char *, va_list)); const char * error_message __P((long)); int init_error_table __P((const char**, long, int)); void com_err_va __P((const char *, long, const char *, va_list)); void com_err __P((const char *, long, const char *, ...)); errf set_com_err_hook __P((errf)); errf reset_com_err_hook __P((void)); -const char *error_table_name __P((int num)); +const char *error_table_name(int num); #endif /* __COM_ERR_H__ */ Index: stable/3/contrib/com_err/com_right.h =================================================================== --- stable/3/contrib/com_err/com_right.h (revision 62581) +++ stable/3/contrib/com_err/com_right.h (revision 62582) @@ -1,63 +1,59 @@ /* * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: com_right.h,v 1.8 1998/02/17 21:19:43 bg Exp $ */ -/* $FreeBSD$ */ #ifndef __COM_RIGHT_H__ #define __COM_RIGHT_H__ -#include - struct error_table { char const * const * msgs; long base; int n_msgs; }; struct et_list { struct et_list *next; struct error_table *table; }; extern struct et_list *_et_list; -const char *com_right __P((struct et_list *list, long code)); -void initialize_error_table_r __P((struct et_list **, const char **, int, - long)); -void free_error_table __P((struct et_list *)); +const char *com_right(struct et_list *list, long code); +void initialize_error_table_r(struct et_list **, const char **, int, long); +void free_error_table(struct et_list *); #endif /* __COM_RIGHT_H__ */ Index: stable/3/contrib/com_err/compile_et.c =================================================================== --- stable/3/contrib/com_err/compile_et.c (revision 62581) +++ stable/3/contrib/com_err/compile_et.c (revision 62582) @@ -1,234 +1,240 @@ /* * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #undef ROKEN_RENAME #include "compile_et.h" #include -#if 0 RCSID("$Id: compile_et.c,v 1.12 1999/04/01 09:13:52 joda Exp $"); -#endif +#include #include #include "parse.h" int numerror; extern FILE *yyin; extern void yyparse(void); long base; int number; char *prefix; char *id_str; char name[128]; char Basename[128]; #ifdef YYDEBUG extern int yydebug = 1; #endif char *filename; char hfn[128]; char cfn[128]; struct error_code *codes = NULL; static int generate_c(void) { int n; struct error_code *ec; FILE *c_file = fopen(cfn, "w"); if(c_file == NULL) return 1; fprintf(c_file, "/* Generated from %s */\n", filename); if(id_str) fprintf(c_file, "/* %s */\n", id_str); fprintf(c_file, "\n"); fprintf(c_file, "#include \n"); fprintf(c_file, "#include \n"); fprintf(c_file, "#include \"%s\"\n", hfn); fprintf(c_file, "\n"); fprintf(c_file, "static const char *text[] = {\n"); for(ec = codes, n = 0; ec; ec = ec->next, n++) { while(n < ec->number) { fprintf(c_file, "\t/* %03d */ \"Reserved %s error (%d)\",\n", n, name, n); n++; } fprintf(c_file, "\t/* %03d */ \"%s\",\n", ec->number, ec->string); } fprintf(c_file, "\tNULL\n"); fprintf(c_file, "};\n"); fprintf(c_file, "\n"); fprintf(c_file, "void initialize_%s_error_table_r(struct et_list **list)\n", name); fprintf(c_file, "{\n"); fprintf(c_file, " initialize_error_table_r(list, text, " "%s_num_errors, ERROR_TABLE_BASE_%s);\n", name, name); fprintf(c_file, "}\n"); fprintf(c_file, "\n"); fprintf(c_file, "void initialize_%s_error_table(void)\n", name); fprintf(c_file, "{\n"); fprintf(c_file, " init_error_table(text, ERROR_TABLE_BASE_%s, " "%s_num_errors);\n", name, name); fprintf(c_file, "}\n"); fclose(c_file); return 0; } static int generate_h(void) { struct error_code *ec; char fn[128]; FILE *h_file = fopen(hfn, "w"); char *p; if(h_file == NULL) return 1; snprintf(fn, sizeof(fn), "__%s__", hfn); for(p = fn; *p; p++) if(!isalnum((unsigned char)*p)) *p = '_'; fprintf(h_file, "/* Generated from %s */\n", filename); if(id_str) fprintf(h_file, "/* %s */\n", id_str); fprintf(h_file, "\n"); fprintf(h_file, "#ifndef %s\n", fn); fprintf(h_file, "#define %s\n", fn); fprintf(h_file, "\n"); fprintf(h_file, "#include \n"); fprintf(h_file, "\n"); fprintf(h_file, "void initialize_%s_error_table_r(struct et_list **);\n", name); fprintf(h_file, "\n"); fprintf(h_file, "void initialize_%s_error_table(void);\n", name); fprintf(h_file, "#define init_%s_err_tbl initialize_%s_error_table\n", name, name); fprintf(h_file, "\n"); fprintf(h_file, "typedef enum %s_error_number{\n", name); fprintf(h_file, "\tERROR_TABLE_BASE_%s = %ld,\n", name, base); fprintf(h_file, "\t%s_err_base = %ld,\n", name, base); for(ec = codes; ec; ec = ec->next) { fprintf(h_file, "\t%s = %ld,\n", ec->name, base + ec->number); } fprintf(h_file, "\t%s_num_errors = %d\n", name, number); fprintf(h_file, "} %s_error_number;\n", name); fprintf(h_file, "\n"); fprintf(h_file, "#endif /* %s */\n", fn); fclose(h_file); return 0; } static int generate(void) { return generate_c() || generate_h(); } +int version_flag; int help_flag; struct getargs args[] = { + { "version", 0, arg_flag, &version_flag }, { "help", 0, arg_flag, &help_flag } }; int num_args = sizeof(args) / sizeof(args[0]); static void usage(int code) { arg_printusage(args, num_args, NULL, "error-table"); exit(code); } int main(int argc, char **argv) { char *p; int optind = 0; + set_progname(argv[0]); if(getarg(args, num_args, argc, argv, &optind)) usage(1); if(help_flag) usage(0); + if(version_flag) { + print_version(NULL); + exit(0); + } if(optind == argc) usage(1); filename = argv[optind]; yyin = fopen(filename, "r"); if(yyin == NULL) err(1, "%s", filename); p = strrchr(filename, '/'); if(p) p++; else p = filename; strncpy(Basename, p, sizeof(Basename)); Basename[sizeof(Basename) - 1] = '\0'; Basename[strcspn(Basename, ".")] = '\0'; snprintf(hfn, sizeof(hfn), "%s.h", Basename); snprintf(cfn, sizeof(cfn), "%s.c", Basename); yyparse(); if(numerror) return 1; return generate(); } Index: stable/3/contrib/com_err/compile_et.h =================================================================== --- stable/3/contrib/com_err/compile_et.h (revision 62581) +++ stable/3/contrib/com_err/compile_et.h (revision 62582) @@ -1,83 +1,85 @@ /* * Copyright (c) 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: compile_et.h,v 1.3 1998/11/22 09:39:46 assar Exp $ */ #ifndef __COMPILE_ET_H__ #define __COMPILE_ET_H__ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include +#include + extern long base; extern int number; extern char *prefix; extern char name[128]; extern char *id_str; extern char *filename; extern int numerror; struct error_code { unsigned number; char *name; char *string; struct error_code *next, **tail; }; extern struct error_code *codes; #define APPEND(L, V) \ do { \ if((L) == NULL) { \ (L) = (V); \ (L)->tail = &(V)->next; \ (L)->next = NULL; \ }else{ \ *(L)->tail = (V); \ (L)->tail = &(V)->next; \ } \ }while(0) #endif /* __COMPILE_ET_H__ */ Index: stable/3/contrib/com_err/lex.l =================================================================== --- stable/3/contrib/com_err/lex.l (revision 62581) +++ stable/3/contrib/com_err/lex.l (revision 62582) @@ -1,129 +1,127 @@ %{ /* * Copyright (c) 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * This is to handle the definition of this symbol in some AIX * headers, which will conflict with the definition that lex will * generate for it. It's only a problem for AIX lex. */ #undef ECHO #include "compile_et.h" #include "parse.h" -#if 0 RCSID("$Id: lex.l,v 1.4 1998/11/20 05:58:52 assar Exp $"); -#endif static unsigned lineno = 1; void error_message(char *, ...); int getstring(void); %} %% et { return ET; } error_table { return ET; } ec { return EC; } error_code { return EC; } prefix { return PREFIX; } index { return INDEX; } id { return ID; } end { return END; } [0-9]+ { yylval.number = atoi(yytext); return NUMBER; } #[^\n]* ; [ \t] ; \n { lineno++; } \" { return getstring(); } [a-zA-Z0-9_]+ { yylval.string = strdup(yytext); return STRING; } . { return *yytext; } %% #ifndef yywrap /* XXX */ int yywrap () { return 1; } #endif int getstring(void) { char x[128]; int i = 0; int c; int quote = 0; while((c = input()) != EOF){ if(quote) { x[i++] = c; quote = 0; continue; } if(c == '\n'){ error_message("unterminated string"); lineno++; break; } if(c == '\\'){ quote++; continue; } if(c == '\"') break; x[i++] = c; } x[i] = '\0'; yylval.string = strdup(x); return STRING; } void error_message (char *format, ...) { va_list args; va_start (args, format); fprintf (stderr, "%s:%d:", filename, lineno); vfprintf (stderr, format, args); va_end (args); numerror++; } Index: stable/3/contrib/com_err/parse.y =================================================================== --- stable/3/contrib/com_err/parse.y (revision 62581) +++ stable/3/contrib/com_err/parse.y (revision 62582) @@ -1,173 +1,171 @@ %{ /* * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "compile_et.h" -#if 0 RCSID("$Id: parse.y,v 1.9 1999/07/04 14:54:58 assar Exp $"); -#endif void yyerror (char *s); long name2number(const char *str); void error_message(char *, ...); extern char *yytext; /* This is for bison */ #if !defined(alloca) && !defined(HAVE_ALLOCA) #define alloca(x) malloc(x) #endif %} %union { char *string; int number; } %token ET INDEX PREFIX EC ID END %token STRING %token NUMBER %% file : /* */ | header statements ; header : id et | et ; id : ID STRING { id_str = $2; } ; et : ET STRING { base = name2number($2); strncpy(name, $2, sizeof(name)); name[sizeof(name) - 1] = '\0'; free($2); } | ET STRING STRING { base = name2number($2); strncpy(name, $3, sizeof(name)); name[sizeof(name) - 1] = '\0'; free($2); free($3); } ; statements : statement | statements statement ; statement : INDEX NUMBER { number = $2; } | PREFIX STRING { prefix = realloc(prefix, strlen($2) + 2); strcpy(prefix, $2); strcat(prefix, "_"); free($2); } | PREFIX { prefix = realloc(prefix, 1); *prefix = '\0'; } | EC STRING ',' STRING { struct error_code *ec = malloc(sizeof(*ec)); ec->next = NULL; ec->number = number; if(prefix && *prefix != '\0') { asprintf (&ec->name, "%s%s", prefix, $2); free($2); } else ec->name = $2; ec->string = $4; APPEND(codes, ec); number++; } | END { YYACCEPT; } ; %% long name2number(const char *str) { const char *p; long base = 0; const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz0123456789_"; if(strlen(str) > 4) { yyerror("table name too long"); return 0; } for(p = str; *p; p++){ char *q = strchr(x, *p); if(q == NULL) { yyerror("invalid character in table name"); return 0; } base = (base << 6) + (q - x) + 1; } base <<= 8; if(base > 0x7fffffff) base = -(0xffffffff - base + 1); return base; } void yyerror (char *s) { error_message ("%s\n", s); }