Support NUL containing lines in head(1)

Very trivial this time.
This commit is contained in:
FRIGN
2016-03-07 10:48:17 +01:00
committed by sin
parent 886fca3fd6
commit 45b42516d4
2 changed files with 2 additions and 2 deletions

2
head.c
View File

@@ -14,7 +14,7 @@ head(FILE *fp, const char *fname, size_t n)
ssize_t len;
while (i < n && (len = getline(&buf, &size, fp)) > 0) {
fputs(buf, stdout);
fwrite(buf, 1, len, stdout);
i += (len && (buf[len - 1] == '\n'));
}
free(buf);