xref: /netbsd/usr.bin/xlint/lint1/err.c (revision bf9ec67e)
1 /*	$NetBSD: err.c,v 1.18 2002/03/07 20:17:37 tv Exp $	*/
2 
3 /*
4  * Copyright (c) 1994, 1995 Jochen Pohl
5  * All Rights Reserved.
6  *
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.
21  *
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.
32  */
33 
34 #include <sys/cdefs.h>
35 #if defined(__RCSID) && !defined(lint)
36 __RCSID("$NetBSD: err.c,v 1.18 2002/03/07 20:17:37 tv Exp $");
37 #endif
38 
39 #include <sys/types.h>
40 #include <stdlib.h>
41 #include <stdarg.h>
42 
43 #include "lint1.h"
44 
45 /* number of errors found */
46 int	nerr;
47 
48 /* number of syntax errors */
49 int	sytxerr;
50 
51 
52 static	const	char *lbasename(const char *);
53 static	void	verror(int, va_list);
54 static	void	vwarning(int, va_list);
55 
56 
57 const	char *msgs[] = {
58 	"syntax error: empty declaration",			      /* 0 */
59 	"old style declaration; add int",			      /* 1 */
60 	"empty declaration",					      /* 2 */
61 	"%s declared in argument declaration list",		      /* 3 */
62 	"illegal type combination",				      /* 4 */
63 	"modifying typedef with '%s'; only qualifiers allowed",	      /* 5 */
64 	"use 'double' instead of 'long float'",			      /* 6 */
65 	"only one storage class allowed",			      /* 7 */
66 	"illegal storage class",				      /* 8 */
67 	"only register valid as formal parameter storage class",      /* 9 */
68 	"duplicate '%s'",					      /* 10 */
69 	"bit-field initializer out of range",			      /* 11 */
70 	"compiler takes size of function",			      /* 12 */
71 	"incomplete enum type: %s",				      /* 13 */
72 	"compiler takes alignment of function",			      /* 14 */
73 	"function returns illegal type",			      /* 15 */
74 	"array of function is illegal",				      /* 16 */
75 	"null dimension",					      /* 17 */
76 	"illegal use of 'void'",				      /* 18 */
77 	"void type for %s",					      /* 19 */
78 	"zero or negative array dimension",			      /* 20 */
79 	"redeclaration of formal parameter %s",			      /* 21 */
80 	"incomplete or misplaced function definition",		      /* 22 */
81 	"undefined label %s",					      /* 23 */
82 	"cannot initialize function: %s",			      /* 24 */
83 	"cannot initialize typedef: %s",			      /* 25 */
84 	"cannot initialize extern declaration: %s",		      /* 26 */
85 	"redeclaration of %s",					      /* 27 */
86 	"redefinition of %s",					      /* 28 */
87 	"previously declared extern, becomes static: %s",	      /* 29 */
88 	"redeclaration of %s; ANSI C requires static",		      /* 30 */
89 	"incomplete structure or union %s: %s",			      /* 31 */
90 	"argument type defaults to 'int': %s",			      /* 32 */
91 	"duplicate member name: %s",				      /* 33 */
92 	"nonportable bit-field type",				      /* 34 */
93 	"illegal bit-field type",				      /* 35 */
94 	"illegal bit-field size",				      /* 36 */
95 	"zero size bit-field",					      /* 37 */
96 	"function illegal in structure or union",		      /* 38 */
97 	"illegal zero sized structure member: %s",		      /* 39 */
98 	"unknown size: %s",					      /* 40 */
99 	"illegal use of bit-field",				      /* 41 */
100 	"forward reference to enum type",			      /* 42 */
101 	"redefinition hides earlier one: %s",			      /* 43 */
102 	"declaration introduces new type in ANSI C: %s %s",	      /* 44 */
103 	"base type is really '%s %s'",				      /* 45 */
104 	"(%s) tag redeclared",					      /* 46 */
105 	"zero sized %s",					      /* 47 */
106 	"overflow in enumeration values: %s",			      /* 48 */
107 	"struct or union member must be named",			      /* 49 */
108 	"a function is declared as an argument: %s",		      /* 50 */
109 	"parameter mismatch: %d declared, %d defined",		      /* 51 */
110 	"cannot initialize parameter: %s",			      /* 52 */
111 	"declared argument %s is missing",			      /* 53 */
112 	"trailing ',' prohibited in enum declaration",		      /* 54 */
113 	"integral constant expression expected",		      /* 55 */
114 	"integral constant too large",				      /* 56 */
115 	"enumeration constant hides parameter: %s",		      /* 57 */
116 	"type does not match prototype: %s",			      /* 58 */
117 	"formal parameter lacks name: param #%d",		      /* 59 */
118 	"void must be sole parameter",				      /* 60 */
119 	"void parameter cannot have name: %s",			      /* 61 */
120 	"function prototype parameters must have types",	      /* 62 */
121 	"prototype does not match old-style definition",	      /* 63 */
122 	"()-less function definition",				      /* 64 */
123 	"%s has no named members",				      /* 65 */
124 	"syntax requires ';' after last struct/union member",	      /* 66 */
125 	"cannot return incomplete type",			      /* 67 */
126 	"typedef already qualified with '%s'",			      /* 68 */
127 	"inappropriate qualifiers with 'void'",			      /* 69 */
128 	"%soperand of '%s' is unsigned in ANSI C",		      /* 70 */
129 	"too many characters in character constant",		      /* 71 */
130 	"typedef declares no type name",			      /* 72 */
131 	"empty character constant",				      /* 73 */
132 	"no hex digits follow \\x",				      /* 74 */
133 	"overflow in hex escape",				      /* 75 */
134 	"character escape does not fit in character",		      /* 76 */
135 	"bad octal digit %c",					      /* 77 */
136 	"nonportable character escape",				      /* 78 */
137 	"dubious escape \\%c",					      /* 79 */
138 	"dubious escape \\%o",					      /* 80 */
139 	"\\a undefined in traditional C",			      /* 81 */
140 	"\\x undefined in traditional C",			      /* 82 */
141 	"storage class after type is obsolescent",		      /* 83 */
142 	"ANSI C requires formal parameter before '...'",	      /* 84 */
143 	"dubious tag declaration: %s %s",			      /* 85 */
144 	"automatic hides external declaration: %s",		      /* 86 */
145 	"static hides external declaration: %s",		      /* 87 */
146 	"typedef hides external declaration: %s",		      /* 88 */
147 	"typedef redeclared: %s",				      /* 89 */
148 	"inconsistent redeclaration of extern: %s",		      /* 90 */
149 	"declaration hides parameter: %s",			      /* 91 */
150 	"inconsistent redeclaration of static: %s",		      /* 92 */
151 	"dubious static function at block level: %s",		      /* 93 */
152 	"function has illegal storage class: %s",		      /* 94 */
153 	"declaration hides earlier one: %s",			      /* 95 */
154 	"cannot dereference non-pointer type",			      /* 96 */
155 	"suffix U is illegal in traditional C",			      /* 97 */
156 	"suffixes F and L are illegal in traditional C",	      /* 98 */
157 	"%s undefined",						      /* 99 */
158 	"unary + is illegal in traditional C",			      /* 100 */
159 	"undefined struct/union member: %s",			      /* 101 */
160 	"illegal member use: %s",				      /* 102 */
161 	"left operand of '.' must be struct/union object",	      /* 103 */
162 	"left operand of '->' must be pointer to struct/union",	      /* 104 */
163 	"non-unique member requires struct/union %s",		      /* 105 */
164 	"left operand of '->' must be pointer",			      /* 106 */
165 	"operands of '%s' have incompatible types",		      /* 107 */
166 	"operand of '%s' has incompatible type",		      /* 108 */
167 	"void type illegal in expression",			      /* 109 */
168 	"pointer to function is not allowed here",		      /* 110 */
169 	"unacceptable operand of '%s'",				      /* 111 */
170 	"cannot take address of bit-field",			      /* 112 */
171 	"cannot take address of register %s",			      /* 113 */
172 	"%soperand of '%s' must be lvalue",			      /* 114 */
173 	"%soperand of '%s' must be modifiable lvalue",		      /* 115 */
174 	"illegal pointer subtraction",				      /* 116 */
175 	"bitwise operation on signed value possibly nonportable",     /* 117 */
176 	"semantics of '%s' change in ANSI C; use explicit cast",      /* 118 */
177 	"conversion of '%s' to '%s' is out of range",		      /* 119 */
178 	"bitwise operation on signed value nonportable",	      /* 120 */
179 	"negative shift",					      /* 121 */
180 	"shift greater than size of object",			      /* 122 */
181 	"illegal combination of pointer and integer, op %s",	      /* 123 */
182 	"illegal pointer combination, op %s",			      /* 124 */
183 	"ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
184 	"incompatible types in conditional",			      /* 126 */
185 	"'&' before array or function: ignored",		      /* 127 */
186 	"operands have incompatible pointer types, op %s",	      /* 128 */
187 	"expression has null effect",				      /* 129 */
188 	"enum type mismatch, op %s",				      /* 130 */
189 	"conversion to '%s' may sign-extend incorrectly",	      /* 131 */
190 	"conversion from '%s' may lose accuracy",		      /* 132 */
191 	"conversion of pointer to '%s' loses bits",		      /* 133 */
192 	"conversion of pointer to '%s' may lose bits",		      /* 134 */
193 	"possible pointer alignment problem",			      /* 135 */
194 	"cannot do pointer arithmetic on operand of unknown size",    /* 136 */
195 	"use of incomplete enum type, op %s",			      /* 137 */
196 	"unknown operand size, op %s",				      /* 138 */
197 	"division by 0",					      /* 139 */
198 	"modulus by 0",						      /* 140 */
199 	"integer overflow detected, op %s",			      /* 141 */
200 	"floating point overflow detected, op %s",		      /* 142 */
201 	"cannot take size of incomplete type",			      /* 143 */
202 	"cannot take size of function",				      /* 144 */
203 	"cannot take size of bit-field",			      /* 145 */
204 	"cannot take size of void",				      /* 146 */
205 	"invalid cast expression",				      /* 147 */
206 	"improper cast of void expression",			      /* 148 */
207 	"illegal function",					      /* 149 */
208 	"argument mismatch: %d arg%s passed, %d expected",	      /* 150 */
209 	"void expressions may not be arguments, arg #%d",	      /* 151 */
210 	"argument cannot have unknown size, arg #%d",		      /* 152 */
211 	"argument has incompatible pointer type, arg #%d",	      /* 153 */
212 	"illegal combination of pointer and integer, arg #%d",	      /* 154 */
213 	"argument is incompatible with prototype, arg #%d",	      /* 155 */
214 	"enum type mismatch, arg #%d",			       	      /* 156 */
215 	"ANSI C treats constant as unsigned",			      /* 157 */
216 	"%s may be used before set",			      	      /* 158 */
217 	"assignment in conditional context",			      /* 159 */
218 	"operator '==' found where '=' was expected",		      /* 160 */
219 	"constant in conditional context",			      /* 161 */
220 	"comparison of %s with %s, op %s",			      /* 162 */
221 	"a cast does not yield an lvalue",			      /* 163 */
222 	"assignment of negative constant to unsigned type",	      /* 164 */
223 	"constant truncated by assignment",			      /* 165 */
224 	"precision lost in bit-field assignment",		      /* 166 */
225 	"array subscript cannot be negative: %ld",		      /* 167 */
226 	"array subscript cannot be > %d: %ld",			      /* 168 */
227 	"precedence confusion possible: parenthesize!",		      /* 169 */
228 	"first operand must have scalar type, op ? :",		      /* 170 */
229 	"assignment type mismatch",				      /* 171 */
230 	"too many struct/union initializers",			      /* 172 */
231 	"too many array initializers",				      /* 173 */
232 	"too many initializers",				      /* 174 */
233 	"initialisation of an incomplete type",			      /* 175 */
234 	"invalid initializer",					      /* 176 */
235 	"non-constant initializer",				      /* 177 */
236 	"initializer does not fit",				      /* 178 */
237 	"cannot initialize struct/union with no named member",	      /* 179 */
238 	"bit-field initializer does not fit",			      /* 180 */
239 	"{}-enclosed initializer required",			      /* 181 */
240 	"incompatible pointer types",				      /* 182 */
241 	"illegal combination of pointer and integer",		      /* 183 */
242 	"illegal pointer combination",				      /* 184 */
243 	"initialisation type mismatch",				      /* 185 */
244 	"bit-field initialisation is illegal in traditional C",	      /* 186 */
245 	"non-null byte ignored in string initializer",		      /* 187 */
246 	"no automatic aggregate initialization in traditional C",     /* 188 */
247 	"assignment of struct/union illegal in traditional C",	      /* 189 */
248 	"empty array declaration: %s",				      /* 190 */
249 	"%s set but not used in function %s",		      	      /* 191 */
250 	"%s unused in function %s",				      /* 192 */
251 	"statement not reached",				      /* 193 */
252 	"label %s redefined",					      /* 194 */
253 	"case not in switch",					      /* 195 */
254 	"case label affected by conversion",			      /* 196 */
255 	"non-constant case expression",				      /* 197 */
256 	"non-integral case expression",				      /* 198 */
257 	"duplicate case in switch: %ld",			      /* 199 */
258 	"duplicate case in switch: %lu",			      /* 200 */
259 	"default outside switch",				      /* 201 */
260 	"duplicate default in switch",				      /* 202 */
261 	"case label must be of type `int' in traditional C",	      /* 203 */
262 	"controlling expressions must have scalar type",	      /* 204 */
263 	"switch expression must have integral type",		      /* 205 */
264 	"enumeration value(s) not handled in switch",		      /* 206 */
265 	"loop not entered at top",				      /* 207 */
266 	"break outside loop or switch",				      /* 208 */
267 	"continue outside loop",				      /* 209 */
268 	"enum type mismatch in initialisation",			      /* 210 */
269 	"return value type mismatch",				      /* 211 */
270 	"cannot return incomplete type",			      /* 212 */
271 	"void function %s cannot return value",			      /* 213 */
272 	"function %s expects to return value",			      /* 214 */
273 	"function implicitly declared to return int",		      /* 215 */
274 	"function %s has return (e); and return;",		      /* 216 */
275 	"function %s falls off bottom without returning value",	      /* 217 */
276 	"ANSI C treats constant as unsigned, op %s",		      /* 218 */
277 	"concatenated strings are illegal in traditional C",	      /* 219 */
278 	"fallthrough on case statement",			      /* 220 */
279 	"initialisation of unsigned with negative constant",	      /* 221 */
280 	"conversion of negative constant to unsigned type",	      /* 222 */
281 	"end-of-loop code not reached",				      /* 223 */
282 	"cannot recover from previous errors",			      /* 224 */
283 	"static function called but not defined: %s()",		      /* 225 */
284 	"static variable %s unused",				      /* 226 */
285 	"const object %s should have initializer",		      /* 227 */
286 	"function cannot return const or volatile object",	      /* 228 */
287 	"questionable conversion of function pointer",		      /* 229 */
288 	"nonportable character comparison, op %s",		      /* 230 */
289 	"argument %s unused in function %s",			      /* 231 */
290 	"label %s unused in function %s",			      /* 232 */
291 	"struct %s never defined",				      /* 233 */
292 	"union %s never defined",				      /* 234 */
293 	"enum %s never defined",				      /* 235 */
294 	"static function %s unused",				      /* 236 */
295 	"redeclaration of formal parameter %s",			      /* 237 */
296 	"initialisation of union is illegal in traditional C",	      /* 238 */
297 	"constant argument to NOT",				      /* 239 */
298 	"assignment of different structures",			      /* 240 */
299 	"dubious operation on enum, op %s",			      /* 241 */
300 	"combination of '%s' and '%s', op %s",			      /* 242 */
301 	"dubious comparison of enums, op %s",			      /* 243 */
302 	"illegal structure pointer combination",		      /* 244 */
303 	"illegal structure pointer combination, op %s",		      /* 245 */
304 	"dubious conversion of enum to '%s'",			      /* 246 */
305 	"pointer casts may be troublesome",			      /* 247 */
306 	"floating-point constant out of range",			      /* 248 */
307 	"syntax error",						      /* 249 */
308 	"unknown character \\%o",				      /* 250 */
309 	"malformed integer constant",				      /* 251 */
310 	"integer constant out of range",			      /* 252 */
311 	"unterminated character constant",			      /* 253 */
312 	"newline in string or char constant",			      /* 254 */
313 	"undefined or invalid # directive",			      /* 255 */
314 	"unterminated comment",					      /* 256 */
315 	"extra characters in lint comment",			      /* 257 */
316 	"unterminated string constant",				      /* 258 */
317 	"conversion to '%s' due to prototype, arg #%d",		      /* 259 */
318 	"previous declaration of %s",				      /* 260 */
319 	"previous definition of %s",				      /* 261 */
320 	"\\\" inside character constants undefined in traditional C", /* 262 */
321 	"\\? undefined in traditional C",			      /* 263 */
322 	"\\v undefined in traditional C",			      /* 264 */
323 	"%s C does not support 'long long'",			      /* 265 */
324 	"'long double' is illegal in traditional C",		      /* 266 */
325 	"shift equal to size of object",			      /* 267 */
326 	"variable declared inline: %s",				      /* 268 */
327 	"argument declared inline: %s",				      /* 269 */
328 	"function prototypes are illegal in traditional C",	      /* 270 */
329 	"switch expression must be of type `int' in traditional C",   /* 271 */
330 	"empty translation unit",				      /* 272 */
331 	"bit-field type '%s' invalid in ANSI C",		      /* 273 */
332 	"ANSI C forbids comparison of %s with %s",		      /* 274 */
333 	"cast discards 'const' from pointer target type",	      /* 275 */
334 	"",							      /* 276 */
335 	"initialisation of '%s' with '%s'",			      /* 277 */
336 	"combination of '%s' and '%s', arg #%d",		      /* 278 */
337 	"combination of '%s' and '%s' in return",		      /* 279 */
338 	"must be outside function: /* %s */",			      /* 280 */
339 	"duplicate use of /* %s */",				      /* 281 */
340 	"must precede function definition: /* %s */",		      /* 282 */
341 	"argument number mismatch with directive: /* %s */",	      /* 283 */
342 	"fallthrough on default statement",			      /* 284 */
343 	"prototype declaration",				      /* 285 */
344 	"function definition is not a prototype",		      /* 286 */
345 	"function declaration is not a prototype",		      /* 287 */
346 	"dubious use of /* VARARGS */ with /* %s */",		      /* 288 */
347 	"can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */",   /* 289 */
348 	"static function %s declared but not defined",		      /* 290 */
349 	"invalid multibyte character",				      /* 291 */
350 	"cannot concatenate wide and regular string literals",	      /* 292 */
351 	"argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE",      /* 293 */
352 	"multi-character character constant",			      /* 294 */
353 	"conversion of '%s' to '%s' is out of range, arg #%d",	      /* 295 */
354 	"conversion of negative constant to unsigned type, arg #%d",  /* 296 */
355 	"conversion to '%s' may sign-extend incorrectly, arg #%d",    /* 297 */
356 	"conversion from '%s' may lose accuracy, arg #%d",	      /* 298 */
357 	"prototype does not match old style definition, arg #%d",     /* 299 */
358 	"old style definition",					      /* 300 */
359 	"array of incomplete type",				      /* 301 */
360 	"%s returns pointer to automatic object",		      /* 302 */
361 	"ANSI C forbids conversion of %s to %s",		      /* 303 */
362 	"ANSI C forbids conversion of %s to %s, arg #%d",	      /* 304 */
363 	"ANSI C forbids conversion of %s to %s, op %s",		      /* 305 */
364 	"constant truncated by conversion, op %s",		      /* 306 */
365 	"static variable %s set but not used",			      /* 307 */
366 	"",							      /* 308 */
367 	"extra bits set to 0 in conversion of '%s' to '%s', op %s",   /* 309 */
368 	"symbol renaming can't be used on function arguments",	      /* 310 */
369 	"symbol renaming can't be used on automatic variables",	      /* 311 */
370 	"%s C does not support // comments",			      /* 312 */
371 };
372 
373 /*
374  * print a list of the messages with their ids
375  */
376 void
377 msglist(void)
378 {
379 	int i;
380 
381 	for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
382 		printf("%d\t%s\n", i, msgs[i]);
383 }
384 
385 /*
386  * If Fflag is not set lbasename() returns a pointer to the last
387  * component of the path, otherwise it returns the argument.
388  */
389 static const char *
390 lbasename(const char *path)
391 {
392 	const	char *cp, *cp1, *cp2;
393 
394 	if (Fflag)
395 		return (path);
396 
397 	cp = cp1 = cp2 = path;
398 	while (*cp != '\0') {
399 		if (*cp++ == '/') {
400 			cp2 = cp1;
401 			cp1 = cp;
402 		}
403 	}
404 	return (*cp1 == '\0' ? cp2 : cp1);
405 }
406 
407 static void
408 verror( int n, va_list ap)
409 {
410 	const	char *fn;
411 
412 	if (ERR_ISSET(n, &msgset))
413 		return;
414 
415 	fn = lbasename(curr_pos.p_file);
416 	(void)printf("%s(%d): ", fn, curr_pos.p_line);
417 	(void)vprintf(msgs[n], ap);
418 	(void)printf(" [%d]\n", n);
419 	nerr++;
420 }
421 
422 static void
423 vwarning( int n, va_list ap)
424 {
425 	const	char *fn;
426 
427 	if (ERR_ISSET(n, &msgset))
428 		return;
429 
430 	if (nowarn)
431 		/* this warning is suppressed by a LINTED comment */
432 		return;
433 
434 	fn = lbasename(curr_pos.p_file);
435 	(void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
436 	(void)vprintf(msgs[n], ap);
437 	(void)printf(" [%d]\n", n);
438 	if (wflag)
439 		nerr++;
440 }
441 
442 void
443 error(int n, ...)
444 {
445 	va_list	ap;
446 
447 	va_start(ap, n);
448 	verror(n, ap);
449 	va_end(ap);
450 }
451 
452 void
453 lerror(const char *msg, ...)
454 {
455 	va_list	ap;
456 	const	char *fn;
457 
458 	va_start(ap, msg);
459 	fn = lbasename(curr_pos.p_file);
460 	(void)fprintf(stderr, "%s(%d): lint error: ", fn, curr_pos.p_line);
461 	(void)vfprintf(stderr, msg, ap);
462 	(void)fprintf(stderr, "\n");
463 	va_end(ap);
464 	exit(1);
465 }
466 
467 void
468 warning(int n, ...)
469 {
470 	va_list	ap;
471 
472 	va_start(ap, n);
473 	vwarning(n, ap);
474 	va_end(ap);
475 }
476 
477 void
478 message(int n, ...)
479 {
480 	va_list	ap;
481 	const	char *fn;
482 
483 	if (ERR_ISSET(n, &msgset))
484 		return;
485 
486 	va_start(ap, n);
487 	fn = lbasename(curr_pos.p_file);
488 	(void)printf("%s(%d): ", fn, curr_pos.p_line);
489 	(void)vprintf(msgs[n], ap);
490 	(void)printf(" [%d]\n", n);
491 	va_end(ap);
492 }
493 
494 int
495 gnuism(int n, ...)
496 {
497 	va_list	ap;
498 	int	msg;
499 
500 	va_start(ap, n);
501 	if (sflag && !gflag) {
502 		verror(n, ap);
503 		msg = 1;
504 	} else if (!sflag && gflag) {
505 		msg = 0;
506 	} else {
507 		vwarning(n, ap);
508 		msg = 1;
509 	}
510 	va_end(ap);
511 
512 	return (msg);
513 }
514