*: 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
This commit is contained in:
Denis Vlasenko
2008-03-17 09:09:09 +00:00
parent 62a90cdd74
commit 1d42665b6b
34 changed files with 172 additions and 209 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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++]);

View File

@@ -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);

View File

@@ -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;
++argv;
if (!*argv)
bb_show_usage();
#if ENABLE_FEATURE_FANCY_SLEEP
if (argc < 2) {
bb_show_usage();
}
++argv;
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 */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}