From f6e53120d810b99aa2372965b1e8abfa8bf85727 Mon Sep 17 00:00:00 2001 From: charnier Date: Mon, 30 Jun 1997 06:42:43 +0000 Subject: Mdoc'ify man page. Use err(3). Remove whoami. --- usr.bin/compile_et/compile_et.1 | 73 ++++++++++++++++++++--------------------- usr.bin/compile_et/compile_et.c | 39 ++++++++-------------- usr.bin/compile_et/compiler.h | 1 - 3 files changed, 49 insertions(+), 64 deletions(-) (limited to 'usr.bin/compile_et') diff --git a/usr.bin/compile_et/compile_et.1 b/usr.bin/compile_et/compile_et.1 index f17a278..e5cef6a 100644 --- a/usr.bin/compile_et/compile_et.1 +++ b/usr.bin/compile_et/compile_et.1 @@ -1,79 +1,78 @@ .\" Copyright (c) 1988 Massachusetts Institute of Technology, .\" Student Information Processing Board. All rights reserved. .\" -.\" $Header$ +.\" $Header: /home/ncvs/src/usr.bin/compile_et/compile_et.1,v 1.1 1995/01/14 22:29:30 wollman Exp $ .\" -.TH COMPILE_ET 1 "22 Nov 1988" SIPB -.SH NAME -compile_et \- error table compiler -.SH SYNOPSIS -.B compile_et -file -.SH DESCRIPTION -.B Compile_et +.Dd November 22, 1988 +.Os +.Dt COMPILE_ET 1 +.Sh NAME +.Nm compile_et +.Nd error table compiler +.Sh SYNOPSIS +.Nm compile_et +.Ar file +.Sh DESCRIPTION +.Nm Compile_et converts a table listing error-code names and associated messages into a C source file suitable for use with the -.IR com_err (3) +.Xr com_err 3 library. - +.Pp The source file name must end with a suffix of ``.et''; the file consists of a declaration supplying the name (up to four characters long) of the error-code table: -.B error_table -.I name +.Em error_table name followed by up to 256 entries of the form: -.B error_code -.I name, +.Em error_code name , " -.I string +.Em string " and a final -.B end +.Em end to indicate the end of the table. - +.Pp The name of the table is used to construct the name of a subroutine -.I initialize_XXXX_error_table +.Em initialize_XXXX_error_table which must be called in order for the -.I com_err +.Xr com_err 3 library to recognize the error table. - +.Pp The various error codes defined are assigned sequentially increasing numbers (starting with a large number computed as a hash function of the name of the table); thus for compatibility it is suggested that new codes be added only to the end of an existing table, and that no codes be removed from tables. - +.Pp The names defined in the table are placed into a C header file with preprocessor directives defining them as integer constants of up to 32 bits in magnitude. - +.Pp A C source file is also generated which should be compiled and linked with the object files which reference these error codes; it contains the text of the messages and the initialization subroutine. Both C files have names derived from that of the original source file, with the ``.et'' suffix replaced by ``.c'' and ``.h''. - +.Pp A ``#'' in the source file is treated as a comment character, and all remaining text to the end of the source line will be ignored. - -.SH BUGS - +.Sh BUGS Since -.B compile_et +.Nm compile_et uses a very simple parser based on -.IR yacc (1), +.Xr yacc 1 , its error recovery leaves much to be desired. - -.\" .IR for manual entries -.\" .PP for paragraph breaks - -.SH "SEE ALSO" -com_err (3). - -Ken Raeburn, "A Common Error Description Library for UNIX". +.Sh "SEE ALSO" +.Xr yacc 1 , +.Xr com_err 3 +.Pp +.Rs +.%A Ken Raeburn +.%T "A Common Error Description Library for UNIX" +.Re diff --git a/usr.bin/compile_et/compile_et.c b/usr.bin/compile_et/compile_et.c index fcedb8f..055a9b6 100644 --- a/usr.bin/compile_et/compile_et.c +++ b/usr.bin/compile_et/compile_et.c @@ -7,11 +7,12 @@ * */ +#include +#include #include #include -#include -#include #include +#include #include #include "mit-sipb-copyright.h" #include "compiler.h" @@ -25,7 +26,7 @@ static const char copyright[] = "Copyright 1987,1988 by MIT Student Information Processing Board"; static const char rcsid_compile_et_c[] = - "$Header: /home/ncvs/src/usr.bin/compile_et/compile_et.c,v 1.2 1995/01/14 22:29:31 wollman Exp $"; + "$Header: /home/ncvs/src/usr.bin/compile_et/compile_et.c,v 1.3 1996/07/12 19:05:17 jkh Exp $"; #endif extern char *gensym(); @@ -41,10 +42,8 @@ extern int yylineno; char * xmalloc (size) unsigned int size; { char * p = malloc (size); - if (!p) { - perror (whoami); - exit (1); - } + if (!p) + err(1, NULL); return p; } @@ -112,14 +111,12 @@ char c_file[MAXPATHLEN]; /* output file */ char h_file[MAXPATHLEN]; /* output */ static void usage () { - fprintf (stderr, "%s: usage: %s ERROR_TABLE\n", - whoami, whoami); + fprintf (stderr, "usage: compile_et ERROR_TABLE\n"); exit (1); } static void dup_err (type, one, two) char const *type, *one, *two; { - fprintf (stderr, "%s: multiple %s specified: `%s' and `%s'\n", - whoami, type, one, two); + warnx("multiple %s specified: `%s' and `%s'", type, one, two); usage (); } @@ -132,10 +129,6 @@ int main (argc, argv) int argc; char **argv; { /* argument parsing */ debug = 0; filename = 0; - whoami = argv[0]; - p = strrchr (whoami, '/'); - if (p) - whoami = p+1; while (argv++, --argc) { char *arg = *argv; if (arg[0] != '-') { @@ -153,7 +146,7 @@ int main (argc, argv) int argc; char **argv; { if (!arg) usage (); if (language) - dup_err ("languanges", language_names[(int)language], arg); + dup_err ("languages", language_names[(int)language], arg); #define check_lang(x,v) else if (!strcasecmp(arg,x)) language = v check_lang ("c", lang_C); check_lang ("ansi_c", lang_C); @@ -168,16 +161,12 @@ int main (argc, argv) int argc; char **argv; { check_lang ("c-plus-plus", lang_CPP); #undef check_lang else { - fprintf (stderr, "%s: unknown language name `%s'\n", - whoami, arg); - fprintf (stderr, "\tpick one of: C K&R-C\n"); - exit (1); + errx(1, "unknown language name `%s'\n\tpick one of: C K&R-C", arg); } } else { - fprintf (stderr, "%s: unknown control argument -`%s'\n", - whoami, arg); - usage (); + warnx("unknown control argument -`%s'", arg); + usage (); } } } @@ -186,9 +175,7 @@ int main (argc, argv) int argc; char **argv; { if (!got_language) language = lang_KRC; else if (language == lang_CPP) { - fprintf (stderr, "%s: Sorry, C++ support is not yet finished.\n", - whoami); - exit (1); + errx(1, "sorry, C++ support is not yet finished"); } p = xmalloc (strlen (filename) + 5); diff --git a/usr.bin/compile_et/compiler.h b/usr.bin/compile_et/compiler.h index 43752e2..3bf568d 100644 --- a/usr.bin/compile_et/compiler.h +++ b/usr.bin/compile_et/compiler.h @@ -17,4 +17,3 @@ enum lang { int debug; /* dump debugging info? */ char *filename; /* error table source */ enum lang language; -const char *whoami; -- cgit v1.1