diff options
author | fanf <fanf@FreeBSD.org> | 2008-02-29 13:19:50 +0000 |
---|---|---|
committer | fanf <fanf@FreeBSD.org> | 2008-02-29 13:19:50 +0000 |
commit | 7b6c8b6229d873574d15aa67708a6ed14b75aa9c (patch) | |
tree | b3058d3a569ec7ab769ecf2f4979bc5b9a36642a | |
parent | 7a1729a27e57a043694c738c97e892e32341eb06 (diff) | |
download | FreeBSD-src-7b6c8b6229d873574d15aa67708a6ed14b75aa9c.zip FreeBSD-src-7b6c8b6229d873574d15aa67708a6ed14b75aa9c.tar.gz |
A fix for other ways of triggering joe@'s bug.
-rw-r--r-- | usr.bin/unifdef/unifdef.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c index 32bed03..fce2dfe 100644 --- a/usr.bin/unifdef/unifdef.c +++ b/usr.bin/unifdef/unifdef.c @@ -42,7 +42,7 @@ static const char copyright[] = #ifdef __IDSTRING __IDSTRING(Berkeley, "@(#)unifdef.c 8.1 (Berkeley) 6/6/93"); __IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.8 2000/07/03 02:51:36 matt Exp $"); -__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.176 2008/02/29 12:44:25 fanf2 Exp $"); +__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.177 2008/02/29 13:17:37 fanf2 Exp $"); #endif #endif /* not lint */ #ifdef __FBSDID @@ -587,16 +587,19 @@ getline(void) linestate = LS_DIRTY; } /* skipcomment normally changes the state, except - if the last line of the file lacks a newline */ + if the last line of the file lacks a newline, or + if there is too much whitespace in a directive */ if (linestate == LS_HASH) { size_t len = cp - tline; - if (fgets(tline + len, MAXLINE - len, input) != NULL) - abort(); /* bug */ - /* append the missing newline */ - tline[len+0] = '\n'; - tline[len+1] = '\0'; - cp++; - linestate = LS_START; + if (fgets(tline + len, MAXLINE - len, input) == NULL) { + /* append the missing newline */ + tline[len+0] = '\n'; + tline[len+1] = '\0'; + cp++; + linestate = LS_START; + } else { + linestate = LS_DIRTY; + } } } if (linestate == LS_DIRTY) { |