diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2003-10-31 00:35:59 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2003-10-31 00:35:59 +0000 |
commit | 4ef5a84583488942142d1adf9bdc46cb44ba0626 (patch) | |
tree | c4bac6346f48c2bd9ea5912ea8ae464400f4d0e0 /coreutils/tail.c | |
parent | 0120be94a0d4203f35a15fd4a8e82f1e57511445 (diff) | |
download | busybox-w32-4ef5a84583488942142d1adf9bdc46cb44ba0626.tar.gz busybox-w32-4ef5a84583488942142d1adf9bdc46cb44ba0626.tar.bz2 busybox-w32-4ef5a84583488942142d1adf9bdc46cb44ba0626.zip |
Move the tail -c option from FANCY_TAIL to the default tail, this makes
the default tail options conform to SUSv3, with the non-SUS
option all in FANCY_TAIL
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r-- | coreutils/tail.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c index 10b5cd7a7..d588ccdd1 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -89,9 +89,9 @@ static ssize_t tail_read(int fd, char *buf, size_t count) | |||
89 | } | 89 | } |
90 | 90 | ||
91 | static const char tail_opts[] = | 91 | static const char tail_opts[] = |
92 | "fn:" | 92 | "fn:c:" |
93 | #ifdef CONFIG_FEATURE_FANCY_TAIL | 93 | #ifdef CONFIG_FEATURE_FANCY_TAIL |
94 | "c:qs:v" | 94 | "qs:v" |
95 | #endif | 95 | #endif |
96 | ; | 96 | ; |
97 | 97 | ||
@@ -104,9 +104,7 @@ int tail_main(int argc, char **argv) | |||
104 | int from_top = 0; | 104 | int from_top = 0; |
105 | int follow = 0; | 105 | int follow = 0; |
106 | int header_threshhold = 1; | 106 | int header_threshhold = 1; |
107 | #ifdef CONFIG_FEATURE_FANCY_TAIL | ||
108 | int count_bytes = 0; | 107 | int count_bytes = 0; |
109 | #endif | ||
110 | 108 | ||
111 | char *tailbuf; | 109 | char *tailbuf; |
112 | size_t tailbufsize; | 110 | size_t tailbufsize; |
@@ -132,11 +130,9 @@ int tail_main(int argc, char **argv) | |||
132 | case 'f': | 130 | case 'f': |
133 | follow = 1; | 131 | follow = 1; |
134 | break; | 132 | break; |
135 | #ifdef CONFIG_FEATURE_FANCY_TAIL | ||
136 | case 'c': | 133 | case 'c': |
137 | count_bytes = 1; | 134 | count_bytes = 1; |
138 | /* FALLS THROUGH */ | 135 | /* FALLS THROUGH */ |
139 | #endif | ||
140 | case 'n': | 136 | case 'n': |
141 | GET_COUNT: | 137 | GET_COUNT: |
142 | count = bb_xgetlarg10_sfx(optarg, tail_suffixes); | 138 | count = bb_xgetlarg10_sfx(optarg, tail_suffixes); |
@@ -201,7 +197,7 @@ int tail_main(int argc, char **argv) | |||
201 | } | 197 | } |
202 | 198 | ||
203 | tailbufsize = BUFSIZ; | 199 | tailbufsize = BUFSIZ; |
204 | #ifdef CONFIG_FEATURE_FANCY_TAIL | 200 | |
205 | /* tail the files */ | 201 | /* tail the files */ |
206 | if (from_top < count_bytes) { /* Each is 0 or 1, so true iff 0 < 1. */ | 202 | if (from_top < count_bytes) { /* Each is 0 or 1, so true iff 0 < 1. */ |
207 | /* Hence, !from_top && count_bytes */ | 203 | /* Hence, !from_top && count_bytes */ |
@@ -209,7 +205,7 @@ int tail_main(int argc, char **argv) | |||
209 | tailbufsize = count + BUFSIZ; | 205 | tailbufsize = count + BUFSIZ; |
210 | } | 206 | } |
211 | } | 207 | } |
212 | #endif | 208 | |
213 | buf = tailbuf = xmalloc(tailbufsize); | 209 | buf = tailbuf = xmalloc(tailbufsize); |
214 | 210 | ||
215 | fmt = header_fmt + 1; /* Skip header leading newline on first output. */ | 211 | fmt = header_fmt + 1; /* Skip header leading newline on first output. */ |
@@ -237,13 +233,10 @@ int tail_main(int argc, char **argv) | |||
237 | if (from_top) { | 233 | if (from_top) { |
238 | nwrite = nread; | 234 | nwrite = nread; |
239 | if (seen < count) { | 235 | if (seen < count) { |
240 | #ifdef CONFIG_FEATURE_FANCY_TAIL | ||
241 | if (count_bytes) { | 236 | if (count_bytes) { |
242 | nwrite -= (count - seen); | 237 | nwrite -= (count - seen); |
243 | seen = count; | 238 | seen = count; |
244 | } else | 239 | } else { |
245 | #endif | ||
246 | { | ||
247 | s = buf; | 240 | s = buf; |
248 | do { | 241 | do { |
249 | --nwrite; | 242 | --nwrite; |
@@ -255,16 +248,13 @@ int tail_main(int argc, char **argv) | |||
255 | } | 248 | } |
256 | tail_xbb_full_write(buf + nread - nwrite, nwrite); | 249 | tail_xbb_full_write(buf + nread - nwrite, nwrite); |
257 | } else if (count) { | 250 | } else if (count) { |
258 | #ifdef CONFIG_FEATURE_FANCY_TAIL | ||
259 | if (count_bytes) { | 251 | if (count_bytes) { |
260 | taillen += nread; | 252 | taillen += nread; |
261 | if (taillen > count) { | 253 | if (taillen > count) { |
262 | memmove(tailbuf, tailbuf + taillen - count, count); | 254 | memmove(tailbuf, tailbuf + taillen - count, count); |
263 | taillen = count; | 255 | taillen = count; |
264 | } | 256 | } |
265 | } else | 257 | } else { |
266 | #endif | ||
267 | { | ||
268 | int k = nread; | 258 | int k = nread; |
269 | int nbuf = 0; | 259 | int nbuf = 0; |
270 | 260 | ||