diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-29 03:31:20 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-29 03:31:20 +0000 |
commit | 745cd17926a9d75cdd6482d5ce58227b492d1ebe (patch) | |
tree | 568f3236704000eed61d3460f9eef92e9535b746 /libbb/appletlib.c | |
parent | c253778de92441b61806e1e4e7806e91f17ea50f (diff) | |
download | busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.tar.gz busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.tar.bz2 busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.zip |
Further optimize applet tables; prettify build output
text data bss dec hex filename
775923 929 9100 785952 bfe20 busybox_old
775565 929 9100 785594 bfcba busybox_unstripped
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r-- | libbb/appletlib.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index dcf24f5a9..d5a2d06af 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -101,19 +101,17 @@ void bb_show_usage(void) | |||
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | /* NB: any char pointer will work as well, not necessarily applet_names */ | ||
104 | static int applet_name_compare(const void *name, const void *v) | 105 | static int applet_name_compare(const void *name, const void *v) |
105 | { | 106 | { |
106 | int i = (const char *)v - applet_names; | 107 | int i = (const char *)v - applet_names; |
107 | return strcmp(name, APPLET_NAME(i)); | 108 | return strcmp(name, APPLET_NAME(i)); |
108 | } | 109 | } |
109 | |||
110 | int find_applet_by_name(const char *name) | 110 | int find_applet_by_name(const char *name) |
111 | { | 111 | { |
112 | const char *p; | ||
113 | /* Do a binary search to find the applet entry given the name. */ | 112 | /* Do a binary search to find the applet entry given the name. */ |
114 | 113 | const char *p; | |
115 | /* NB: any char pointer will work as well, not necessarily applet_names */ | 114 | p = bsearch(name, applet_names, ARRAY_SIZE(applet_main), 1, applet_name_compare); |
116 | p = bsearch(name, applet_names, ARRAY_SIZE(applet_mains), 1, applet_name_compare); | ||
117 | if (!p) | 115 | if (!p) |
118 | return -1; | 116 | return -1; |
119 | return p - applet_names; | 117 | return p - applet_names; |
@@ -543,10 +541,12 @@ static void install_links(const char *busybox, int use_symbolic_links) | |||
543 | if (use_symbolic_links) | 541 | if (use_symbolic_links) |
544 | lf = symlink; | 542 | lf = symlink; |
545 | 543 | ||
546 | for (i = 0; i < ARRAY_SIZE(applet_mains); i++) { | 544 | for (i = 0; i < ARRAY_SIZE(applet_main); i++) { |
547 | fpc = concat_path_file( | 545 | fpc = concat_path_file( |
548 | install_dir[APPLET_INSTALL_LOC(i)], | 546 | install_dir[APPLET_INSTALL_LOC(i)], |
549 | APPLET_NAME(i)); | 547 | APPLET_NAME(i)); |
548 | // debug: bb_error_msg("%slinking %s to busybox", | ||
549 | // use_symbolic_links ? "sym" : "", fpc); | ||
550 | rc = lf(busybox, fpc); | 550 | rc = lf(busybox, fpc); |
551 | if (rc != 0 && errno != EEXIST) { | 551 | if (rc != 0 && errno != EEXIST) { |
552 | bb_simple_perror_msg(fpc); | 552 | bb_simple_perror_msg(fpc); |
@@ -644,7 +644,7 @@ void run_applet_no_and_exit(int applet_no, char **argv) | |||
644 | bb_show_usage(); | 644 | bb_show_usage(); |
645 | if (ENABLE_FEATURE_SUID) | 645 | if (ENABLE_FEATURE_SUID) |
646 | check_suid(applet_no); | 646 | check_suid(applet_no); |
647 | exit(applet_mains[applet_no](argc, argv)); | 647 | exit(applet_main[applet_no](argc, argv)); |
648 | } | 648 | } |
649 | 649 | ||
650 | void run_applet_and_exit(const char *name, char **argv) | 650 | void run_applet_and_exit(const char *name, char **argv) |