svn commit: trunk/busybox: coreutils testsuite/tail
vda at busybox.net
vda at busybox.net
Sun Mar 23 03:28:40 UTC 2008
Author: vda
Date: 2008-03-22 20:28:40 -0700 (Sat, 22 Mar 2008)
New Revision: 21457
Log:
tail: fix fallout from tail -c optimization
Modified:
trunk/busybox/coreutils/tail.c
trunk/busybox/testsuite/tail/tail-n-works
trunk/busybox/testsuite/tail/tail-works
Changeset:
Modified: trunk/busybox/coreutils/tail.c
===================================================================
--- trunk/busybox/coreutils/tail.c 2008-03-22 17:46:43 UTC (rev 21456)
+++ trunk/busybox/coreutils/tail.c 2008-03-23 03:28:40 UTC (rev 21457)
@@ -163,8 +163,6 @@
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 @@
/* 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;
}
}
Modified: trunk/busybox/testsuite/tail/tail-n-works
===================================================================
--- trunk/busybox/testsuite/tail/tail-n-works 2008-03-22 17:46:43 UTC (rev 21456)
+++ trunk/busybox/testsuite/tail/tail-n-works 2008-03-23 03:28:40 UTC (rev 21457)
@@ -1,4 +1,4 @@
-[ -n "$d" ] || d=..
-tail -n 2 "$d/README" > logfile.gnu
-busybox tail -n 2 "$d/README" > logfile.bb
-cmp logfile.gnu logfile.bb
+echo -ne "abc\ndef\n123\n" >input
+echo -ne "def\n123\n" >logfile.ok
+busybox tail -n 2 input > logfile.bb
+cmp logfile.ok logfile.bb
Modified: trunk/busybox/testsuite/tail/tail-works
===================================================================
--- trunk/busybox/testsuite/tail/tail-works 2008-03-22 17:46:43 UTC (rev 21456)
+++ trunk/busybox/testsuite/tail/tail-works 2008-03-23 03:28:40 UTC (rev 21457)
@@ -1,4 +1,4 @@
-[ -n "$d" ] || d=..
-tail -n 2 "$d/README" > logfile.gnu
-busybox tail -n 2 "$d/README" > logfile.bb
-cmp logfile.gnu logfile.bb
+echo -ne "abc\ndef\n123\n" >input
+echo -ne "def\n123\n" >logfile.ok
+busybox tail -2 input > logfile.bb
+cmp logfile.ok logfile.bb
More information about the busybox-cvs
mailing list