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:
parent
5b8d532ec0
commit
efb6bed393
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user