diff --git a/contrib/com_err/com_err.c b/contrib/com_err/com_err.c index fc15e9a914c1..f00c602646bb 100644 --- a/contrib/com_err/com_err.c +++ b/contrib/com_err/com_err.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * 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 + * 3. 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. * @@ -35,17 +30,18 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/* $FreeBSD$ */ #ifdef HAVE_CONFIG_H #include -RCSID("$Id: com_err.c,v 1.13 1999/03/12 15:17:08 bg Exp $"); +RCSID("$Id: com_err.c,v 1.18 2002/03/10 23:07:01 assar Exp $"); #endif #include #include #include #include "com_err.h" -struct et_list *_et_list; +struct et_list *_et_list = NULL; const char * @@ -53,8 +49,12 @@ 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) { + if (code < 0) + sprintf(msg, "Unknown error %ld", code); + else + p = strerror(code); + } if (p != NULL && *p != '\0') { strncpy(msg, p, sizeof(msg) - 1); msg[sizeof(msg) - 1] = 0; @@ -70,6 +70,10 @@ init_error_table(const char **msgs, long base, int count) return 0; } +static void +default_proc (const char *whoami, long code, const char *fmt, va_list args) + __attribute__((__format__(__printf__, 3, 0))); + static void default_proc (const char *whoami, long code, const char *fmt, va_list args) { @@ -153,3 +157,17 @@ error_table_name(int num) *p = '\0'; return(buf); } + +void +add_to_error_table(struct et_list *new_table) +{ + struct et_list *et; + + for (et = _et_list; et; et = et->next) { + if (et->table->base == new_table->table->base) + return; + } + + new_table->next = _et_list; + _et_list = new_table; +} diff --git a/contrib/com_err/com_err.h b/contrib/com_err/com_err.h index 19cf034d6840..6c1faa4bd5bd 100644 --- a/contrib/com_err/com_err.h +++ b/contrib/com_err/com_err.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * 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 + * 3. 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. * @@ -36,8 +31,8 @@ * SUCH DAMAGE. */ -/* $Id: com_err.h,v 1.3 1998/05/02 20:13:28 assar Exp $ */ /* $FreeBSD$ */ +/* $Id: com_err.h,v 1.9 2001/05/11 20:03:36 assar Exp $ */ /* MIT compatible com_err library */ @@ -45,10 +40,7 @@ #define __COM_ERR_H__ #include - -#ifdef __STDC__ #include -#endif #include @@ -57,12 +49,17 @@ 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 *, ...)); +void com_err_va __P((const char *, long, const char *, va_list)) + __printflike(3, 0); + +void com_err __P((const char *, long, const char *, ...)) + __printflike(3, 4); 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 __P((int num)); + +void add_to_error_table __P((struct et_list *new_table)); #endif /* __COM_ERR_H__ */ diff --git a/contrib/com_err/com_right.h b/contrib/com_err/com_right.h index c329bced9785..09e95fa0251c 100644 --- a/contrib/com_err/com_right.h +++ b/contrib/com_err/com_right.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * 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 + * 3. 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. * @@ -36,13 +31,14 @@ * SUCH DAMAGE. */ -/* $Id: com_right.h,v 1.8 1998/02/17 21:19:43 bg Exp $ */ +/* $Id: com_right.h,v 1.11 2000/07/31 01:11:08 assar Exp $ */ /* $FreeBSD$ */ #ifndef __COM_RIGHT_H__ #define __COM_RIGHT_H__ #include +#include struct error_table { char const * const * msgs; @@ -56,8 +52,7 @@ struct et_list { 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 initialize_error_table_r __P((struct et_list **, const char **, int, long)); void free_error_table __P((struct et_list *)); #endif /* __COM_RIGHT_H__ */ diff --git a/contrib/com_err/compile_et.c b/contrib/com_err/compile_et.c index 345a39f0b140..59d9de996d63 100644 --- a/contrib/com_err/compile_et.c +++ b/contrib/com_err/compile_et.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1998-2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * 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 + * 3. 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. * @@ -35,13 +30,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/* $FreeBSD$ */ #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 $"); +RCSID("$Id: compile_et.c,v 1.16 2002/08/20 12:44:51 joda Exp $"); #endif #include @@ -89,7 +85,7 @@ generate_c(void) fprintf(c_file, "#include \"%s\"\n", hfn); fprintf(c_file, "\n"); - fprintf(c_file, "static const char *text[] = {\n"); + fprintf(c_file, "static const char *%s_error_strings[] = {\n", name); for(ec = codes, n = 0; ec; ec = ec->next, n++) { while(n < ec->number) { @@ -104,20 +100,22 @@ generate_c(void) fprintf(c_file, "\tNULL\n"); fprintf(c_file, "};\n"); fprintf(c_file, "\n"); + fprintf(c_file, "#define num_errors %d\n", number); + 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); + " initialize_error_table_r(list, %s_error_strings, " + "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); + " init_error_table(%s_error_strings, ERROR_TABLE_BASE_%s, " + "num_errors);\n", name, name); fprintf(c_file, "}\n"); fclose(c_file); @@ -147,7 +145,7 @@ generate_h(void) 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, "struct et_list;\n"); fprintf(h_file, "\n"); fprintf(h_file, "void initialize_%s_error_table_r(struct et_list **);\n", @@ -158,16 +156,16 @@ generate_h(void) 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 = %ld%s\n", ec->name, base + ec->number, + (ec->next != NULL) ? "," : ""); } - 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, "#define ERROR_TABLE_BASE_%s %ld\n", name, base); + fprintf(h_file, "\n"); fprintf(h_file, "#endif /* %s */\n", fn); @@ -200,6 +198,7 @@ main(int argc, char **argv) char *p; int optind = 0; + setprogname(argv[0]); if(getarg(args, num_args, argc, argv, &optind)) usage(1); if(help_flag) diff --git a/contrib/com_err/compile_et.h b/contrib/com_err/compile_et.h index fc6b3e54c0d9..35e4863989ff 100644 --- a/contrib/com_err/compile_et.h +++ b/contrib/com_err/compile_et.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * 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 + * 3. 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. * @@ -36,7 +31,8 @@ * SUCH DAMAGE. */ -/* $Id: compile_et.h,v 1.3 1998/11/22 09:39:46 assar Exp $ */ +/* $Id: compile_et.h,v 1.6 2000/07/01 20:21:48 assar Exp $ */ +/* $FreeBSD$ */ #ifndef __COMPILE_ET_H__ #define __COMPILE_ET_H__ diff --git a/contrib/com_err/lex.l b/contrib/com_err/lex.l index 264ad6f8ab90..b5f8db1e1e43 100644 --- a/contrib/com_err/lex.l +++ b/contrib/com_err/lex.l @@ -1,6 +1,6 @@ %{ /* - * Copyright (c) 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -15,12 +15,7 @@ * 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 + * 3. 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. * @@ -36,6 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/* $FreeBSD$ */ /* * This is to handle the definition of this symbol in some AIX @@ -47,14 +43,18 @@ #include "compile_et.h" #include "parse.h" +#include "lex.h" #if 0 -RCSID("$Id: lex.l,v 1.4 1998/11/20 05:58:52 assar Exp $"); +RCSID("$Id: lex.l,v 1.6 2000/06/22 00:42:52 assar Exp $"); #endif static unsigned lineno = 1; -void error_message(char *, ...); -int getstring(void); +static int getstring(void); + +#define YY_NO_UNPUT + +#undef ECHO %} @@ -85,7 +85,7 @@ yywrap () } #endif -int +static int getstring(void) { char x[128]; @@ -117,7 +117,7 @@ getstring(void) } void -error_message (char *format, ...) +error_message (const char *format, ...) { va_list args; diff --git a/contrib/com_err/parse.y b/contrib/com_err/parse.y index 32875d4271bb..960bcfa8f1e4 100644 --- a/contrib/com_err/parse.y +++ b/contrib/com_err/parse.y @@ -1,6 +1,6 @@ %{ /* - * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -15,12 +15,7 @@ * 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 + * 3. 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. * @@ -36,15 +31,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/* $FreeBSD$ */ #include "compile_et.h" +#include "lex.h" #if 0 -RCSID("$Id: parse.y,v 1.9 1999/07/04 14:54:58 assar Exp $"); +RCSID("$Id: parse.y,v 1.11 2000/06/22 00:42:52 assar Exp $"); #endif void yyerror (char *s); -long name2number(const char *str); -void error_message(char *, ...); +static long name2number(const char *str); extern char *yytext; @@ -141,7 +137,7 @@ statement : INDEX NUMBER %% -long +static long name2number(const char *str) { const char *p;