diff options
author | joerg <joerg@FreeBSD.org> | 1995-08-15 19:34:11 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1995-08-15 19:34:11 +0000 |
commit | 71bcd71cfdc03a7a9dce2cae6ab4d8bc9f087090 (patch) | |
tree | 8c8815f3ef8d028770e6485888351389c6c66bbe /usr.bin/head/head.c | |
parent | 93d48be4a6907a0ccebf53f88e5753edf82ebe34 (diff) | |
download | FreeBSD-src-71bcd71cfdc03a7a9dce2cae6ab4d8bc9f087090.zip FreeBSD-src-71bcd71cfdc03a7a9dce2cae6ab4d8bc9f087090.tar.gz |
head(1) ignored EOFs (in certain cases).
Closes PR # bin/678: head(1) ignore EOF
Submitted by: wosch@cs.tu-berlin.de (Wolfram Schneider)
Diffstat (limited to 'usr.bin/head/head.c')
-rw-r--r-- | usr.bin/head/head.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c index e33a3c2..3c4865b 100644 --- a/usr.bin/head/head.c +++ b/usr.bin/head/head.c @@ -113,12 +113,11 @@ head(fp, cnt) { register int ch; - while (cnt--) - while ((ch = getc(fp)) != EOF) { + while ((ch = getc(fp)) != EOF && cnt) { if (putchar(ch) == EOF) err(1, "stdout: %s", strerror(errno)); if (ch == '\n') - break; + cnt--; } } |