diff options
author | Jim Meyering <jim@meyering.net> | 2003-05-21 09:29:50 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-05-21 09:29:50 +0000 |
commit | dadd6992a2618eaacff505d56dc73c6215071fdd (patch) | |
tree | 12d055ac627e3edcb3e5d9e2db9d12748fdb71b9 /src/head.c | |
parent | 23dbc2747d4614f88e48e5dadf91d284fc41f95a (diff) | |
download | coreutils-dadd6992a2618eaacff505d56dc73c6215071fdd.tar.xz |
(elide_tail_lines_pipe): Fix a thinko.
This sort of thing is why it'd be *Really Good* to factor
out the common code used here and in tail.c.
Diffstat (limited to 'src/head.c')
-rw-r--r-- | src/head.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/head.c b/src/head.c index 1497a712a..7d58aefa9 100644 --- a/src/head.c +++ b/src/head.c @@ -555,8 +555,9 @@ elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide) goto free_lbuffers; } - /* Count the incomplete line on files that don't end with a newline. */ - if (last->buffer[last->nbytes - 1] != '\n') + /* If we read any bytes at all, count the incomplete line + on files that don't end with a newline. */ + if (last->nbytes && last->buffer[last->nbytes - 1] != '\n') { ++last->nlines; ++total_lines; |