From af0255f49681bcc78830a56af885e891eca210f4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 25 Feb 2013 01:24:32 +0100 Subject: 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 --- coreutils/tail.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'coreutils/tail.c') 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 @@ * 7) lseek attempted when count==0 even if arg was +0 (from top) */ +//kbuild:lib-$(CONFIG_TAIL) += tail.o +//kbuild:lib-$(CONFIG_TAIL) += head_tail.o + //usage:#define tail_trivial_usage //usage: "[OPTIONS] [FILE]..." //usage:#define tail_full_usage "\n\n" @@ -34,14 +37,13 @@ //usage: "\n -s SECONDS Wait SECONDS between reads with -f" //usage: ) //usage: "\n -n N[kbm] Print last N lines" +//usage: "\n -n +N[kbm] Skip N lines and print the rest" //usage: IF_FEATURE_FANCY_TAIL( -//usage: "\n -c N[kbm] Print last N bytes" +//usage: "\n -c [+]N[kbm] Print last N bytes" //usage: "\n -q Never print headers" //usage: "\n -v Always print headers" //usage: "\n" //usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)." -//usage: "\nIf N starts with a '+', output begins with the Nth item from the start" -//usage: "\nof each file, not from the end." //usage: ) //usage: //usage:#define tail_example_usage @@ -49,13 +51,7 @@ //usage: "nameserver 10.0.0.1\n" #include "libbb.h" - -static const struct suffix_mult tail_suffixes[] = { - { "b", 512 }, - { "k", 1024 }, - { "m", 1024*1024 }, - { "", 0 } -}; +#include "head_tail.h" struct globals { bool from_top; @@ -102,7 +98,7 @@ static unsigned eat_num(const char *p) p++; G.from_top = 1; } - return xatou_sfx(p, tail_suffixes); + return xatou_sfx(p, head_tail_suffixes); } int tail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -- cgit v1.2.3