summaryrefslogtreecommitdiffstats
path: root/usr.bin/head
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1996-02-26 22:46:36 +0000
committerwosch <wosch@FreeBSD.org>1996-02-26 22:46:36 +0000
commitfc85423c34d04a56754f43925e7a2a97265eb732 (patch)
tree14300a05815d26d86c78fdef98bc873993e3dfb3 /usr.bin/head
parent89b4ca893fe13e54c6d973cb8ba18e9fb0e54dc0 (diff)
downloadFreeBSD-src-fc85423c34d04a56754f43925e7a2a97265eb732.zip
FreeBSD-src-fc85423c34d04a56754f43925e7a2a97265eb732.tar.gz
first check the count and then get
the next line of characters and not cause it to first get the characters even if the count (cnt) has become 0. Submitted by: R Bezuidenhout <rbezuide@mikom.csir.co.za>
Diffstat (limited to 'usr.bin/head')
-rw-r--r--usr.bin/head/head.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c
index 3c4865b..9c13591 100644
--- a/usr.bin/head/head.c
+++ b/usr.bin/head/head.c
@@ -113,7 +113,7 @@ head(fp, cnt)
{
register int ch;
- while ((ch = getc(fp)) != EOF && cnt) {
+ while (cnt && (ch = getc(fp)) != EOF) {
if (putchar(ch) == EOF)
err(1, "stdout: %s", strerror(errno));
if (ch == '\n')
OpenPOWER on IntegriCloud