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
89b4ca893f
commit
fc85423c34
@ -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