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