aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/head
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>1995-08-15 19:34:11 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>1995-08-15 19:34:11 +0000
commit8e502f1158e4c49410f1ee249cecc258a4bd73ae (patch)
tree8c8815f3ef8d028770e6485888351389c6c66bbe /usr.bin/head
parenta722b904d7291701b49c992d12d445486dfb5dd5 (diff)
Notes
Diffstat (limited to 'usr.bin/head')
-rw-r--r--usr.bin/head/head.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c
index e33a3c26a459..3c4865b79076 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--;
}
}