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
1347f5b8e5
commit
298f429180
@ -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…
x
Reference in New Issue
Block a user