diff options
Diffstat (limited to 'usr.bin/xlint/lint1/main1.c')
-rw-r--r-- | usr.bin/xlint/lint1/main1.c | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/usr.bin/xlint/lint1/main1.c b/usr.bin/xlint/lint1/main1.c index 0add206..f04d817 100644 --- a/usr.bin/xlint/lint1/main1.c +++ b/usr.bin/xlint/lint1/main1.c @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $ */ +/* $NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -31,14 +31,18 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef lint -static char rcsid[] = "$NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $"; +#include <sys/cdefs.h> +#if defined(__RCSID) && !defined(lint) +__RCSID("$NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $"); #endif +#include <sys/types.h> #include <stdio.h> +#include <string.h> #include <stdlib.h> #include <unistd.h> -#include <err.h> +#include <errno.h> +#include <limits.h> #include "lint1.h" @@ -49,7 +53,7 @@ int yflag; * Print warnings if an assignment of an integertype to another integertype * causes an implizit narrowing conversion. If aflag is 1, these warnings * are printed only if the source type is at least as wide as long. If aflag - * is greather then 1, they are always printed. + * is greater than 1, they are always printed. */ int aflag; @@ -71,6 +75,9 @@ int Fflag; /* Enable some extensions of gcc */ int gflag; +/* Treat warnings as errors */ +int wflag; + /* * Apply a number of heuristic tests to attempt to intuit bugs, improve * style, and reduce waste. @@ -104,16 +111,22 @@ int vflag = 1; /* Complain about structures which are never defined. */ int zflag = 1; -static void usage __P((void)); +err_set msgset; + +static void usage(void); + +int main(int, char *[]); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int c; + char *ptr; - while ((c = getopt(argc, argv, "abcdeghprstuvyzF")) != -1) { + setprogname(argv[0]); + + ERR_ZERO(&msgset); + while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFX:")) != -1) { switch (c) { case 'a': aflag++; break; case 'b': bflag = 1; break; @@ -128,10 +141,35 @@ main(argc, argv) case 's': sflag = 1; break; case 't': tflag = 1; break; case 'u': uflag = 0; break; + case 'w': wflag = 1; break; case 'v': vflag = 0; break; case 'y': yflag = 1; break; case 'z': zflag = 0; break; - case '?': usage(); + + case 'm': + msglist(); + return(0); + + case 'X': + for (ptr = strtok(optarg, ","); ptr; + ptr = strtok(NULL, ",")) { + char *eptr; + long msg = strtol(ptr, &eptr, 0); + if ((msg == LONG_MIN || msg == LONG_MAX) && + errno == ERANGE) + err(1, "invalid error message id '%s'", + ptr); + if (*eptr || ptr == eptr || msg < 0 || + msg >= ERR_SETSIZE) + errx(1, "invalid error message id '%s'", + ptr); + ERR_SET(msg, &msgset); + } + break; + case '?': + default: + usage(); + break; } } argc -= optind; @@ -168,14 +206,16 @@ main(argc, argv) } static void -usage() +usage(void) { - (void)fprintf(stderr, "usage: lint1 [-abcdeghprstuvyzF] src dest\n"); + (void)fprintf(stderr, + "Usage: %s [-abcdeghmprstuvwyzF] [-X <id>[,<id>]... src dest\n", + getprogname()); exit(1); } - + void -norecover() +norecover(void) { /* cannot recover from previous errors */ error(224); |