diff options
author | Jim Meyering <jim@meyering.net> | 2003-05-13 10:21:13 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-05-13 10:21:13 +0000 |
commit | 5352c4a62b929dfa86651b3db4eb511edb4b3052 (patch) | |
tree | d1f50207d3d013a3d1d02e9a970b86ae856941d6 | |
parent | 320da0f8a813c6cf9eb7becaa24bf0b92dbc5617 (diff) | |
download | coreutils-5352c4a62b929dfa86651b3db4eb511edb4b3052.tar.xz |
(elide_tail_lines_pipe): Use `if', not an assert.
Now that assert is no longer used, don't include <assert.h>.
-rw-r--r-- | src/head.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/head.c b/src/head.c index 83e03781b..ad718aa1e 100644 --- a/src/head.c +++ b/src/head.c @@ -28,7 +28,6 @@ #include <stdio.h> #include <getopt.h> -#include <assert.h> #include <sys/types.h> #include "system.h" @@ -221,7 +220,8 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0) /* If we're eliding no more than this many bytes, then it's ok to allocate more memory in order to use a more time-efficient algorithm. - FIXME: use a fraction of available memory instead, as in sort. */ + FIXME: use a fraction of available memory instead, as in sort. + FIXME: is this even worthwhile? */ #ifndef HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD # define HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD 1024 * 1024 #endif @@ -565,19 +565,19 @@ elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide) } /* Print the first `total_lines - n_elide' lines of tmp->buffer. */ - assert (n_elide <= total_lines); - { - size_t n = total_lines - n_elide; - char const *buffer_end = tmp->buffer + tmp->nbytes; - char const *p = tmp->buffer; - while (n && (p = memchr (p, '\n', buffer_end - p))) - { - ++p; - ++tmp->nlines; - --n; - } - fwrite (tmp->buffer, 1, p - tmp->buffer, stdout); - } + if (n_elide < total_lines) + { + size_t n = total_lines - n_elide; + char const *buffer_end = tmp->buffer + tmp->nbytes; + char const *p = tmp->buffer; + while (n && (p = memchr (p, '\n', buffer_end - p))) + { + ++p; + ++tmp->nlines; + --n; + } + fwrite (tmp->buffer, 1, p - tmp->buffer, stdout); + } free_lbuffers: while (first) |