diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-23 06:28:40 +0300 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-23 06:28:40 +0300 |
commit | 69ca5a70fd4ae30f8a3beabec4d705f7dd32e3f3 (patch) | |
tree | 1939c21e008bb456049b186d8e3f61f41842b9e8 /coreutils/tail.c | |
parent | c8bac033f321d6077be35a6ce127b2587d096583 (diff) |
tail: fix fallout from tail -c optimization
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r-- | coreutils/tail.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c index 35b25a416..2f997a9f6 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -163,8 +163,6 @@ int tail_main(int argc, char **argv) fmt = header_fmt + 1; /* Skip header leading newline on first output. */ i = 0; do { - off_t current; - if (nfiles > header_threshhold) { tail_xprint_header(fmt, argv[i]); fmt = header_fmt; @@ -173,19 +171,17 @@ int tail_main(int argc, char **argv) /* Optimizing count-bytes case if the file is seekable. * Beware of backing up too far. * Also we exclude files with size 0 (because of /proc/xxx) */ - current = lseek(fds[i], 0, SEEK_END); - if (current > 0) { - if (!from_top) { + if (COUNT_BYTES && !from_top) { + off_t current = lseek(fds[i], 0, SEEK_END); + if (current > 0) { if (count == 0) continue; /* showing zero lines is easy :) */ - if (COUNT_BYTES) { - current -= count; - if (current < 0) - current = 0; - xlseek(fds[i], current, SEEK_SET); - bb_copyfd_size(fds[i], STDOUT_FILENO, count); - continue; - } + current -= count; + if (current < 0) + current = 0; + xlseek(fds[i], current, SEEK_SET); + bb_copyfd_size(fds[i], STDOUT_FILENO, count); + continue; } } |