diff options
author | Denis Vlasenko | 2008-03-17 09:09:09 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-03-17 09:09:09 +0000 |
commit | 1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2 (patch) | |
tree | 7ec8969fc2b07a2b7dc37f96435e5eddf7daf7fd /coreutils | |
parent | 62a90cdd7435f09f4bb8673e8b7b213067f9d5cc (diff) | |
download | busybox-1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2.zip busybox-1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2.tar.gz |
*: shrink: use Vladimir's "o+" specifier instead of xatou(opt_param)
function old new delta
getopt32 1370 1385 +15
sulogin_main 490 494 +4
realpath_main 84 86 +2
sleep_main 76 77 +1
mt_main 256 257 +1
printenv_main 75 74 -1
fdformat_main 546 545 -1
usleep_main 44 42 -2
setlogcons_main 77 75 -2
ed_main 2654 2649 -5
deallocvt_main 69 64 -5
addgroup_main 373 368 -5
mkfs_minix_main 2989 2982 -7
tail_main 1221 1213 -8
sv_main 1254 1241 -13
du_main 348 328 -20
tftp_main 325 302 -23
split_main 581 558 -23
nc_main 1000 977 -23
diff_main 891 868 -23
arping_main 1797 1770 -27
ls_main 893 847 -46
od_main 2797 2750 -47
readprofile_main 1944 1895 -49
tcpudpsvd_main 1973 1922 -51
udhcpc_main 2590 2513 -77
grep_main 824 722 -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/22 up/down: 23/-560) Total: -537 bytes
text data bss dec hex filename
796973 658 7428 805059 c48c3 busybox_old
796479 662 7420 804561 c46d1 busybox_unstripped
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/du.c | 13 | ||||
-rw-r--r-- | coreutils/ls.c | 9 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 10 | ||||
-rw-r--r-- | coreutils/printenv.c | 4 | ||||
-rw-r--r-- | coreutils/realpath.c | 7 | ||||
-rw-r--r-- | coreutils/sleep.c | 17 | ||||
-rw-r--r-- | coreutils/split.c | 12 | ||||
-rw-r--r-- | coreutils/tail.c | 5 | ||||
-rw-r--r-- | coreutils/usleep.c | 4 |
9 files changed, 29 insertions, 52 deletions
diff --git a/coreutils/du.c b/coreutils/du.c index 7495f7a..b469824 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -146,7 +146,6 @@ int du_main(int argc ATTRIBUTE_UNUSED, char **argv) unsigned long total; int slink_depth_save; bool print_final_total; - char *smax_print_depth; unsigned opt; #if ENABLE_FEATURE_HUMAN_READABLE @@ -168,8 +167,8 @@ int du_main(int argc ATTRIBUTE_UNUSED, char **argv) * ignore -a. This is consistent with -s being equivalent to -d 0. */ #if ENABLE_FEATURE_HUMAN_READABLE - opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s"; - opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth); + opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+"; + opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth); argv += optind; if (opt & (1 << 9)) { /* -h opt */ @@ -184,8 +183,8 @@ int du_main(int argc ATTRIBUTE_UNUSED, char **argv) G.disp_hr = 1024; } #else - opt_complementary = "H-L:L-H:s-d:d-s"; - opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth); + opt_complementary = "H-L:L-H:s-d:d-s:d+"; + opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth); argv += optind; #if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K if (opt & (1 << 2)) { @@ -211,10 +210,6 @@ int du_main(int argc ATTRIBUTE_UNUSED, char **argv) G.max_print_depth = 0; } G.one_file_system = opt & (1 << 5); /* -x opt */ - if (opt & (1 << 6)) { - /* -d opt */ - G.max_print_depth = xatoi_u(smax_print_depth); - } if (opt & (1 << 7)) { /* -l opt */ G.count_hardlinks = MAXINT(nlink_t); diff --git a/coreutils/ls.c b/coreutils/ls.c index dbf1c5b..9e5c6de 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -799,8 +799,6 @@ int ls_main(int argc, char **argv) int ac; int i; char **av; - USE_FEATURE_AUTOWIDTH(char *tabstops_str = NULL;) - USE_FEATURE_AUTOWIDTH(char *terminal_width_str = NULL;) USE_FEATURE_LS_COLOR(char *color_opt;) #if ENABLE_FEATURE_LS_TIMESTAMPS @@ -820,12 +818,9 @@ int ls_main(int argc, char **argv) /* process options */ USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;) #if ENABLE_FEATURE_AUTOWIDTH - opt = getopt32(argv, ls_options, &tabstops_str, &terminal_width_str + opt_complementary = "T+:w+"; /* -T N, -w N */ + opt = getopt32(argv, ls_options, &tabstops, &terminal_width USE_FEATURE_LS_COLOR(, &color_opt)); - if (tabstops_str) - tabstops = xatou(tabstops_str); - if (terminal_width_str) - terminal_width = xatou(terminal_width_str); #else opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt)); #endif diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index a083114..4526f0e 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c @@ -188,7 +188,7 @@ static off_t pseudo_offset; a multiple of the least common multiple of the sizes associated with the specified output types. It should be as large as possible, but no larger than 16 -- unless specified with the -w option. */ -static size_t bytes_per_block; +static unsigned bytes_per_block = 32; /* have to use unsigned, not size_t */ /* A NULL-terminated list of the file-arguments from the command line. */ static const char *const *file_list; @@ -1218,7 +1218,6 @@ int od_main(int argc, char **argv) ; #endif char *str_A, *str_N, *str_j, *str_S; - char *str_w = NULL; llist_t *lst_t = NULL; unsigned opt; int l_c_m; @@ -1239,7 +1238,7 @@ int od_main(int argc, char **argv) /* flag_dump_strings = 0; - already is */ /* Parse command line */ - opt_complementary = "t::"; // list + opt_complementary = "w+:t::"; /* -w N, -t is a list */ #if ENABLE_GETOPT_LONG applet_long_options = od_longopts; #endif @@ -1248,7 +1247,7 @@ int od_main(int argc, char **argv) // -S was -s and also had optional parameter // but in coreutils 6.3 it was renamed and now has // _mandatory_ parameter - &str_A, &str_N, &str_j, &lst_t, &str_S, &str_w); + &str_A, &str_N, &str_j, &lst_t, &str_S, &bytes_per_block); argc -= optind; argv += optind; if (opt & OPT_A) { @@ -1404,9 +1403,6 @@ int od_main(int argc, char **argv) l_c_m = get_lcm(); if (opt & OPT_w) { /* -w: width */ - bytes_per_block = 32; - if (str_w) - bytes_per_block = xatou(str_w); if (!bytes_per_block || bytes_per_block % l_c_m != 0) { bb_error_msg("warning: invalid width %u; using %d instead", (unsigned)bytes_per_block, l_c_m); diff --git a/coreutils/printenv.c b/coreutils/printenv.c index 06d68d0..31d76d7 100644 --- a/coreutils/printenv.c +++ b/coreutils/printenv.c @@ -11,10 +11,10 @@ #include "libbb.h" int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int printenv_main(int argc, char **argv) +int printenv_main(int argc ATTRIBUTE_UNUSED, char **argv) { /* no variables specified, show whole env */ - if (argc == 1) { + if (!argv[1]) { int e = 0; while (environ[e]) puts(environ[e++]); diff --git a/coreutils/realpath.c b/coreutils/realpath.c index bcb73a8..6766524 100644 --- a/coreutils/realpath.c +++ b/coreutils/realpath.c @@ -13,7 +13,7 @@ #include "libbb.h" int realpath_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int realpath_main(int argc, char **argv) +int realpath_main(int argc ATTRIBUTE_UNUSED, char **argv) { int retval = EXIT_SUCCESS; @@ -25,19 +25,18 @@ int realpath_main(int argc, char **argv) # define resolved_path_MUST_FREE 0 #endif - if (--argc == 0) { + if (!*++argv) { bb_show_usage(); } do { - argv++; if (realpath(*argv, resolved_path) != NULL) { puts(resolved_path); } else { retval = EXIT_FAILURE; bb_simple_perror_msg(*argv); } - } while (--argc); + } while (*++argv); #if ENABLE_FEATURE_CLEAN_UP && resolved_path_MUST_FREE RELEASE_CONFIG_BUFFER(resolved_path); diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 6890e35..78f9a8e 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c @@ -34,17 +34,16 @@ static const struct suffix_mult sfx[] = { #endif int sleep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int sleep_main(int argc, char **argv) +int sleep_main(int argc ATTRIBUTE_UNUSED, char **argv) { unsigned duration; -#if ENABLE_FEATURE_FANCY_SLEEP - - if (argc < 2) { + ++argv; + if (!*argv) bb_show_usage(); - } - ++argv; +#if ENABLE_FEATURE_FANCY_SLEEP + duration = 0; do { duration += xatoul_range_sfx(*argv, 0, UINT_MAX-duration, sfx); @@ -52,11 +51,7 @@ int sleep_main(int argc, char **argv) #else /* FEATURE_FANCY_SLEEP */ - if (argc != 2) { - bb_show_usage(); - } - - duration = xatou(argv[1]); + duration = xatou(*argv); #endif /* FEATURE_FANCY_SLEEP */ diff --git a/coreutils/split.c b/coreutils/split.c index cf26a93..2306789 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -68,15 +68,13 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv) ssize_t bytes_read, to_write; char *src; - opt_complementary = "?2"; - opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &sfx); + opt_complementary = "?2:a+"; /* max 2 args; -a N */ + opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); if (opt & SPLIT_OPT_l) - cnt = xatoul(count_p); - if (opt & SPLIT_OPT_b) - cnt = xatoul_sfx(count_p, split_suffices); - if (opt & SPLIT_OPT_a) - suffix_len = xatou(sfx); + cnt = XATOOFF(count_p); + if (opt & SPLIT_OPT_b) // FIXME: also needs XATOOFF + cnt = xatoull_sfx(count_p, split_suffices); sfx = "x"; argv += optind; diff --git a/coreutils/tail.c b/coreutils/tail.c index 52aa8f6..35b25a4 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -87,7 +87,6 @@ int tail_main(int argc, char **argv) bool from_top; int header_threshhold = 1; const char *str_c, *str_n; - USE_FEATURE_FANCY_TAIL(const char *str_s;) char *tailbuf; size_t tailbufsize; @@ -110,8 +109,9 @@ int tail_main(int argc, char **argv) } #endif + USE_FEATURE_FANCY_TAIL(opt_complementary = "s+";) /* -s N */ opt = getopt32(argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"), - &str_c, &str_n USE_FEATURE_FANCY_TAIL(,&str_s)); + &str_c, &str_n USE_FEATURE_FANCY_TAIL(,&sleep_period)); #define FOLLOW (opt & 0x1) #define COUNT_BYTES (opt & 0x2) //if (opt & 0x1) // -f @@ -119,7 +119,6 @@ int tail_main(int argc, char **argv) if (opt & 0x4) count = eat_num(str_n); // -n #if ENABLE_FEATURE_FANCY_TAIL if (opt & 0x8) header_threshhold = INT_MAX; // -q - if (opt & 0x10) sleep_period = xatou(str_s); // -s if (opt & 0x20) header_threshhold = 0; // -v #endif argc -= optind; diff --git a/coreutils/usleep.c b/coreutils/usleep.c index 1c90223..d34880d 100644 --- a/coreutils/usleep.c +++ b/coreutils/usleep.c @@ -14,9 +14,9 @@ /* This is a NOFORK applet. Be very careful! */ int usleep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int usleep_main(int argc, char **argv) +int usleep_main(int argc ATTRIBUTE_UNUSED, char **argv) { - if (argc != 2) { + if (!argv[1]) { bb_show_usage(); } |