1 /* $NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $ */
4 * Copyright (c) 1994, 1995 Jochen Pohl
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Jochen Pohl for
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 #if defined(__RCSID) && !defined(lint)
36 __RCSID("$NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $");
38 __FBSDID("$FreeBSD$");
40 #include <sys/types.h>
55 * Print warnings if an assignment of an integertype to another integertype
56 * causes an implizit narrowing conversion. If aflag is 1, these warnings
57 * are printed only if the source type is at least as wide as long. If aflag
58 * is greater than 1, they are always printed.
62 /* Print a warning if a break statement cannot be reached. */
65 /* Print warnings for pointer casts. */
68 /* Print various debug information. */
71 /* Perform stricter checking of enum types and operations on enum types. */
74 /* Print complete pathnames, not only the basename. */
77 /* Enable some extensions of gcc */
80 /* Treat warnings as errors */
84 * Apply a number of heuristic tests to attempt to intuit bugs, improve
85 * style, and reduce waste.
89 /* Attempt to check portability to other dialects of C. */
93 * In case of redeclarations/redefinitions print the location of the
94 * previous declaration/definition.
98 /* Strict ANSI C mode. */
101 /* Traditional C mode. */
105 * Complain about functions and external variables used and not defined,
106 * or defined and not used.
110 /* Complain about unused function arguments. */
113 /* Complain about structures which are never defined. */
118 static void usage(void);
120 int main(int, char *[]);
123 main(int argc, char *argv[])
129 while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFX:")) != -1) {
131 case 'a': aflag++; break;
132 case 'b': bflag = 1; break;
133 case 'c': cflag = 1; break;
134 case 'd': dflag = 1; break;
135 case 'e': eflag = 1; break;
136 case 'F': Fflag = 1; break;
137 case 'g': gflag = 1; break;
138 case 'h': hflag = 1; break;
139 case 'p': pflag = 1; break;
140 case 'r': rflag = 1; break;
141 case 's': sflag = 1; break;
142 case 't': tflag = 1; break;
143 case 'u': uflag = 0; break;
144 case 'w': wflag = 1; break;
145 case 'v': vflag = 0; break;
146 case 'y': yflag = 1; break;
147 case 'z': zflag = 0; break;
154 for (ptr = strtok(optarg, ","); ptr;
155 ptr = strtok(NULL, ",")) {
157 long msg = strtol(ptr, &eptr, 0);
158 if ((msg == LONG_MIN || msg == LONG_MAX) &&
160 err(1, "invalid error message id '%s'",
162 if (*eptr || ptr == eptr || msg < 0 ||
164 errx(1, "invalid error message id '%s'",
166 ERR_SET(msg, &msgset);
181 /* open the input file */
182 if ((yyin = fopen(argv[0], "r")) == NULL)
183 err(1, "cannot open '%s'", argv[0]);
185 /* initialize output */
198 /* Following warnings cannot be suppressed by LINTED */
211 (void)fprintf(stderr,
212 "usage: lint1 [-abcdeghmprstuvwyzF] [-X <id>[,<id>]... src dest\n");
219 /* cannot recover from previous errors */