WARNS=2 fixes, use __FBSDID(), kill register keyword.

This commit is contained in:
Mark Murray 2001-12-11 23:20:23 +00:00
parent b6a5c4e0e4
commit 54750e1d8a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87698

View file

@ -34,19 +34,19 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifndef lint #ifndef lint
static const char copyright[] = static const char copyright[] =
"@(#) Copyright (c) 1985, 1993\n\ "@(#) Copyright (c) 1985, 1993\n\
The Regents of the University of California. All rights reserved.\n"; The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */ #endif
#ifndef lint #ifndef lint
#if 0 static const char sccsid[] = "@(#)unifdef.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)unifdef.c 8.1 (Berkeley) 6/6/93";
#endif #endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
/* /*
* unifdef - remove ifdef'ed lines * unifdef - remove ifdef'ed lines
@ -76,8 +76,9 @@ FILE *input;
#define NO 0 #define NO 0
#endif/*YES */ #endif/*YES */
typedef int Bool; typedef int Bool;
typedef int Linetype;
char *filename BSS; const char *filename BSS;
char text BSS; /* -t option in effect: this is a text file */ char text BSS; /* -t option in effect: this is a text file */
char lnblank BSS; /* -l option in effect: blank deleted lines */ char lnblank BSS; /* -l option in effect: blank deleted lines */
char complement BSS; /* -c option in effect: complement the operation */ char complement BSS; /* -c option in effect: complement the operation */
@ -100,8 +101,8 @@ char incomment BSS; /* inside C comment */
char inquote BSS; /* inside single or double quotes */ char inquote BSS; /* inside single or double quotes */
int exitstat BSS; int exitstat BSS;
char *skipcomment (); char *skipcomment __P((char *));
char *skipquote (); char *skipquote __P((char *, int));
static void usage __P((void)); static void usage __P((void));
void flushline __P((Bool)); void flushline __P((Bool));
int getlin __P((char *, int, FILE *, int)); int getlin __P((char *, int, FILE *, int));
@ -109,6 +110,7 @@ int error __P((int, int, int));
void pfile __P((void)); void pfile __P((void));
int doif __P((int, int, Reject_level, int)); int doif __P((int, int, Reject_level, int));
int findsym __P((char *)); int findsym __P((char *));
Linetype checkline __P((int *));
int int
main (argc, argv) main (argc, argv)
@ -116,8 +118,8 @@ int argc;
char **argv; char **argv;
{ {
char **curarg; char **curarg;
register char *cp; char *cp;
register char *cp1; char *cp1;
char ignorethis; char ignorethis;
for (curarg = &argv[1]; --argc > 0; curarg++) { for (curarg = &argv[1]; --argc > 0; curarg++) {
@ -133,7 +135,7 @@ char **argv;
) )
&& cp1[1] != '\0' && cp1[1] != '\0'
) { ) {
register int symind; int symind;
if ((symind = findsym (&cp1[1])) < 0) { if ((symind = findsym (&cp1[1])) < 0) {
if (nsyms >= MAXSYMS) if (nsyms >= MAXSYMS)
@ -190,7 +192,6 @@ usage()
} }
/* types of input lines: */ /* types of input lines: */
typedef int Linetype;
#define LT_PLAIN 0 /* ordinary line */ #define LT_PLAIN 0 /* ordinary line */
#define LT_TRUE 1 /* a true #ifdef of a symbol known to us */ #define LT_TRUE 1 /* a true #ifdef of a symbol known to us */
#define LT_FALSE 2 /* a false #ifdef of a symbol known to us */ #define LT_FALSE 2 /* a false #ifdef of a symbol known to us */
@ -199,7 +200,6 @@ typedef int Linetype;
#define LT_ELSE 5 /* #else */ #define LT_ELSE 5 /* #else */
#define LT_ENDIF 6 /* #endif */ #define LT_ENDIF 6 /* #endif */
#define LT_LEOF 7 /* end of file */ #define LT_LEOF 7 /* end of file */
extern Linetype checkline ();
Reject_level reject BSS; /* 0 or 1: pass thru; 1 or 2: ignore comments */ Reject_level reject BSS; /* 0 or 1: pass thru; 1 or 2: ignore comments */
#define REJ_NO 0 #define REJ_NO 0
@ -208,7 +208,7 @@ Reject_level reject BSS; /* 0 or 1: pass thru; 1 or 2: ignore comments */
int linenum BSS; /* current line number */ int linenum BSS; /* current line number */
int stqcline BSS; /* start of current coment or quote */ int stqcline BSS; /* start of current coment or quote */
char *errs[] = { const char *errs[] = {
#define NO_ERR 0 #define NO_ERR 0
"", "",
#define END_ERR 1 #define END_ERR 1
@ -241,13 +241,13 @@ pfile ()
int int
doif (thissym, inif, prevreject, depth) doif (thissym, inif, prevreject, depth)
register int thissym; /* index of the symbol who was last ifdef'ed */ int thissym; /* index of the symbol who was last ifdef'ed */
int inif; /* YES or NO we are inside an ifdef */ int inif; /* YES or NO we are inside an ifdef */
Reject_level prevreject;/* previous value of reject */ Reject_level prevreject;/* previous value of reject */
int depth; /* depth of ifdef's */ int depth; /* depth of ifdef's */
{ {
register Linetype lineval; Linetype lineval;
register Reject_level thisreject; Reject_level thisreject;
int doret; /* tmp return value of doif */ int doret; /* tmp return value of doif */
int cursym; /* index of the symbol returned by checkline */ int cursym; /* index of the symbol returned by checkline */
int stline; /* line number when called this time */ int stline; /* line number when called this time */
@ -321,8 +321,8 @@ int depth; /* depth of ifdef's */
return NO_ERR; return NO_ERR;
case LT_LEOF: { case LT_LEOF: {
int err; int lerr;
err = incomment lerr = incomment
? CEOF_ERR ? CEOF_ERR
: inquote == QUOTE_SINGLE : inquote == QUOTE_SINGLE
? Q1EOF_ERR ? Q1EOF_ERR
@ -330,11 +330,11 @@ int depth; /* depth of ifdef's */
? Q2EOF_ERR ? Q2EOF_ERR
: NO_ERR; : NO_ERR;
if (inif != IN_NONE) { if (inif != IN_NONE) {
if (err != NO_ERR) if (lerr != NO_ERR)
(void) error (err, stqcline, depth); (void) error (lerr, stqcline, depth);
return error (IEOF_ERR, stline, depth); return error (IEOF_ERR, stline, depth);
} else if (err != NO_ERR) } else if (lerr != NO_ERR)
return error (err, stqcline, depth); return error (lerr, stqcline, depth);
else else
return NO_ERR; return NO_ERR;
} }
@ -351,8 +351,8 @@ Linetype
checkline (cursym) checkline (cursym)
int *cursym; /* if LT_TRUE or LT_FALSE returned, set this to sym index */ int *cursym; /* if LT_TRUE or LT_FALSE returned, set this to sym index */
{ {
register char *cp; char *cp;
register char *symp; char *symp;
char *scp; char *scp;
Linetype retval; Linetype retval;
# define KWSIZE 8 # define KWSIZE 8
@ -433,7 +433,7 @@ int *cursym; /* if LT_TRUE or LT_FALSE returned, set this to sym index */
*/ */
char * char *
skipcomment (cp) skipcomment (cp)
register char *cp; char *cp;
{ {
if (incomment) if (incomment)
goto inside; goto inside;
@ -470,10 +470,10 @@ register char *cp;
*/ */
char * char *
skipquote (cp, type) skipquote (cp, type)
register char *cp; char *cp;
register int type; int type;
{ {
register char qchar; char qchar;
qchar = type == QUOTE_SINGLE ? '\'' : '"'; qchar = type == QUOTE_SINGLE ? '\'' : '"';
@ -507,10 +507,10 @@ int
findsym (str) findsym (str)
char *str; char *str;
{ {
register char *cp; char *cp;
register char *symp; char *symp;
register int symind; int symind;
register char chr; char chr;
for (symind = 0; symind < nsyms; ++symind) { for (symind = 0; symind < nsyms; ++symind) {
if (insym[symind] == SYM_INACTIVE) { if (insym[symind] == SYM_INACTIVE) {
@ -533,14 +533,14 @@ char *str;
*/ */
int int
getlin (line, maxline, inp, expandtabs) getlin (line, maxline, inp, expandtabs)
register char *line; char *line;
int maxline; int maxline;
FILE *inp; FILE *inp;
int expandtabs; int expandtabs;
{ {
int tmp; int tmp;
register int num; int num;
register int chr; int chr;
#ifdef FFSPECIAL #ifdef FFSPECIAL
static char havechar = NO; /* have leftover char from last time */ static char havechar = NO; /* have leftover char from last time */
static char svchar BSS; static char svchar BSS;
@ -608,9 +608,9 @@ flushline (keep)
Bool keep; Bool keep;
{ {
if ((keep && reject != REJ_YES) ^ complement) { if ((keep && reject != REJ_YES) ^ complement) {
register char *line = tline; char *line = tline;
register FILE *out = stdout; FILE *out = stdout;
register char chr; char chr;
while ((chr = *line++)) while ((chr = *line++))
putc (chr, out); putc (chr, out);
@ -619,19 +619,19 @@ Bool keep;
} }
int int
error (err, line, depth) error (lerr, line, depth)
int err; /* type of error & index into error string array */ int lerr; /* type of error & index into error string array */
int line; /* line number */ int line; /* line number */
int depth; /* how many ifdefs we are inside */ int depth; /* how many ifdefs we are inside */
{ {
if (err == END_ERR) if (lerr == END_ERR)
return err; return lerr;
#ifndef TESTING #ifndef TESTING
warnx("error in %s line %d: %s", filename, line, errs[err]); warnx("error in %s line %d: %s", filename, line, errs[lerr]);
#else/* TESTING */ #else/* TESTING */
warnx("error in %s line %d: %s. ifdef depth: %d", warnx("error in %s line %d: %s. ifdef depth: %d",
filename, line, errs[err], depth); filename, line, errs[lerr], depth);
#endif/*TESTING */ #endif/*TESTING */
exitstat = 2; exitstat = 2;