1 /* $NetBSD: main1.c,v 1.18 2008/05/02 15:10:05 christos 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 #if HAVE_NBTOOL_CONFIG_H
35 #include "nbtool_config.h"
38 #include <sys/cdefs.h>
39 #if defined(__RCSID) && !defined(lint)
40 __RCSID("$NetBSD: main1.c,v 1.18 2008/05/02 15:10:05 christos Exp $");
43 #include <sys/types.h>
58 * Print warnings if an assignment of an integertype to another integertype
59 * causes an implicit narrowing conversion. If aflag is 1, these warnings
60 * are printed only if the source type is at least as wide as long. If aflag
61 * is greater than 1, they are always printed.
65 /* Print a warning if a break statement cannot be reached. */
68 /* Print warnings for pointer casts. */
71 /* Print various debug information. */
74 /* Perform stricter checking of enum types and operations on enum types. */
77 /* Print complete pathnames, not only the basename. */
80 /* Enable some extensions of gcc */
83 /* Treat warnings as errors */
87 * Apply a number of heuristic tests to attempt to intuit bugs, improve
88 * style, and reduce waste.
92 /* Attempt to check portability to other dialects of C. */
96 * In case of redeclarations/redefinitions print the location of the
97 * previous declaration/definition.
101 /* Strict ANSI C mode. */
104 /* Traditional C mode. */
107 /* Enable C9X extensions */
114 * Complain about functions and external variables used and not defined,
115 * or defined and not used.
119 /* Complain about unused function arguments. */
122 /* Complain about structures which are never defined. */
129 static void usage(void);
131 int main(int, char *[]);
141 main(int argc
, char *argv
[])
146 setprogname(argv
[0]);
149 while ((c
= getopt(argc
, argv
, "abcdeghmprstuvwyzFPSX:")) != -1) {
151 case 'a': aflag
++; break;
152 case 'b': bflag
= 1; break;
153 case 'c': cflag
= 1; break;
154 case 'd': dflag
= 1; break;
155 case 'e': eflag
= 1; break;
156 case 'F': Fflag
= 1; break;
157 case 'g': gflag
= 1; break;
158 case 'h': hflag
= 1; break;
159 case 'p': pflag
= 1; break;
160 case 'P': Pflag
= 1; break;
161 case 'r': rflag
= 1; break;
162 case 's': sflag
= 1; break;
163 case 'S': Sflag
= 1; break;
164 case 't': tflag
= 1; break;
165 case 'u': uflag
= 0; break;
166 case 'w': wflag
= 1; break;
167 case 'v': vflag
= 0; break;
168 case 'y': yflag
= 1; break;
169 case 'z': zflag
= 0; break;
176 for (ptr
= strtok(optarg
, ","); ptr
;
177 ptr
= strtok(NULL
, ",")) {
182 msg
= strtol(ptr
, &eptr
, 0);
183 if ((msg
== LONG_MIN
|| msg
== LONG_MAX
) &&
185 err(1, "invalid error message id '%s'",
187 if (*eptr
|| ptr
== eptr
|| msg
< 0 ||
189 errx(1, "invalid error message id '%s'",
191 ERR_SET(msg
, &msgset
);
206 /* open the input file */
207 if ((yyin
= fopen(argv
[0], "r")) == NULL
)
208 err(1, "cannot open '%s'", argv
[0]);
210 /* initialize output */
216 (void)signal(SIGFPE
, sigfpe
);
224 /* Following warnings cannot be suppressed by LINTED */
227 printf("%s, %d: nowarn = 0\n", curr_pos
.p_file
, curr_pos
.p_line
);
240 (void)fprintf(stderr
,
241 "Usage: %s [-abcdeghmprstuvwyzFS] [-X <id>[,<id>]... src dest\n",
249 /* cannot recover from previous errors */