WARNSify, fix .Nm usage, KNFify

This commit is contained in:
lukem 1997-10-20 02:23:13 +00:00
parent 9998247baa
commit 8d32174590
2 changed files with 482 additions and 472 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: unifdef.1,v 1.4 1994/12/07 00:33:48 jtc Exp $ .\" $NetBSD: unifdef.1,v 1.5 1997/10/20 02:23:13 lukem Exp $
.\" .\"
.\" Copyright (c) 1985, 1991, 1993 .\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -43,7 +43,7 @@
.Nm unifdef .Nm unifdef
.Nd remove ifdef'ed lines .Nd remove ifdef'ed lines
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm unifdef .Nm
.Op Fl clt .Op Fl clt
.Oo .Oo
.Fl D Ns Ar sym .Fl D Ns Ar sym
@ -54,10 +54,10 @@
.Ar ... .Ar ...
.Op Ar file .Op Ar file
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm Unifdef .Nm
is useful for removing ifdef'ed lines is useful for removing ifdef'ed lines
from a file while otherwise leaving the file alone. from a file while otherwise leaving the file alone.
.Nm Unifdef .Nm
acts on acts on
#ifdef, #ifndef, #else, and #endif lines, #ifdef, #ifndef, #else, and #endif lines,
and it knows only enough about C and it knows only enough about C
@ -97,7 +97,7 @@ If the
.Fl c .Fl c
flag is specified, flag is specified,
then the operation of then the operation of
.Nm unifdef .Nm
is complemented, is complemented,
i.e. the lines that would have been removed or blanked i.e. the lines that would have been removed or blanked
are retained and vice versa. are retained and vice versa.
@ -116,7 +116,7 @@ If your C code uses ifdefs to delimit non-C lines,
such as comments such as comments
or code which is under construction, or code which is under construction,
then you must tell then you must tell
.Nm unifdef .Nm
which symbols are used for that purpose so that it won't try to parse which symbols are used for that purpose so that it won't try to parse
for quotes and comments for quotes and comments
inside those ifdefs. inside those ifdefs.
@ -131,7 +131,7 @@ and
above. above.
.El .El
.Pp .Pp
.Nm Unifdef .Nm
copies its output to copies its output to
.Em stdout .Em stdout
and will take its input from and will take its input from
@ -140,7 +140,7 @@ if no
.Ar file .Ar file
argument is given. argument is given.
.Pp .Pp
.Nm Unifdef .Nm
works nicely with the works nicely with the
.Fl D Ns Ar sym .Fl D Ns Ar sym
option added to option added to

View File

