From 5352c4a62b929dfa86651b3db4eb511edb4b3052 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 13 May 2003 10:21:13 +0000 Subject: [PATCH] (elide_tail_lines_pipe): Use `if', not an assert. Now that assert is no longer used, don't include . --- src/head.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/head.c b/src/head.c index 83e03781b0..ad718aa1ee 100644 --- a/src/head.c +++ b/src/head.c @@ -28,7 +28,6 @@ #include #include -#include #include #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) -- 2.47.2