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:
wosch 1996-02-26 22:46:36 +00:00
parent 89b4ca893f
commit fc85423c34

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