diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-28 06:49:03 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-28 06:49:03 +0000 |
commit | 1aa7e477b1b727db77cac2d717f0fcca40587f78 (patch) | |
tree | 247171517f0e01d32a71a5e96f4bef462cc0e9c6 /shell/ash.c | |
parent | 79c6904faff1ebd4bf4b7d9cd0c20ca70f4cec75 (diff) | |
download | busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.tar.gz busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.tar.bz2 busybox-w32-1aa7e477b1b727db77cac2d717f0fcca40587f78.zip |
reorganize applet table. Eliminates pointers to names.
Should be a big win for libbusybox. busybox wins too:
text data bss dec hex filename
776524 929 9100 786553 c0079 busybox_old
775903 929 9100 785932 bfe0c busybox_unstripped
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/shell/ash.c b/shell/ash.c index 8f388f59b..9b9fe5b6d 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #if DEBUG | 53 | #if DEBUG |
54 | #define _GNU_SOURCE | 54 | #define _GNU_SOURCE |
55 | #endif | 55 | #endif |
56 | #include "busybox.h" /* for struct bb_applet */ | 56 | #include "busybox.h" /* for applet_names */ |
57 | #include <paths.h> | 57 | #include <paths.h> |
58 | #include <setjmp.h> | 58 | #include <setjmp.h> |
59 | #include <fnmatch.h> | 59 | #include <fnmatch.h> |
@@ -6479,12 +6479,10 @@ tryexec(char *cmd, char **argv, char **envp) | |||
6479 | 6479 | ||
6480 | #if ENABLE_FEATURE_SH_STANDALONE | 6480 | #if ENABLE_FEATURE_SH_STANDALONE |
6481 | if (strchr(cmd, '/') == NULL) { | 6481 | if (strchr(cmd, '/') == NULL) { |
6482 | const struct bb_applet *a; | 6482 | int a = find_applet_by_name(cmd); |
6483 | 6483 | if (a >= 0) { | |
6484 | a = find_applet_by_name(cmd); | 6484 | if (APPLET_IS_NOEXEC(a)) |
6485 | if (a) { | 6485 | run_applet_no_and_exit(a, argv); |
6486 | if (a->noexec) | ||
6487 | run_appletstruct_and_exit(a, argv); | ||
6488 | /* re-exec ourselves with the new arguments */ | 6486 | /* re-exec ourselves with the new arguments */ |
6489 | execve(bb_busybox_exec_path, argv, envp); | 6487 | execve(bb_busybox_exec_path, argv, envp); |
6490 | /* If they called chroot or otherwise made the binary no longer | 6488 | /* If they called chroot or otherwise made the binary no longer |
@@ -6539,7 +6537,7 @@ shellexec(char **argv, const char *path, int idx) | |||
6539 | envp = environment(); | 6537 | envp = environment(); |
6540 | if (strchr(argv[0], '/') | 6538 | if (strchr(argv[0], '/') |
6541 | #if ENABLE_FEATURE_SH_STANDALONE | 6539 | #if ENABLE_FEATURE_SH_STANDALONE |
6542 | || find_applet_by_name(argv[0]) | 6540 | || find_applet_by_name(argv[0]) >= 0 |
6543 | #endif | 6541 | #endif |
6544 | ) { | 6542 | ) { |
6545 | tryexec(argv[0], argv, envp); | 6543 | tryexec(argv[0], argv, envp); |
@@ -11117,7 +11115,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
11117 | } | 11115 | } |
11118 | 11116 | ||
11119 | #if ENABLE_FEATURE_SH_STANDALONE | 11117 | #if ENABLE_FEATURE_SH_STANDALONE |
11120 | if (find_applet_by_name(name)) { | 11118 | if (find_applet_by_name(name) >= 0) { |
11121 | entry->cmdtype = CMDNORMAL; | 11119 | entry->cmdtype = CMDNORMAL; |
11122 | entry->u.index = -1; | 11120 | entry->u.index = -1; |
11123 | return; | 11121 | return; |
@@ -11298,11 +11296,15 @@ helpcmd(int argc, char **argv) | |||
11298 | } | 11296 | } |
11299 | } | 11297 | } |
11300 | #if ENABLE_FEATURE_SH_STANDALONE | 11298 | #if ENABLE_FEATURE_SH_STANDALONE |
11301 | for (i = 0; i < NUM_APPLETS; i++) { | 11299 | { |
11302 | col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), applets[i].name); | 11300 | const char *a = applet_names; |
11303 | if (col > 60) { | 11301 | while (*a) { |
11304 | out1fmt("\n"); | 11302 | col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), a); |
11305 | col = 0; | 11303 | if (col > 60) { |
11304 | out1fmt("\n"); | ||
11305 | col = 0; | ||
11306 | } | ||
11307 | a += strlen(a) + 1; | ||
11306 | } | 11308 | } |
11307 | } | 11309 | } |
11308 | #endif | 11310 | #endif |