head(1) ignored EOFs (in certain cases).
Closes PR # bin/678: head(1) ignore EOF Submitted by: wosch@cs.tu-berlin.de (Wolfram Schneider)
This commit is contained in:
parent
a722b904d7
commit
8e502f1158
@ -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--;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user