libm: Fix typos in Makefile comments.
[dragonfly.git] / usr.bin / xlint / lint1 / main1.c
blob694ac0219b5b6b9ebbdd392f1e821d53877db415
1 /* $NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $ */
3 /*
4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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
18 * The NetBSD Project.
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.
33 * $NetBSD: main1.c,v 1.3 1995/10/02 17:29:56 jpo Exp $
34 * $DragonFly: src/usr.bin/xlint/lint1/main1.c,v 1.6 2004/07/07 12:24:00 asmodai Exp $
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <unistd.h>
40 #include <err.h>
42 #include "lint1.h"
44 /* set yydebug to 1*/
45 int yflag;
48 * Print warnings if an assignment of an integertype to another integertype
49 * causes an implizit narrowing conversion. If aflag is 1, these warnings
50 * are printed only if the source type is at least as wide as long. If aflag
51 * is greather then 1, they are always printed.
53 int aflag;
55 /* Print a warning if a break statement cannot be reached. */
56 int bflag;
58 /* Print warnings for pointer casts. */
59 int cflag;
61 /* Print various debug information. */
62 int dflag;
64 /* Perform stricter checking of enum types and operations on enum types. */
65 int eflag;
67 /* Print complete pathnames, not only the basename. */
68 int Fflag;
70 /* Enable some extensions of gcc */
71 int gflag;
74 * Apply a number of heuristic tests to attempt to intuit bugs, improve
75 * style, and reduce waste.
77 int hflag;
79 /* Attempt to check portability to other dialects of C. */
80 int pflag;
83 * In case of redeclarations/redefinitions print the location of the
84 * previous declaration/definition.
86 int rflag;
88 /* Strict ANSI C mode. */
89 int sflag;
91 /* Traditional C mode. */
92 int tflag;
95 * Complain about functions and external variables used and not defined,
96 * or defined and not used.
98 int uflag = 1;
100 /* Complain about unused function arguments. */
101 int vflag = 1;
103 /* Complain about structures which are never defined. */
104 int zflag = 1;
106 static void usage(void);
109 main(int argc, char *argv[])
111 int c;
113 while ((c = getopt(argc, argv, "abcdeghprstuvyzF")) != -1) {
114 switch (c) {
115 case 'a': aflag++; break;
116 case 'b': bflag = 1; break;
117 case 'c': cflag = 1; break;
118 case 'd': dflag = 1; break;
119 case 'e': eflag = 1; break;
120 case 'F': Fflag = 1; break;
121 case 'g': gflag = 1; break;
122 case 'h': hflag = 1; break;
123 case 'p': pflag = 1; break;
124 case 'r': rflag = 1; break;
125 case 's': sflag = 1; break;
126 case 't': tflag = 1; break;
127 case 'u': uflag = 0; break;
128 case 'v': vflag = 0; break;
129 case 'y': yflag = 1; break;
130 case 'z': zflag = 0; break;
131 case '?': usage();
134 argc -= optind;
135 argv += optind;
137 if (argc != 2)
138 usage();
140 /* open the input file */
141 if ((yyin = fopen(argv[0], "r")) == NULL)
142 err(1, "cannot open '%s'", argv[0]);
144 /* initialize output */
145 outopen(argv[1]);
147 if (yflag)
148 yydebug = 1;
150 initmem();
151 initdecl();
152 initscan();
153 initmtab();
155 yyparse();
157 /* Following warnings cannot be suppressed by LINTED */
158 nowarn = 0;
160 chkglsyms();
162 outclose();
164 return (nerr != 0);
167 static void
168 usage(void)
170 (void)fprintf(stderr, "usage: lint1 [-abcdeghprstuvyzF] src dest\n");
171 exit(1);
174 void
175 norecover(void)
177 /* cannot recover from previous errors */
178 error(224);
179 exit(1);