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>
This commit is contained in:
Wolfram Schneider 1996-02-26 22:46:36 +00:00
parent 1347f5b8e5
commit 298f429180

View File

@ -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')