function old new delta run_applet_and_exit 755 770 +15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 15/0) Total: 15 bytes text data bss dec hex filename
With the standalone shell feature enabled bloat increases to 30 bytes. Signed-off-by: Ron Yorston <[email protected]> --- libbb/appletlib.c | 29 ++++++++++------------------- libbb/lineedit.c | 11 +++-------- shell/ash.c | 6 ++---- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 95e589e..32f3fd3 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -159,13 +159,10 @@ int FAST_FUNC find_applet_by_name(const char *name) return (int)(ptrdiff_t)p - 1; #else /* A version which does not pull in bsearch */ - int i = 0; - const char *p = applet_names; - while (i < NUM_APPLETS) { - if (strcmp(name, p) == 0) + int i; + for (i = 0; i < NUM_APPLETS; i++) { + if (strcmp(name, APPLET_NAME(i)) == 0) return i; - p += strlen(p) + 1; - i++; } return -1; #endif @@ -616,9 +613,8 @@ static int busybox_main(char **argv) { if (!argv[1]) { /* Called without arguments */ - const char *a; int col; - unsigned output_width; + unsigned i, output_width; help: output_width = 80; if (ENABLE_FEATURE_AUTOWIDTH) { @@ -658,11 +654,10 @@ static int busybox_main(char **argv) "Currently defined functions:\n" ); col = 0; - a = applet_names; /* prevent last comma to be in the very last pos */ output_width--; - while (*a) { - int len2 = strlen(a) + 2; + for (i = 0; i < NUM_APPLETS; i++) { + int len2 = strlen(APPLET_NAME(i)) + 2; if (col >= (int)output_width - len2) { full_write2_str(",\n"); col = 0; @@ -673,27 +668,23 @@ static int busybox_main(char **argv) } else { full_write2_str(", "); } - full_write2_str(a); + full_write2_str(APPLET_NAME(i)); col += len2; - a += len2 - 1; } full_write2_str("\n\n"); return 0; } if (is_prefixed_with(argv[1], "--list")) { - unsigned i = 0; - const char *a = applet_names; + unsigned i; dup2(1, 2); - while (*a) { + for (i = 0; i < NUM_APPLETS; i++) { # if ENABLE_FEATURE_INSTALLER if (argv[1][6]) /* --list-full? */ full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); # endif - full_write2_str(a); + full_write2_str(APPLET_NAME(i)); full_write2_str("\n"); - i++; - a += strlen(a) + 1; } return 0; } diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 2ddb2b6..1706e3d 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -777,14 +777,9 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 if (type == FIND_EXE_ONLY) { - const char *p = applet_names; - - i = 0; - while (i < NUM_APPLETS) { - if (strncmp(pfind, p, pf_len) == 0) - add_match(xstrdup(p)); - p += strlen(p) + 1; - i++; + for (i = 0; i < NUM_APPLETS; i++) { + if (strncmp(pfind, APPLET_NAME(i), pf_len) == 0) + add_match(xstrdup(APPLET_NAME(i))); } } #endif diff --git a/shell/ash.c b/shell/ash.c index b5a2d96..77c8b63 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12588,14 +12588,12 @@ helpcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) } # if ENABLE_FEATURE_SH_STANDALONE { - const char *a = applet_names; - while (*a) { - col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), a); + for (i = 0; i < NUM_APPLETS; i++) { + col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), APPLET_NAME(i)); if (col > 60) { out1fmt("\n"); col = 0; } - a += strlen(a) + 1; } } # endif -- 2.5.5 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