@ -1,4 +1,4 @@
/* $NetBSD: unifdef.c,v 1.4 1994/12/20 01:44:07 jtc Exp $ */ /* $NetBSD: unifdef.c,v 1.5 1997/10/20 02:23:14 lukem Exp $ */
/* /*
* Copyright (c) 1985, 1993 * Copyright (c) 1985, 1993
@ -36,17 +36,17 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint #ifndef lint
static char copyright[] = __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 /* not lint */
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)unifdef.c 8.1 (Berkeley) 6/6/93"; static char sccsid[] = "@(#)unifdef.c 8.1 (Berkeley) 6/6/93";
#endif #endif
static char rcsid[] = "$NetBSD: unifdef.c,v 1.4 1994/12/20 01:44:07 jtc Exp $"; __RCSID("$NetBSD: unifdef.c,v 1.5 1997/10/20 02:23:14 lukem Exp $");
#endif /* not lint */ #endif /* not lint */
/* /*
@ -70,14 +70,15 @@ FILE *input;
#ifndef YES #ifndef YES
#define YES 1 #define YES 1
#define NO 0 #define NO 0
#endif/*YES */ #endif /* YES */
typedef int Bool; typedef int Bool;
char *progname BSS; char *progname BSS;
char *filename BSS; 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 */
#define MAXSYMS 100 #define MAXSYMS 100
char *symname[MAXSYMS] BSS; /* symbol name */ char *symname[MAXSYMS] BSS; /* symbol name */
@ -101,19 +102,20 @@ int error __P((int, int, int));
int findsym __P((char *)); int findsym __P((char *));
void flushline __P((Bool)); void flushline __P((Bool));
int getlin __P((char *, int, FILE *, int)); int getlin __P((char *, int, FILE *, int));
int main __P((int, char **));
void pfile __P((void)); void pfile __P((void));
void prname __P((void)); void prname __P((void));
char *skipcomment __P((char *)); char *skipcomment __P((char *));
char *skipquote __P((char *, int)); char *skipquote __P((char *, int));
int int
main (argc, argv) main(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
char **curarg; char **curarg;
register char *cp; char *cp;
register char *cp1; char *cp1;
char ignorethis; char ignorethis;
progname = argv[0][0] ? argv[0] : "unifdef"; progname = argv[0][0] ? argv[0] : "unifdef";
@ -126,18 +128,18 @@ char **argv;
cp1++; cp1++;
} else } else
ignorethis = NO; ignorethis = NO;
if ( ( *cp1 == 'D' if ((*cp1 == 'D'
|| *cp1 == 'U' || *cp1 == 'U'
) )
&& 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) {
prname (); prname();
fprintf (stderr, "too many symbols.\n"); fprintf(stderr, "too many symbols.\n");
exit (2); exit(2);
} }
symind = nsyms++; symind = nsyms++;
symname[symind] = &cp1[1]; symname[symind] = &cp1[1];
@ -145,40 +147,44 @@ char **argv;
} }
ignore[symind] = ignorethis; ignore[symind] = ignorethis;
true[symind] = *cp1 == 'D' ? YES : NO; true[symind] = *cp1 == 'D' ? YES : NO;
} else if (ignorethis) } else
if (ignorethis)
goto unrec; goto unrec;
else if (strcmp (&cp[1], "t") == 0) else
if (strcmp(&cp[1], "t") == 0)
text = YES; text = YES;
else if (strcmp (&cp[1], "l") == 0) else
if (strcmp(&cp[1], "l") == 0)
lnblank = YES; lnblank = YES;
else if (strcmp (&cp[1], "c") == 0) else
if (strcmp(&cp[1], "c") == 0)
complement = YES; complement = YES;
else { else {
unrec: unrec:
prname (); prname();
fprintf (stderr, "unrecognized option: %s\n", cp); fprintf(stderr, "unrecognized option: %s\n", cp);
goto usage; goto usage;
} }
} }
if (nsyms == 0) { if (nsyms == 0) {
usage: usage:
fprintf (stderr, "\ fprintf(stderr, "\
Usage: %s [-l] [-t] [-c] [[-Dsym] [-Usym] [-iDsym] [-iUsym]]... [file]\n\ Usage: %s [-l] [-t] [-c] [[-Dsym] [-Usym] [-iDsym] [-iUsym]]... [file]\n\
At least one arg from [-D -U -iD -iU] is required\n", progname); At least one arg from [-D -U -iD -iU] is required\n", progname);
exit (2); exit(2);
} }
if (argc > 1) { if (argc > 1) {
prname (); prname();
fprintf (stderr, "can only do one file.\n"); fprintf(stderr, "can only do one file.\n");
} else if (argc == 1) { } else
if (argc == 1) {
filename = *curarg; filename = *curarg;
if ((input = fopen (filename, "r")) != NULL) { if ((input = fopen(filename, "r")) != NULL) {
pfile(); pfile();
(void) fclose (input); (void) fclose(input);
} else { } else {
prname (); prname();
fprintf (stderr, "can't open "); fprintf(stderr, "can't open ");
perror(*curarg); perror(*curarg);
} }
} else { } else {
@ -187,10 +193,9 @@ Usage: %s [-l] [-t] [-c] [[-Dsym] [-Usym] [-iDsym] [-iUsym]]... [file]\n\
pfile(); pfile();
} }
(void) fflush (stdout); (void) fflush(stdout);
exit (exitstat); exit(exitstat);
} }
/* types of input lines: */ /* types of input lines: */
typedef int Linetype; typedef int Linetype;
#define LT_PLAIN 0 /* ordinary line */ #define LT_PLAIN 0 /* ordinary line */
@ -230,38 +235,37 @@ char *errs[] = {
#define Q2EOF_ERR 7 #define Q2EOF_ERR 7
"Premature EOF in quoted string" "Premature EOF in quoted string"
}; };
/* States for inif arg to doif */ /* States for inif arg to doif */
#define IN_NONE 0 #define IN_NONE 0
#define IN_IF 1 #define IN_IF 1
#define IN_ELSE 2 #define IN_ELSE 2
void void
pfile () pfile()
{ {
reject = REJ_NO; reject = REJ_NO;
(void) doif (-1, IN_NONE, reject, 0); (void) doif(-1, IN_NONE, reject, 0);
return; return;
} }
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 */
stline = linenum; stline = linenum;
for (;;) { for (;;) {
switch (lineval = checkline (&cursym)) { switch (lineval = checkline(&cursym)) {
case LT_PLAIN: case LT_PLAIN:
flushline (YES); flushline(YES);
break; break;
case LT_TRUE: case LT_TRUE:
@ -275,57 +279,58 @@ int depth; /* depth of ifdef's */
insym[cursym] = SYM_FALSE; insym[cursym] = SYM_FALSE;
} }
if (ignore[cursym]) if (ignore[cursym])
flushline (YES); flushline(YES);
else { else {
exitstat = 1; exitstat = 1;
flushline (NO); flushline(NO);
} }
if ((doret = doif (cursym, IN_IF, thisreject, depth + 1)) != NO_ERR) if ((doret = doif(cursym, IN_IF, thisreject, depth + 1)) != NO_ERR)
return error (doret, stline, depth); return error(doret, stline, depth);
break; break;
case LT_IF: case LT_IF:
case LT_OTHER: case LT_OTHER:
flushline (YES); flushline(YES);
if ((doret = doif (-1, IN_IF, reject, depth + 1)) != NO_ERR) if ((doret = doif(-1, IN_IF, reject, depth + 1)) != NO_ERR)
return error (doret, stline, depth); return error(doret, stline, depth);
break; break;
case LT_ELSE: case LT_ELSE:
if (inif != IN_IF) if (inif != IN_IF)
return error (ELSE_ERR, linenum, depth); return error(ELSE_ERR, linenum, depth);
inif = IN_ELSE; inif = IN_ELSE;
if (thissym >= 0) { if (thissym >= 0) {
if (insym[thissym] == SYM_TRUE) { if (insym[thissym] == SYM_TRUE) {
reject = ignore[thissym] ? REJ_IGNORE : REJ_YES; reject = ignore[thissym] ? REJ_IGNORE : REJ_YES;
insym[thissym] = SYM_FALSE; insym[thissym] = SYM_FALSE;
} else { /* (insym[thissym] == SYM_FALSE) */ } else { /* (insym[thissym] ==
* SYM_FALSE) */
reject = prevreject; reject = prevreject;
insym[thissym] = SYM_TRUE; insym[thissym] = SYM_TRUE;
} }
if (!ignore[thissym]) { if (!ignore[thissym]) {
flushline (NO); flushline(NO);
break; break;
} }
} }
flushline (YES); flushline(YES);
break; break;
case LT_ENDIF: case LT_ENDIF:
if (inif == IN_NONE) if (inif == IN_NONE)
return error (ENDIF_ERR, linenum, depth); return error(ENDIF_ERR, linenum, depth);
if (thissym >= 0) { if (thissym >= 0) {
insym[thissym] = SYM_INACTIVE; insym[thissym] = SYM_INACTIVE;
reject = prevreject; reject = prevreject;
if (!ignore[thissym]) { if (!ignore[thissym]) {
flushline (NO); flushline(NO);
return NO_ERR; return NO_ERR;
} }
} }
flushline (YES); flushline(YES);
return NO_ERR; return NO_ERR;
case LT_LEOF: { case LT_LEOF:{
int err; int err;
err = incomment err = incomment
? CEOF_ERR ? CEOF_ERR
@ -336,109 +341,117 @@ int depth; /* depth of ifdef's */
: NO_ERR; : NO_ERR;
if (inif != IN_NONE) { if (inif != IN_NONE) {
if (err != NO_ERR) if (err != NO_ERR)
(void) error (err, stqcline, depth); (void) error(err, stqcline, depth);
return error (IEOF_ERR, stline, depth); return error(IEOF_ERR, stline, depth);
} else if (err != NO_ERR) } else
return error (err, stqcline, depth); if (err != NO_ERR)
return error(err, stqcline, depth);
else else
return NO_ERR; return NO_ERR;
} }
} }
} }
} }
#define endsym(c) (!isalpha (c) && !isdigit (c) && c != '_') #define endsym(c) (!isalpha (c) && !isdigit (c) && c != '_')
#define MAXLINE 256 #define MAXLINE 256
char tline[MAXLINE] BSS; char tline[MAXLINE] BSS;
Linetype 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
char keyword[KWSIZE]; char keyword[KWSIZE];
linenum++; linenum++;
if (getlin (tline, sizeof tline, input, NO) == EOF) if (getlin(tline, sizeof tline, input, NO) == EOF)
return LT_LEOF; return LT_LEOF;
retval = LT_PLAIN; retval = LT_PLAIN;
if ( *(cp = tline) != '#' if (*(cp = tline) != '#'
|| incomment || incomment
|| inquote == QUOTE_SINGLE || inquote == QUOTE_SINGLE
|| inquote == QUOTE_DOUBLE || inquote == QUOTE_DOUBLE
) )
goto eol; goto eol;
cp = skipcomment (++cp); cp = skipcomment(++cp);
symp = keyword; symp = keyword;
while (!endsym (*cp)) { while (!endsym(*cp)) {
*symp = *cp++; *symp = *cp++;
if (++symp >= &keyword[KWSIZE]) if (++symp >= &keyword[KWSIZE])
goto eol; goto eol;
} }
*symp = '\0'; *symp = '\0';
if (strcmp (keyword, "ifdef") == 0) { if (strcmp(keyword, "ifdef") == 0) {
retval = YES; retval = YES;
goto ifdef; goto ifdef;
} else if (strcmp (keyword, "ifndef") == 0) { } else
if (strcmp(keyword, "ifndef") == 0) {
retval = NO; retval = NO;
ifdef: ifdef:
scp = cp = skipcomment (++cp); scp = cp = skipcomment(++cp);
if (incomment) { if (incomment) {
retval = LT_PLAIN; retval = LT_PLAIN;
goto eol; goto eol;
} } {
{
int symind; int symind;
if ((symind = findsym (scp)) >= 0) if ((symind = findsym(scp)) >= 0)
retval = (retval ^ true[*cursym = symind]) retval = (retval ^ true[*cursym = symind])
? LT_FALSE : LT_TRUE; ? LT_FALSE : LT_TRUE;
else else
retval = LT_OTHER; retval = LT_OTHER;
} }
} else if (strcmp (keyword, "if") == 0) } else
if (strcmp(keyword, "if") == 0)
retval = LT_IF; retval = LT_IF;
else if (strcmp (keyword, "else") == 0) else
if (strcmp(keyword, "else") == 0)
retval = LT_ELSE; retval = LT_ELSE;
else if (strcmp (keyword, "endif") == 0) else
if (strcmp(keyword, "endif") == 0)
retval = LT_ENDIF; retval = LT_ENDIF;
eol: eol:
if (!text && reject != REJ_IGNORE) if (!text && reject != REJ_IGNORE)
for (; *cp; ) { for (; *cp;) {
if (incomment) if (incomment)
cp = skipcomment (cp); cp = skipcomment(cp);
else if (inquote == QUOTE_SINGLE) else
cp = skipquote (cp, QUOTE_SINGLE); if (inquote == QUOTE_SINGLE)
else if (inquote == QUOTE_DOUBLE) cp = skipquote(cp, QUOTE_SINGLE);
cp = skipquote (cp, QUOTE_DOUBLE); else
else if (*cp == '/' && cp[1] == '*') if (inquote == QUOTE_DOUBLE)
cp = skipcomment (cp); cp = skipquote(cp, QUOTE_DOUBLE);
else if (*cp == '\'') else
cp = skipquote (cp, QUOTE_SINGLE); if (*cp == '/' && cp[1] == '*')
else if (*cp == '"') cp = skipcomment(cp);
cp = skipquote (cp, QUOTE_DOUBLE); else
if (*cp == '\'')
cp = skipquote(cp, QUOTE_SINGLE);
else
if (*cp == '"')
cp = skipquote(cp, QUOTE_DOUBLE);
else else
cp++; cp++;
} }
return retval; return retval;
} }
/* /*
* Skip over comments and stop at the next charaacter * Skip over comments and stop at the next charaacter
* position that is not whitespace. * position that is not whitespace.
*/ */
char * char *
skipcomment (cp) skipcomment(cp)
register char *cp; char *cp;
{ {
if (incomment) if (incomment)
goto inside; goto inside;
@ -447,7 +460,7 @@ register char *cp;
cp++; cp++;
if (text) if (text)
return cp; return cp;
if ( cp[0] != '/' if (cp[0] != '/'
|| cp[1] != '*' || cp[1] != '*'
) )
return cp; return cp;
@ -456,7 +469,7 @@ register char *cp;
incomment = YES; incomment = YES;
stqcline = linenum; stqcline = linenum;
} }
inside: inside:
for (;;) { for (;;) {
for (; *cp != '*'; cp++) for (; *cp != '*'; cp++)
if (*cp == '\0') if (*cp == '\0')
@ -468,17 +481,16 @@ register char *cp;
} }
} }
} }
/* /*
* Skip over a quoted string or character and stop at the next charaacter * Skip over a quoted string or character and stop at the next charaacter
* position that is not whitespace. * position that is not whitespace.
*/ */
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 ? '\'' : '"';
@ -490,66 +502,62 @@ register int type;
cp++; cp++;
inquote = type; inquote = type;
stqcline = linenum; stqcline = linenum;
inside: inside:
for (; ; cp++) { for (;; cp++) {
if (*cp == qchar) if (*cp == qchar)
break; break;
if ( *cp == '\0' if (*cp == '\0' || (*cp == '\\' && *++cp == '\0'))
|| *cp == '\\' && *++cp == '\0'
)
return cp; return cp;
} }
inquote = QUOTE_NONE; inquote = QUOTE_NONE;
} }
} }
/* /*
* findsym - look for the symbol in the symbol table. * findsym - look for the symbol in the symbol table.
* if found, return symbol table index, * if found, return symbol table index,
* else return -1. * else return -1.
*/ */
int 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) {
for ( symp = symname[symind], cp = str for (symp = symname[symind], cp = str
; *symp && *cp == *symp ; *symp && *cp == *symp
; cp++, symp++ ; cp++, symp++
) )
continue; continue;
chr = *cp; chr = *cp;
if (*symp == '\0' && endsym (chr)) if (*symp == '\0' && endsym(chr))
return symind; return symind;
} }
} }
return -1; return -1;
} }
/* /*
* getlin - expands tabs if asked for * getlin - expands tabs if asked for
* and (if compiled in) treats form-feed as an end-of-line * and (if compiled in) treats form-feed as an end-of-line
*/ */
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;
#endif/*FFSPECIAL */ #endif /* FFSPECIAL */
num = 0; num = 0;
#ifdef FFSPECIAL #ifdef FFSPECIAL
@ -558,13 +566,13 @@ int expandtabs;
chr = svchar; chr = svchar;
goto ent; goto ent;
} }
#endif/*FFSPECIAL */ #endif /* FFSPECIAL */
while (num + 8 < maxline) { /* leave room for tab */ while (num + 8 < maxline) { /* leave room for tab */
chr = getc (inp); chr = getc(inp);
if (isprint (chr)) { if (isprint(chr)) {
#ifdef FFSPECIAL #ifdef FFSPECIAL
ent: ent:
#endif/*FFSPECIAL */ #endif /* FFSPECIAL */
*line++ = chr; *line++ = chr;
num++; num++;
} else } else
@ -600,54 +608,56 @@ int expandtabs;
svchar = chr; svchar = chr;
} }
goto end; goto end;
#endif/*FFSPECIAL */ #endif /* FFSPECIAL */
} }
} }
end: end:
*++line = '\0'; *++line = '\0';
return num; return num;
} }
void void
flushline (keep) 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++) != 0)
putc (chr, out); putc(chr, out);
} else if (lnblank) } else
putc ('\n', stdout); if (lnblank)
putc('\n', stdout);
return; return;
} }
void void
prname () prname()
{ {
fprintf (stderr, "%s: ", progname); fprintf(stderr, "%s: ", progname);
return; return;
} }
int int
error (err, line, depth) error(err, line, depth)
int err; /* type of error & index into error string array */ int err; /* type of error & index into error string
int line; /* line number */ * array */
int depth; /* how many ifdefs we are inside */ int line; /* line number */
int depth; /* how many ifdefs we are inside */
{ {
if (err == END_ERR) if (err == END_ERR)
return err; return err;
prname (); prname();
#ifndef TESTING #ifndef TESTING
fprintf (stderr, "Error in %s line %d: %s.\n", filename, line, errs[err]); fprintf(stderr, "Error in %s line %d: %s.\n", filename, line, errs[err]);
#else/* TESTING */ #else /* TESTING */
fprintf (stderr, "Error in %s line %d: %s. ", filename, line, errs[err]); fprintf(stderr, "Error in %s line %d: %s. ", filename, line, errs[err]);
fprintf (stderr, "ifdef depth: %d\n", depth); fprintf(stderr, "ifdef depth: %d\n", depth);
#endif/*TESTING */ #endif /* TESTING */
exitstat = 2; exitstat = 2;
return depth > 1 ? IEOF_ERR : END_ERR; return depth > 1 ? IEOF_ERR : END_ERR;