aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-25 01:24:32 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-25 01:24:32 +0100
commitaf0255f49681bcc78830a56af885e891eca210f4 (patch)
tree89fa748e057d2543c69205300f7614a4ef326fdf /coreutils/tail.c
parent8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099 (diff)
downloadbusybox-w32-af0255f49681bcc78830a56af885e891eca210f4.tar.gz
busybox-w32-af0255f49681bcc78830a56af885e891eca210f4.tar.bz2
busybox-w32-af0255f49681bcc78830a56af885e891eca210f4.zip
head,tail: use common suffix struct. simplify help text.
function old new delta head_tail_suffixes - 32 +32 head_main 415 406 -9 packed_usage 29252 29234 -18 tail_suffixes 32 - -32 head_suffixes 32 - -32 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 0/2 up/down: 32/-91) Total: -59 bytes text data bss dec hex filename 890474 497 7584 898555 db5fb busybox_old 890415 497 7584 898496 db5c0 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index b376ec863..87251da83 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -24,6 +24,9 @@
24 * 7) lseek attempted when count==0 even if arg was +0 (from top) 24 * 7) lseek attempted when count==0 even if arg was +0 (from top)
25 */ 25 */
26 26
27//kbuild:lib-$(CONFIG_TAIL) += tail.o
28//kbuild:lib-$(CONFIG_TAIL) += head_tail.o
29
27//usage:#define tail_trivial_usage 30//usage:#define tail_trivial_usage
28//usage: "[OPTIONS] [FILE]..." 31//usage: "[OPTIONS] [FILE]..."
29//usage:#define tail_full_usage "\n\n" 32//usage:#define tail_full_usage "\n\n"
@@ -34,14 +37,13 @@
34//usage: "\n -s SECONDS Wait SECONDS between reads with -f" 37//usage: "\n -s SECONDS Wait SECONDS between reads with -f"
35//usage: ) 38//usage: )
36//usage: "\n -n N[kbm] Print last N lines" 39//usage: "\n -n N[kbm] Print last N lines"
40//usage: "\n -n +N[kbm] Skip N lines and print the rest"
37//usage: IF_FEATURE_FANCY_TAIL( 41//usage: IF_FEATURE_FANCY_TAIL(
38//usage: "\n -c N[kbm] Print last N bytes" 42//usage: "\n -c [+]N[kbm] Print last N bytes"
39//usage: "\n -q Never print headers" 43//usage: "\n -q Never print headers"
40//usage: "\n -v Always print headers" 44//usage: "\n -v Always print headers"
41//usage: "\n" 45//usage: "\n"
42//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)." 46//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)."
43//usage: "\nIf N starts with a '+', output begins with the Nth item from the start"
44//usage: "\nof each file, not from the end."
45//usage: ) 47//usage: )
46//usage: 48//usage:
47//usage:#define tail_example_usage 49//usage:#define tail_example_usage
@@ -49,13 +51,7 @@
49//usage: "nameserver 10.0.0.1\n" 51//usage: "nameserver 10.0.0.1\n"
50 52
51#include "libbb.h" 53#include "libbb.h"
52 54#include "head_tail.h"
53static const struct suffix_mult tail_suffixes[] = {
54 { "b", 512 },
55 { "k", 1024 },
56 { "m", 1024*1024 },
57 { "", 0 }
58};
59 55
60struct globals { 56struct globals {
61 bool from_top; 57 bool from_top;
@@ -102,7 +98,7 @@ static unsigned eat_num(const char *p)
102 p++; 98 p++;
103 G.from_top = 1; 99 G.from_top = 1;
104 } 100 }
105 return xatou_sfx(p, tail_suffixes); 101 return xatou_sfx(p, head_tail_suffixes);
106} 102}
107 103
108int tail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 104int tail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;