tail: fix fallout from tail -c optimization
This commit is contained in:
parent
c8bac033f3
commit
69ca5a70fd
@ -163,8 +163,6 @@ int tail_main(int argc, char **argv)
|
|||||||
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
|
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
off_t current;
|
|
||||||
|
|
||||||
if (nfiles > header_threshhold) {
|
if (nfiles > header_threshhold) {
|
||||||
tail_xprint_header(fmt, argv[i]);
|
tail_xprint_header(fmt, argv[i]);
|
||||||
fmt = header_fmt;
|
fmt = header_fmt;
|
||||||
@ -173,19 +171,17 @@ int tail_main(int argc, char **argv)
|
|||||||
/* Optimizing count-bytes case if the file is seekable.
|
/* Optimizing count-bytes case if the file is seekable.
|
||||||
* Beware of backing up too far.
|
* Beware of backing up too far.
|
||||||
* Also we exclude files with size 0 (because of /proc/xxx) */
|
* Also we exclude files with size 0 (because of /proc/xxx) */
|
||||||
current = lseek(fds[i], 0, SEEK_END);
|
if (COUNT_BYTES && !from_top) {
|
||||||
if (current > 0) {
|
off_t current = lseek(fds[i], 0, SEEK_END);
|
||||||
if (!from_top) {
|
if (current > 0) {
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
continue; /* showing zero lines is easy :) */
|
continue; /* showing zero lines is easy :) */
|
||||||
if (COUNT_BYTES) {
|
current -= count;
|
||||||
current -= count;
|
if (current < 0)
|
||||||
if (current < 0)
|
current = 0;
|
||||||
current = 0;
|
xlseek(fds[i], current, SEEK_SET);
|
||||||
xlseek(fds[i], current, SEEK_SET);
|
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
|
||||||
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ -n "$d" ] || d=..
|
echo -ne "abc\ndef\n123\n" >input
|
||||||
tail -n 2 "$d/README" > logfile.gnu
|
echo -ne "def\n123\n" >logfile.ok
|
||||||
busybox tail -n 2 "$d/README" > logfile.bb
|
busybox tail -n 2 input > logfile.bb
|
||||||
cmp logfile.gnu logfile.bb
|
cmp logfile.ok logfile.bb
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ -n "$d" ] || d=..
|
echo -ne "abc\ndef\n123\n" >input
|
||||||
tail -n 2 "$d/README" > logfile.gnu
|
echo -ne "def\n123\n" >logfile.ok
|
||||||
busybox tail -n 2 "$d/README" > logfile.bb
|
busybox tail -2 input > logfile.bb
|
||||||
cmp logfile.gnu logfile.bb
|
cmp logfile.ok logfile.bb
|
||||||
|
Loading…
x
Reference in New Issue
Block a user