diff options
| author | lukem <lukem@NetBSD.org> | 1997-10-18 14:44:21 +0000 |
|---|---|---|
| committer | lukem <lukem@NetBSD.org> | 1997-10-18 14:44:21 +0000 |
| commit | 397a8a0855536cc80951104d87aa4af5d46cd781 (patch) | |
| tree | 3cc9c30f154d428f92f4e16568bd3bffc6297c92 /usr.bin/error | |
| parent | 0026c9e93a612dd4b204926445eeae8cdd7724ed (diff) | |
WARNSify (big job!), fix .Nm usage
Diffstat (limited to 'usr.bin/error')
| -rw-r--r-- | usr.bin/error/error.1 | 46 | ||||
| -rw-r--r-- | usr.bin/error/error.h | 63 | ||||
| -rw-r--r-- | usr.bin/error/filter.c | 51 | ||||
| -rw-r--r-- | usr.bin/error/input.c | 98 | ||||
| -rw-r--r-- | usr.bin/error/main.c | 30 | ||||
| -rw-r--r-- | usr.bin/error/pi.c | 37 | ||||
| -rw-r--r-- | usr.bin/error/subr.c | 174 | ||||
| -rw-r--r-- | usr.bin/error/touch.c | 149 |
8 files changed, 396 insertions, 252 deletions
diff --git a/usr.bin/error/error.1 b/usr.bin/error/error.1 index 00c63b4310f..a78f2f19810 100644 --- a/usr.bin/error/error.1 +++ b/usr.bin/error/error.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: error.1,v 1.4 1997/02/11 06:01:54 mikel Exp $ +.\" $NetBSD: error.1,v 1.5 1997/10/18 14:44:21 lukem Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -40,7 +40,7 @@ .Nm error .Nd analyze and disperse compiler error messages .Sh SYNOPSIS -.Nm error +.Nm .Op Fl n .Op Fl s .Op Fl q @@ -49,7 +49,7 @@ .Op Fl I Ar ignorefile .Op name .Sh DESCRIPTION -.Nm Error +.Nm analyzes and optionally disperses the diagnostic error messages produced by a number of compilers and language processors to the source file and line where the errors occurred. It can replace the painful, @@ -96,7 +96,7 @@ Thus the suffix list: .Dl ".c.y.foo*.h" .Pp allows -.Nm error +.Nm to touch files ending with ``.c'', ``.y'', ``.foo*'' and ``.h''. .It Fl s Print out @@ -105,7 +105,7 @@ regarding the error categorization. Not too useful. .El .Pp -.Nm Error +.Nm looks at the error messages, either from the specified file .Ar name @@ -120,17 +120,17 @@ line the error message refers. Error messages which can't be categorized by language processor or content are not inserted into any file, but are sent to the standard output. -.Nm Error +.Nm touches source files only after all input has been read. .Pp -.Nm Error +.Nm is intended to be run with its standard input connected via a pipe to the error message source. Some language processors put error messages on their standard error file; others put their messages on the standard output. Hence, both error sources should be piped together into -.Nm error . +.Nm "" . For example, when using the .Xr csh 1 syntax, @@ -142,7 +142,7 @@ by whatever programs .Xr make 1 runs when making lint. .Pp -.Nm Error +.Nm knows about the error messages produced by: .Xr make 1 , .Xr \&cc 1 , @@ -156,7 +156,7 @@ knows about the error messages produced by: .Xr f77 1 , and .Em DEC Western Research Modula\-2 . -.Nm Error +.Nm knows a standard format for error messages produced by the language processors, so is sensitive to changes in these formats. @@ -165,21 +165,21 @@ For all languages except error messages are restricted to be on one line. Some error messages refer to more than one line in more than one files; -.Nm error +.Nm will duplicate the error message and insert it at all of the places referenced. .Pp -.Nm Error +.Nm will do one of six things with error messages. .Bl -tag -width Em synchronize .It Em synchronize Some language processors produce short errors describing which file it is processing. -.Nm Error +.Nm uses these to determine the file name for languages that don't include the file name in each error message. These synchronization messages are consumed entirely by -.Nm error . +.Nm "" . .It Em discard Error messages from .Xr lint 1 @@ -192,7 +192,7 @@ and are discarded, to prevent accidently touching these libraries. Again, these error messages are consumed entirely by -.Nm error . +.Nm "" . .It Em nullify Error messages from .Xr lint 1 @@ -228,9 +228,9 @@ insertion into the file to which they refer. Only true error messages are candidates for inserting into the file they refer to. Other error messages are consumed entirely by -.Nm error +.Nm or are written to the standard output. -.Nm Error +.Nm inserts the error messages into the source file on the line preceding the line the language processor found in error. Each error message is turned into a one line comment for the @@ -254,7 +254,7 @@ To avoid this, programs with comments and source on the same line should be formatted so that language statements appear before comments. .Pp -.Nm Error +.Nm catches interrupt and terminate signals, and if in the insertion phase, will orderly terminate what it is doing. @@ -269,7 +269,7 @@ user's teletype .El .Sh HISTORY The -.Nm error +.Nm command appeared in .Bx 4.0 . @@ -284,10 +284,10 @@ only one link to it. .Pp Changing a language processor's format of error messages may cause -.Nm error +.Nm to not understand the error message. .Pp -.Nm Error , +.Nm "" , since it is purely mechanical, will not filter out subsequent errors caused by `floodgating' initiated by one syntactically trivial error. @@ -296,9 +296,9 @@ Humans are still much better at discarding these related errors. Pascal error messages belong after the lines affected (error puts them before). The alignment of the `\\' marking the point of error is also disturbed by -.Nm error . +.Nm "" . .Pp -.Nm Error +.Nm was designed for work on .Tn CRT Ns 's at reasonably high speed. diff --git a/usr.bin/error/error.h b/usr.bin/error/error.h index 37af8e0fd12..cf0ce6902ef 100644 --- a/usr.bin/error/error.h +++ b/usr.bin/error/error.h @@ -1,4 +1,4 @@ -/* $NetBSD: error.h,v 1.3 1995/09/02 06:15:25 jtc Exp $ */ +/* $NetBSD: error.h,v 1.4 1997/10/18 14:44:25 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -36,7 +36,6 @@ */ typedef int boolean; -#define reg register #define TRUE 1 #define FALSE 0 @@ -120,7 +119,7 @@ extern char *scriptname; extern boolean query; extern boolean terse; -int inquire(); /* inquire for yes/no */ +int inquire __P((char *, ...)); /* inquire for yes/no */ /* * codes for inquire() to return */ @@ -129,7 +128,7 @@ int inquire(); /* inquire for yes/no */ #define Q_YES 3 /* 'Y' */ #define Q_yes 4 /* 'y' */ -int probethisfile(); +int probethisfile __P((char *)); /* * codes for probethisfile to return */ @@ -202,25 +201,55 @@ extern Eptr *errors; extern int nfiles; extern Eptr **files; /* array of pointers into errors*/ boolean *touchedfiles; /* which files we touched */ + /* * The langauge the compilation is in, as intuited from * the flavor of error messages analyzed. */ extern int langauge; extern char *currentfilename; + /* * Functional forwards */ -char *Calloc(); -char *strsave(); -char *clobberfirst(); -char lastchar(); -char firstchar(); -char next_lastchar(); -char **wordvsplice(); -int wordvcmp(); -boolean persperdexplode(); -/* - * Printing hacks - */ -char *plural(), *verbform(); +void arrayify __P((int *, Eptr **, Eptr)); +char *Calloc __P((int, int)); +void clob_last __P((char *, char)); +int countfiles __P((Eptr *)); +Errorclass discardit __P((Eptr)); +void diverterrors __P((char *, int, Eptr **, int, boolean, int)); +void eaterrors __P((int *, Eptr **)); +boolean edit __P((char *)); +void erroradd __P((int, char **, Errorclass, Errorclass)); +void errorprint __P((FILE *, Eptr, boolean)); +void execvarg __P((int, int *, char ***)); +void filenames __P((int, Eptr **)); +void findfiles __P((int, Eptr *, int *, Eptr ***)); +char firstchar __P((char *)); +void getignored __P((char *)); +void hackfile __P((char *, Eptr **, int, int)); +void insert __P((int)); +char lastchar __P((char *)); +int mustoverwrite __P((FILE *, FILE *)); +int mustwrite __P((char *, int, FILE *)); +char next_lastchar __P((char *)); +int nopertain __P((Eptr **)); +int oktotouch __P((char *)); +void onintr __P((int)); +boolean persperdexplode __P((char *, char **, char **)); +int position __P((char *, char)); +boolean preview __P((char *, int, Eptr **, int)); +void printerrors __P((boolean, int, Eptr [])); +char *plural __P((int)); +boolean qpersperdexplode __P((char *, char **, char **)); +int settotouch __P((char *)); +char *strsave __P((char *)); +char *substitute __P((char *, char, char)); +void text __P((Eptr, boolean)); +boolean touchfiles __P((int, Eptr **, int *, char ***)); +char *verbform __P((int)); +void wordvbuild __P((char *, int*, char ***)); +int wordvcmp __P((char **, int, char **)); +void wordvprint __P((FILE *, int, char **)); +char **wordvsplice __P((int, int, char **)); +boolean writetouched __P((int)); diff --git a/usr.bin/error/filter.c b/usr.bin/error/filter.c index 47181cfb2f2..852654241bb 100644 --- a/usr.bin/error/filter.c +++ b/usr.bin/error/filter.c @@ -1,4 +1,4 @@ -/* $NetBSD: filter.c,v 1.3 1995/09/02 06:15:28 jtc Exp $ */ +/* $NetBSD: filter.c,v 1.4 1997/10/18 14:44:28 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)filter.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: filter.c,v 1.3 1995/09/02 06:15:28 jtc Exp $"; +__RCSID("$NetBSD: filter.c,v 1.4 1997/10/18 14:44:28 lukem Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -58,21 +59,24 @@ char *lint_libs[] = { 0 }; extern char* processname; -int lexsort(); +int lexsort __P((const void *, const void *)); +int search_ignore __P((char *)); + /* * Read the file ERRORNAME of the names of functions in lint * to ignore complaints about. */ +void getignored(auxname) char *auxname; { - reg int i; - FILE *fyle; - char inbuffer[256]; - int uid; - char filename[128]; - char *username; - struct passwd *passwdentry; + int i; + FILE *fyle; + char inbuffer[256]; + int uid; + char filename[128]; + char *username; + struct passwd *passwdentry; nignored = 0; if (auxname == 0){ /* use the default */ @@ -129,18 +133,24 @@ getignored(auxname) #endif } -int lexsort(cpp1, cpp2) - char **cpp1, **cpp2; +int +lexsort(c1, c2) + const void *c1, *c2; { + char **cpp1, **cpp2; + + cpp1 = (char **)c1; + cpp2 = (char **)c2; return(strcmp(*cpp1, *cpp2)); } -int search_ignore(key) +int +search_ignore(key) char *key; { - reg int ub, lb; - reg int halfway; - int order; + int ub, lb; + int halfway; + int order; if (nignored == 0) return(-1); @@ -163,11 +173,12 @@ int search_ignore(key) * and the linenumber the second. * Return the new categorization of the error class. */ -Errorclass discardit(errorp) - reg Eptr errorp; +Errorclass +discardit(errorp) + Eptr errorp; { - int language; - reg int i; + int language; + int i; Errorclass errorclass = errorp->error_e_class; switch(errorclass){ diff --git a/usr.bin/error/input.c b/usr.bin/error/input.c index 37a7d3b2d8d..d226510d0d0 100644 --- a/usr.bin/error/input.c +++ b/usr.bin/error/input.c @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.4 1995/09/10 15:55:13 christos Exp $ */ +/* $NetBSD: input.c,v 1.5 1997/10/18 14:44:32 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: input.c,v 1.4 1995/09/10 15:55:13 christos Exp $"; +__RCSID("$NetBSD: input.c,v 1.5 1997/10/18 14:44:32 lukem Exp $"); #endif /* not lint */ #include <stdio.h> @@ -52,29 +53,31 @@ char **wordv; /* the actual error message */ int nerrors; int language; -Errorclass onelong(); -Errorclass cpp(); -Errorclass pccccom(); /* Portable C Compiler C Compiler */ -Errorclass richieccom(); /* Richie Compiler for 11 */ -Errorclass lint0(); -Errorclass lint1(); -Errorclass lint2(); -Errorclass lint3(); -Errorclass make(); -Errorclass f77(); -Errorclass pi(); -Errorclass ri(); -Errorclass troff(); -Errorclass mod2(); +Errorclass catchall __P((void)); +Errorclass cpp __P((void)); +Errorclass f77 __P((void)); +Errorclass lint0 __P((void)); +Errorclass lint1 __P((void)); +Errorclass lint2 __P((void)); +Errorclass lint3 __P((void)); +Errorclass make __P((void)); +Errorclass mod2 __P((void)); +Errorclass onelong __P((void)); +Errorclass pccccom __P((void)); /* Portable C Compiler C Compiler */ +Errorclass pi __P((void)); +Errorclass ri __P((void)); +Errorclass richieccom __P((void)); /* Richie Compiler for 11 */ +Errorclass troff __P((void)); + /* * Eat all of the lines in the input file, attempting to categorize * them by their various flavors */ +void eaterrors(r_errorc, r_errorv) int *r_errorc; Eptr **r_errorv; { - extern boolean piflag; Errorclass errorclass = C_SYNC; char *line; char *inbuffer; @@ -122,14 +125,15 @@ eaterrors(r_errorc, r_errorv) /* * create a new error entry, given a zero based array and count */ +void erroradd(errorlength, errorv, errorclass, errorsubclass) int errorlength; char **errorv; Errorclass errorclass; Errorclass errorsubclass; { - reg Eptr newerror; - reg char *cp; + Eptr newerror; + char *cp; if (errorclass == C_TRUE){ /* check canonicalization of the second argument*/ @@ -167,7 +171,8 @@ erroradd(errorlength, errorv, errorclass, errorsubclass) } /* length > 0 */ } -Errorclass onelong() +Errorclass +onelong() { char **nwordv; if ( (wordc == 1) && (language != INLD) ){ @@ -213,7 +218,8 @@ Errorclass onelong() return(C_UNKNOWN); } /* end of one long */ -Errorclass cpp() +Errorclass +cpp() { /* * Now attempt a cpp error message match @@ -235,7 +241,8 @@ Errorclass cpp() return(C_UNKNOWN); } /*end of cpp*/ -Errorclass pccccom() +Errorclass +pccccom() { /* * Now attempt a ccom error message match: @@ -272,11 +279,13 @@ Errorclass pccccom() * fprintf(stderr, "%d: ", line); * */ -Errorclass richieccom() + +Errorclass +richieccom() { - reg char *cp; - reg char **nwordv; - char *file; + char *cp; + char **nwordv; + char *file; if (lastchar(wordv[1]) == ':'){ cp = wordv[1] + strlen(wordv[1]) - 1; @@ -299,10 +308,11 @@ Errorclass richieccom() return(C_UNKNOWN); } -Errorclass lint0() +Errorclass +lint0() { - reg char **nwordv; - char *line, *file; + char **nwordv; + char *line, *file; /* * Attempt a match for the new lint style normal compiler * error messages, of the form @@ -329,7 +339,8 @@ Errorclass lint0() return (C_UNKNOWN); } -Errorclass lint1() +Errorclass +lint1() { char *line1, *line2; char *file1, *file2; @@ -366,7 +377,8 @@ Errorclass lint1() return(C_UNKNOWN); } /* end of lint 1*/ -Errorclass lint2() +Errorclass +lint2() { char *file; char *line; @@ -396,7 +408,9 @@ Errorclass lint2() char *Lint31[4] = {"returns", "value", "which", "is"}; char *Lint32[6] = {"value", "is", "used,", "but", "none", "returned"}; -Errorclass lint3() + +Errorclass +lint3() { if ( (wordvcmp(wordv+2, 4, Lint31) == 0) || (wordvcmp(wordv+2, 6, Lint32) == 0) ){ @@ -413,6 +427,8 @@ char *F77_fatal[3] = {"Compiler", "error", "line"}; char *F77_error[3] = {"Error", "on", "line"}; char *F77_warning[3] = {"Warning", "on", "line"}; char *F77_no_ass[3] = {"Error.","No","assembly."}; + +Errorclass f77() { char **nwordv; @@ -452,7 +468,9 @@ f77() char *Make_Croak[3] = {"***", "Error", "code"}; char *Make_NotRemade[5] = {"not", "remade", "because", "of", "errors"}; -Errorclass make() + +Errorclass +make() { if (wordvcmp(wordv+1, 3, Make_Croak) == 0){ language = INMAKE; @@ -464,7 +482,9 @@ Errorclass make() } return(C_UNKNOWN); } -Errorclass ri() + +Errorclass +ri() { /* * Match an error message produced by ri; here is the @@ -499,7 +519,8 @@ Errorclass ri() return(C_UNKNOWN); } -Errorclass catchall() +Errorclass +catchall() { /* * Catches random things. @@ -508,7 +529,8 @@ Errorclass catchall() return(C_NONSPEC); } /* end of catch all*/ -Errorclass troff() +Errorclass +troff() { /* * troff source error message, from eqn, bib, tbl... @@ -532,7 +554,9 @@ Errorclass troff() } return(C_UNKNOWN); } -Errorclass mod2() + +Errorclass +mod2() { /* * for decwrl modula2 compiler (powell) diff --git a/usr.bin/error/main.c b/usr.bin/error/main.c index 995efade9d4..d5702f3abda 100644 --- a/usr.bin/error/main.c +++ b/usr.bin/error/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 1995/09/02 06:15:37 jtc Exp $ */ +/* $NetBSD: main.c,v 1.4 1997/10/18 14:44:35 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,17 +33,17 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/09/02 06:15:37 jtc Exp $"; +__RCSID("$NetBSD: main.c,v 1.4 1997/10/18 14:44:35 lukem Exp $"); #endif /* not lint */ #include <signal.h> @@ -74,8 +74,11 @@ boolean terse = FALSE; /* Terse output */ char *suffixlist = ".*"; /* initially, can touch any file */ -int errorsort(); -void onintr(); +int errorsort __P((const void *, const void *)); +void forkvi __P((int, char **)); +int main __P((int, char **)); +void try __P((char *, int, char **)); + /* * error [-I ignorename] [-n] [-q] [-t suffixlist] [-s] [-v] [infile] * @@ -119,6 +122,7 @@ void onintr(); * infile: The error messages come from this file. * Default: stdin */ +int main(argc, argv) int argc; char *argv[]; @@ -218,8 +222,10 @@ main(argc, argv) fflush(stdout); if (touchfiles(nfiles, files, &ed_argc, &ed_argv) && edit_files) forkvi(ed_argc, ed_argv); + return (0); } +void forkvi(argc, argv) int argc; char **argv; @@ -246,6 +252,7 @@ forkvi(argc, argv) fprintf(stdout, "Can't find any editors.\n"); } +void try(name, argc, argv) char *name; int argc; @@ -264,11 +271,12 @@ try(name, argc, argv) execvp(name, argv); } -int errorsort(epp1, epp2) - Eptr *epp1, *epp2; +int errorsort(x1, x2) + const void *x1, *x2; { - reg Eptr ep1, ep2; - int order; + Eptr *epp1 = (Eptr *)x1, *epp2 = (Eptr *)x2; + Eptr ep1, ep2; + int order; /* * Sort by: * 1) synchronization, non specific, discarded errors first; diff --git a/usr.bin/error/pi.c b/usr.bin/error/pi.c index ca7eae71aa8..f8269f19499 100644 --- a/usr.bin/error/pi.c +++ b/usr.bin/error/pi.c @@ -1,4 +1,4 @@ -/* $NetBSD: pi.c,v 1.3 1995/09/02 06:15:44 jtc Exp $ */ +/* $NetBSD: pi.c,v 1.4 1997/10/18 14:44:37 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)pi.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: pi.c,v 1.3 1995/09/02 06:15:44 jtc Exp $"; +__RCSID("$NetBSD: pi.c,v 1.4 1997/10/18 14:44:37 lukem Exp $"); #endif /* not lint */ #include <stdio.h> @@ -50,6 +51,13 @@ static char *c_linenumber; static char *unk_hdr[] = {"In", "program", "???"}; static char **c_header = &unk_hdr[0]; +boolean alldigits __P((char *)); +boolean isdateformat __P((int, char **)); +boolean instringset __P((char *, char **)); +Errorclass pi __P((void)); +boolean piptr __P((char *)); + + /* * Attempt to handle error messages produced by pi (and by pc) * @@ -159,16 +167,19 @@ char *pi_und2[] = {"undefined", "on", "lines"}; char *pi_imp1[] = {"improperly", "used", "on", "line"}; char *pi_imp2[] = {"improperly", "used", "on", "lines"}; -boolean alldigits(string) - reg char *string; +boolean +alldigits(string) + char *string; { for (; *string && isdigit(*string); string++) continue; return(*string == '\0'); } -boolean instringset(member, set) - char *member; - reg char **set; + +boolean +instringset(member, set) + char *member; + char **set; { for(; *set; set++){ if (strcmp(*set, member) == 0) @@ -177,7 +188,8 @@ boolean instringset(member, set) return(FALSE); } -boolean isdateformat(wordc, wordv) +boolean +isdateformat(wordc, wordv) int wordc; char **wordv; { @@ -189,8 +201,9 @@ boolean isdateformat(wordc, wordv) && (alldigits(wordv[4])) ); } -boolean piptr(string) - reg char *string; +boolean +piptr(string) + char *string; { if (*string != '-') return(FALSE); @@ -207,10 +220,12 @@ boolean piptr(string) extern int wordc; extern char **wordv; -Errorclass pi() +Errorclass +pi() { char **nwordv; + nwordv = NULL; if (wordc < 2) return (C_UNKNOWN); if ( ( strlen(wordv[1]) == 1) diff --git a/usr.bin/error/subr.c b/usr.bin/error/subr.c index 33e0b0734eb..0a7d89e8656 100644 --- a/usr.bin/error/subr.c +++ b/usr.bin/error/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.4 1995/09/10 15:55:15 christos Exp $ */ +/* $NetBSD: subr.c,v 1.5 1997/10/18 14:44:40 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,30 +33,33 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: subr.c,v 1.4 1995/09/10 15:55:15 christos Exp $"; +__RCSID("$NetBSD: subr.c,v 1.5 1997/10/18 14:44:40 lukem Exp $"); #endif /* not lint */ -#include <stdio.h> #include <ctype.h> +#include <err.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include "error.h" /* * Arrayify a list of rules */ +void arrayify(e_length, e_array, header) int *e_length; Eptr **e_array; Eptr header; { - reg Eptr errorp; - reg Eptr *array; - reg int listlength; - reg int listindex; + Eptr errorp; + Eptr *array; + int listlength; + int listindex; for (errorp = header, listlength = 0; errorp; errorp = errorp->error_next, listlength++) @@ -73,31 +76,19 @@ arrayify(e_length, e_array, header) *e_array = array; } -/*VARARGS1*/ -error(msg, a1, a2, a3) - char *msg; -{ - fprintf(stderr, "Error: "); - fprintf(stderr, msg, a1, a2, a3); - fprintf(stderr, "\n"); - fflush(stdout); - fflush(stderr); - exit(6); -} -/*ARGSUSED*/ -char *Calloc(nelements, size) +char * +Calloc(nelements, size) int nelements; int size; { char *back; - if ( (back = (char *)calloc(nelements, size)) == (char *)NULL){ - error("Ran out of memory.\n"); - exit(1); - } + if ( (back = (char *)calloc(nelements, size)) == (char *)NULL) + errx(1, "Ran out of memory."); return(back); } -char *strsave(instring) +char * +strsave(instring) char *instring; { char *outstring; @@ -105,15 +96,17 @@ char *strsave(instring) instring); return(outstring); } + /* * find the position of a given character in a string * (one based) */ -int position(string, ch) - reg char *string; - reg char ch; +int +position(string, ch) + char *string; + char ch; { - reg int i; + int i; if (string) for (i=1; *string; string++, i++){ if (*string == ch) @@ -121,14 +114,16 @@ int position(string, ch) } return(-1); } + /* * clobber the first occurance of ch in string by the new character */ -char *substitute(string, chold, chnew) +char * +substitute(string, chold, chnew) char *string; char chold, chnew; { - reg char *cp = string; + char *cp = string; if (cp) while (*cp){ @@ -141,7 +136,8 @@ char *substitute(string, chold, chnew) return(string); } -char lastchar(string) +char +lastchar(string) char *string; { int length; @@ -153,7 +149,8 @@ char lastchar(string) return('\0'); } -char firstchar(string) +char +firstchar(string) char *string; { if (string) @@ -162,7 +159,8 @@ char firstchar(string) return('\0'); } -char next_lastchar(string) +char +next_lastchar(string) char *string; { int length; @@ -174,6 +172,7 @@ char next_lastchar(string) return('\0'); } +void clob_last(string, newstuff) char *string, newstuff; { @@ -188,12 +187,13 @@ clob_last(string, newstuff) * parse a string that is the result of a format %s(%d) * return TRUE if this is of the proper format */ -boolean persperdexplode(string, r_perd, r_pers) +boolean +persperdexplode(string, r_perd, r_pers) char *string; char **r_perd, **r_pers; { - reg char *cp; - int length = 0; + char *cp; + int length = 0; if (string) length = strlen(string); @@ -215,16 +215,18 @@ boolean persperdexplode(string, r_perd, r_pers) } return(FALSE); } + /* * parse a quoted string that is the result of a format \"%s\"(%d) * return TRUE if this is of the proper format */ -boolean qpersperdexplode(string, r_perd, r_pers) +boolean +qpersperdexplode(string, r_perd, r_pers) char *string; char **r_perd, **r_pers; { - reg char *cp; - int length = 0; + char *cp; + int length = 0; if (string) length = strlen(string); @@ -263,36 +265,37 @@ static char mod2incomment[] = MOD2INCOMMENT; static char mod2outcomment[] = MOD2OUTCOMMENT; struct lang_desc lang_table[] = { - /*INUNKNOWN 0*/ "unknown", cincomment, coutcomment, - /*INCPP 1*/ "cpp", cincomment, coutcomment, - /*INCC 2*/ "cc", cincomment, coutcomment, - /*INAS 3*/ "as", ASINCOMMENT, newline, - /*INLD 4*/ "ld", cincomment, coutcomment, - /*INLINT 5*/ "lint", cincomment, coutcomment, - /*INF77 6*/ "f77", fincomment, foutcomment, - /*INPI 7*/ "pi", piincomment, pioutcomment, - /*INPC 8*/ "pc", piincomment, pioutcomment, - /*INFRANZ 9*/ "franz",lispincomment, newline, - /*INLISP 10*/ "lisp", lispincomment, newline, - /*INVAXIMA 11*/ "vaxima",lispincomment,newline, - /*INRATFOR 12*/ "ratfor",fincomment, foutcomment, - /*INLEX 13*/ "lex", cincomment, coutcomment, - /*INYACC 14*/ "yacc", cincomment, coutcomment, - /*INAPL 15*/ "apl", ".lm", newline, - /*INMAKE 16*/ "make", ASINCOMMENT, newline, - /*INRI 17*/ "ri", riincomment, rioutcomment, - /*INTROFF 18*/ "troff",troffincomment,troffoutcomment, - /*INMOD2 19*/ "mod2", mod2incomment, mod2outcomment, - 0, 0, 0 + { /*INUNKNOWN 0*/ "unknown", cincomment, coutcomment }, + { /*INCPP 1*/ "cpp", cincomment, coutcomment }, + { /*INCC 2*/ "cc", cincomment, coutcomment }, + { /*INAS 3*/ "as", ASINCOMMENT, newline }, + { /*INLD 4*/ "ld", cincomment, coutcomment }, + { /*INLINT 5*/ "lint", cincomment, coutcomment }, + { /*INF77 6*/ "f77", fincomment, foutcomment }, + { /*INPI 7*/ "pi", piincomment, pioutcomment }, + { /*INPC 8*/ "pc", piincomment, pioutcomment }, + { /*INFRANZ 9*/ "franz",lispincomment, newline }, + { /*INLISP 10*/ "lisp", lispincomment, newline }, + { /*INVAXIMA 11*/ "vaxima",lispincomment,newline }, + { /*INRATFOR 12*/ "ratfor",fincomment, foutcomment }, + { /*INLEX 13*/ "lex", cincomment, coutcomment }, + { /*INYACC 14*/ "yacc", cincomment, coutcomment }, + { /*INAPL 15*/ "apl", ".lm", newline }, + { /*INMAKE 16*/ "make", ASINCOMMENT, newline }, + { /*INRI 17*/ "ri", riincomment, rioutcomment }, + { /*INTROFF 18*/ "troff",troffincomment,troffoutcomment }, + { /*INMOD2 19*/ "mod2", mod2incomment, mod2outcomment }, + { 0, 0, 0 } }; +void printerrors(look_at_subclass, errorc, errorv) boolean look_at_subclass; int errorc; Eptr errorv[]; { - reg int i; - reg Eptr errorp; + int i; + Eptr errorp; for (errorp = errorv[i = 0]; i < errorc; errorp = errorv[++i]){ if (errorp->error_e_class == C_IGNORE) @@ -308,6 +311,7 @@ printerrors(look_at_subclass, errorc, errorv) } } +void wordvprint(fyle, wordc, wordv) FILE *fyle; int wordc; @@ -327,15 +331,16 @@ wordvprint(fyle, wordc, wordv) * Given a string, parse it into a number of words, and build * a wordc wordv combination pointing into it. */ +void wordvbuild(string, r_wordc, r_wordv) char *string; int *r_wordc; char ***r_wordv; { - reg char *cp; - char **wordv; - int wordcount; - int wordindex; + char *cp; + char **wordv; + int wordcount; + int wordindex; for (wordcount = 0, cp = string; *cp; wordcount++){ while (*cp && isspace(*cp)) @@ -357,7 +362,7 @@ wordvbuild(string, r_wordc, r_wordv) *cp++ = '\0'; } if (wordcount != 0) - error("Initial miscount of the number of words in a line\n"); + errx(6, "Initial miscount of the number of words in a line"); wordv[wordindex] = (char *)0; #ifdef FULLDEBUG for (wordcount = 0; wordcount < wordindex; wordcount++) @@ -367,22 +372,24 @@ wordvbuild(string, r_wordc, r_wordv) *r_wordc = wordindex; *r_wordv = wordv; } + /* * Compare two 0 based wordvectors */ -int wordvcmp(wordv1, wordc, wordv2) +int +wordvcmp(wordv1, wordc, wordv2) char **wordv1; int wordc; char **wordv2; { - reg int i; - int back; + int i; + int back; + for (i = 0; i < wordc; i++){ if (wordv1[i] == 0 || wordv2[i] == 0) - return(-1); - if (back = strcmp(wordv1[i], wordv2[i])){ + return(-1); + if ((back = strcmp(wordv1[i], wordv2[i])) != NULL) return(back); - } } return(0); /* they are equal */ } @@ -391,14 +398,15 @@ int wordvcmp(wordv1, wordc, wordv2) * splice a 0 basedword vector onto the tail of a * new wordv, allowing the first emptyhead slots to be empty */ -char **wordvsplice(emptyhead, wordc, wordv) +char ** +wordvsplice(emptyhead, wordc, wordv) int emptyhead; int wordc; char **wordv; { - reg char **nwordv; - int nwordc = emptyhead + wordc; - reg int i; + char **nwordv; + int nwordc = emptyhead + wordc; + int i; nwordv = (char **)Calloc(nwordc, sizeof (char *)); for (i = 0; i < emptyhead; i++) @@ -408,19 +416,23 @@ char **wordvsplice(emptyhead, wordc, wordv) } return(nwordv); } + /* * plural'ize and verb forms */ static char *S = "s"; static char *N = ""; -char *plural(n) + +char * +plural(n) int n; { return( n > 1 ? S : N); } -char *verbform(n) + +char * +verbform(n) int n; { return( n > 1 ? N : S); } - diff --git a/usr.bin/error/touch.c b/usr.bin/error/touch.c index d0ea5554efa..b00b8ae7019 100644 --- a/usr.bin/error/touch.c +++ b/usr.bin/error/touch.c @@ -1,4 +1,4 @@ -/* $NetBSD: touch.c,v 1.5 1997/05/17 19:40:47 pk Exp $ */ +/* $NetBSD: touch.c,v 1.6 1997/10/18 14:44:42 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,21 +33,27 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)touch.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: touch.c,v 1.5 1997/05/17 19:40:47 pk Exp $"; +__RCSID("$NetBSD: touch.c,v 1.6 1997/10/18 14:44:42 lukem Exp $"); #endif /* not lint */ #include <sys/types.h> #include <sys/stat.h> +#include <ctype.h> #include <signal.h> -#include <unistd.h> #include <stdio.h> -#include <ctype.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif #include "error.h" #include "pathnames.h" @@ -60,19 +66,20 @@ static char rcsid[] = "$NetBSD: touch.c,v 1.5 1997/05/17 19:40:47 pk Exp $"; #define FILEITERATE(fi, lb) for (fi = lb; fi <= nfiles; fi++) int touchstatus = Q_YES; +void findfiles(nerrors, errors, r_nfiles, r_files) - int nerrors; + int nerrors; Eptr *errors; - int *r_nfiles; + int *r_nfiles; Eptr ***r_files; { - int nfiles; + int nfiles; Eptr **files; - char *name; - reg int ei; - int fi; - reg Eptr errorp; + char *name; + int ei; + int fi; + Eptr errorp; nfiles = countfiles(errors); @@ -113,12 +120,13 @@ findfiles(nerrors, errors, r_nfiles, r_files) *r_files = files; } -int countfiles(errors) +int +countfiles(errors) Eptr *errors; { char *name; int ei; - reg Eptr errorp; + Eptr errorp; int nfiles; nfiles = 0; @@ -133,6 +141,7 @@ int countfiles(errors) } return(nfiles); } + char *class_table[] = { /*C_UNKNOWN 0 */ "Unknown", /*C_IGNORE 1 */ "ignore", @@ -147,14 +156,15 @@ char *class_table[] = { int class_count[C_LAST - C_FIRST] = {0}; +void filenames(nfiles, files) int nfiles; Eptr **files; { - reg int fi; - char *sep = " "; + int fi; + char *sep = " "; extern char *class_table[]; - int someerrors; + int someerrors; /* * first, simply dump out errors that @@ -185,13 +195,14 @@ filenames(nfiles, files) /* * Dump out errors that don't pertain to any file */ -int nopertain(files) +int +nopertain(files) Eptr **files; { int type; int someerrors = 0; - reg Eptr *erpp; - reg Eptr errorp; + Eptr *erpp; + Eptr errorp; if (files[1] - files[0] <= 0) return(0); @@ -219,20 +230,21 @@ int nopertain(files) extern boolean notouch; -boolean touchfiles(nfiles, files, r_edargc, r_edargv) +boolean +touchfiles(nfiles, files, r_edargc, r_edargv) int nfiles; Eptr **files; int *r_edargc; char ***r_edargv; { - char *name; - reg Eptr errorp; - reg int fi; - reg Eptr *erpp; - int ntrueerrors; - boolean scribbled; - int n_pissed_on; /* # of file touched*/ - int spread; + char *name; + Eptr errorp; + int fi; + Eptr *erpp; + int ntrueerrors; + boolean scribbled; + int n_pissed_on; /* # of file touched*/ + int spread; FILEITERATE(fi, 1){ name = (*files[fi])->error_text[0]; @@ -278,10 +290,12 @@ boolean touchfiles(nfiles, files, r_edargc, r_edargv) } } +void hackfile(name, files, ix, nerrors) char *name; Eptr **files; int ix; + int nerrors; { boolean previewed; int errordest; /* where errors go*/ @@ -310,14 +324,15 @@ hackfile(name, files, ix, nerrors) } } -boolean preview(name, nerrors, files, ix) +boolean +preview(name, nerrors, files, ix) char *name; int nerrors; Eptr **files; int ix; { int back; - reg Eptr *erpp; + Eptr *erpp; if (nerrors <= 0) return(FALSE); @@ -341,7 +356,8 @@ boolean preview(name, nerrors, files, ix) return(back); } -int settotouch(name) +int +settotouch(name) char *name; { int dest = TOSTDOUT; @@ -388,6 +404,7 @@ int settotouch(name) return(dest); } +void diverterrors(name, dest, files, ix, previewed, nterrors) char *name; int dest; @@ -397,8 +414,8 @@ diverterrors(name, dest, files, ix, previewed, nterrors) int nterrors; { int nerrors; - reg Eptr *erpp; - reg Eptr errorp; + Eptr *erpp; + Eptr errorp; nerrors = files[ix+1] - files[ix]; @@ -432,13 +449,14 @@ diverterrors(name, dest, files, ix, previewed, nterrors) } } -int oktotouch(filename) +int +oktotouch(filename) char *filename; { - extern char *suffixlist; - reg char *src; - reg char *pat; - char *osrc; + extern char *suffixlist; + char *src; + char *pat; + char *osrc; pat = suffixlist; if (pat == 0) @@ -474,6 +492,7 @@ int oktotouch(filename) } return(0); } + /* * Construct an execv argument * We need 1 argument for the editor's name @@ -484,6 +503,7 @@ int oktotouch(filename) * We fill in the initial search string. * We fill in the arguments, and the null. */ +void execvarg(n_pissed_on, r_argc, r_argv) int n_pissed_on; int *r_argc; @@ -493,6 +513,7 @@ execvarg(n_pissed_on, r_argc, r_argv) char *sep; int fi; + sep = NULL; (*r_argv) = (char **)Calloc(n_pissed_on + 3, sizeof(char *)); (*r_argc) = n_pissed_on + 2; (*r_argv)[1] = "+1;/###/"; @@ -528,7 +549,8 @@ boolean tempfileopen = FALSE; * open the file; guaranteed to be both readable and writable * Well, if it isn't, then return TRUE if something failed */ -boolean edit(name) +boolean +edit(name) char *name; { int fd; @@ -554,10 +576,13 @@ boolean edit(name) o_lineno = 0; return(FALSE); } + /* * Position to the line (before, after) the line given by place */ char edbuf[BUFSIZ]; + +void insert(place) int place; { @@ -569,9 +594,10 @@ insert(place) } } +void text(p, use_all) - reg Eptr p; - boolean use_all; + Eptr p; + boolean use_all; { int offset = use_all ? 0 : 2; @@ -588,14 +614,15 @@ text(p, use_all) * write the touched file to its temporary copy, * then bring the temporary in over the local file */ +boolean writetouched(overwrite) int overwrite; { - reg int nread; - reg FILE *localfile; - reg FILE *tmpfile; - int botch; - int oktorm; + int nread; + FILE *localfile; + FILE *tmpfile; + int botch; + int oktorm; botch = 0; oktorm = 1; @@ -650,10 +677,12 @@ writetouched(overwrite) tempfileopen = FALSE; return(TRUE); } + /* * return 1 if the tmpfile can be removed after writing it out */ -int mustoverwrite(preciousfile, tmpfile) +int +mustoverwrite(preciousfile, tmpfile) FILE *preciousfile; FILE *tmpfile; { @@ -668,6 +697,7 @@ int mustoverwrite(preciousfile, tmpfile) /* * return 0 on catastrophe */ +int mustwrite(base, n, preciousfile) char *base; int n; @@ -705,7 +735,8 @@ mustwrite(base, n, preciousfile) } void -onintr() +onintr(dummy) + int dummy; { switch(inquire(terse ? "\nContinue? " @@ -726,6 +757,7 @@ onintr() /*NOTREACHED*/ } +void errorprint(place, errorp, print_all) FILE *place; Eptr errorp; @@ -740,18 +772,30 @@ errorprint(place, errorp, print_all) putc('\n', place); } -int inquire(fmt, a1, a2) +int +#if __STDC__ +inquire(char *fmt, ...) +#else +inquire(fmt, va_alist) char *fmt; - /*VARARGS1*/ + va_dcl +#endif { + va_list ap; char buffer[128]; +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + if (queryfile == NULL) return(0); for(;;){ do{ fflush(stdout); - fprintf(stderr, fmt, a1, a2); + vfprintf(stderr, fmt, ap); fflush(stderr); } while (fgets(buffer, 127, queryfile) == NULL); switch(buffer[0]){ @@ -764,7 +808,8 @@ int inquire(fmt, a1, a2) } } -int probethisfile(name) +int +probethisfile(name) char *name; { struct stat statbuf; |
