aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-21 00:43:06 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-21 00:43:06 +0000
commit6910741067913d131d931b1e6424d3b8ed43e64f (patch)
tree945d53a36adbced6732a01fad444e8bf2ff5f1db /coreutils/tail.c
parent3f3190e34c5d39986fae0ec03f37cf5509dd9c93 (diff)
downloadbusybox-6910741067913d131d931b1e6424d3b8ed43e64f.tar.gz
tail: fix tail +N
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 643c0f3c9..2182b0936 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -122,15 +122,15 @@ int tail_main(int argc, char **argv)
/* FALLS THROUGH */
case 'n':
#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
- GET_COUNT:
+ GET_COUNT:
#endif
- count = xatol_sfx(optarg, tail_suffixes);
- /* Note: Leading whitespace is an error trapped above. */
+ from_top = 0;
if (*optarg == '+') {
+ ++optarg;
from_top = 1;
- } else {
- from_top = 0;
}
+ count = xatol_sfx(optarg, tail_suffixes);
+ /* Note: Leading whitespace is an error trapped above. */
if (count < 0) {
count = -count;
}
@@ -150,20 +150,18 @@ int tail_main(int argc, char **argv)
bb_show_usage();
}
}
+ argc -= optind;
+ argv += optind;
/* open all the files */
- fds = xmalloc(sizeof(int) * (argc - optind + 1));
-
- argv += optind;
+ fds = xmalloc(sizeof(int) * (argc + 1));
nfiles = i = 0;
-
- if ((argc -= optind) == 0) {
+ if (argc == 0) {
struct stat statbuf;
if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
follow = 0;
}
- /* --argv; */
*argv = (char *) bb_msg_standard_input;
goto DO_STDIN;
}