summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorfanf <fanf@FreeBSD.org>2008-02-29 13:19:50 +0000
committerfanf <fanf@FreeBSD.org>2008-02-29 13:19:50 +0000
commit7b6c8b6229d873574d15aa67708a6ed14b75aa9c (patch)
treeb3058d3a569ec7ab769ecf2f4979bc5b9a36642a /usr.bin
parent7a1729a27e57a043694c738c97e892e32341eb06 (diff)
downloadFreeBSD-src-7b6c8b6229d873574d15aa67708a6ed14b75aa9c.zip
FreeBSD-src-7b6c8b6229d873574d15aa67708a6ed14b75aa9c.tar.gz
A fix for other ways of triggering joe@'s bug.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/unifdef/unifdef.c21
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) {
OpenPOWER on IntegriCloud