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-w32-6910741067913d131d931b1e6424d3b8ed43e64f.tar.gz
busybox-w32-6910741067913d131d931b1e6424d3b8ed43e64f.tar.bz2
busybox-w32-6910741067913d131d931b1e6424d3b8ed43e64f.zip
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)
122 /* FALLS THROUGH */ 122 /* FALLS THROUGH */
123 case 'n': 123 case 'n':
124#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL 124#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
125 GET_COUNT: 125 GET_COUNT:
126#endif 126#endif
127 count = xatol_sfx(optarg, tail_suffixes); 127 from_top = 0;
128 /* Note: Leading whitespace is an error trapped above. */
129 if (*optarg == '+') { 128 if (*optarg == '+') {
129 ++optarg;
130 from_top = 1; 130 from_top = 1;
131 } else {
132 from_top = 0;
133 } 131 }
132 count = xatol_sfx(optarg, tail_suffixes);
133 /* Note: Leading whitespace is an error trapped above. */
134 if (count < 0) { 134 if (count < 0) {
135 count = -count; 135 count = -count;
136 } 136 }
@@ -150,20 +150,18 @@ int tail_main(int argc, char **argv)
150 bb_show_usage(); 150 bb_show_usage();
151 } 151 }
152 } 152 }
153 argc -= optind;
154 argv += optind;
153 155
154 /* open all the files */ 156 /* open all the files */
155 fds = xmalloc(sizeof(int) * (argc - optind + 1)); 157 fds = xmalloc(sizeof(int) * (argc + 1));
156
157 argv += optind;
158 nfiles = i = 0; 158 nfiles = i = 0;
159 159 if (argc == 0) {
160 if ((argc -= optind) == 0) {
161 struct stat statbuf; 160 struct stat statbuf;
162 161
163 if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) { 162 if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
164 follow = 0; 163 follow = 0;
165 } 164 }
166 /* --argv; */
167 *argv = (char *) bb_msg_standard_input; 165 *argv = (char *) bb_msg_standard_input;
168 goto DO_STDIN; 166 goto DO_STDIN;
169 } 167 }