diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-28 09:45:50 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-28 09:45:50 +0200 |
commit | dd6b21192112711f1b7e89e998891f17f9c21c8d (patch) | |
tree | 7fbf5f40038db7375ca49da5f0a99ba5a3f61a34 | |
parent | b9f2bb36eaef9a3316fb7d54953a900b70912d85 (diff) | |
download | busybox-w32-dd6b21192112711f1b7e89e998891f17f9c21c8d.tar.gz busybox-w32-dd6b21192112711f1b7e89e998891f17f9c21c8d.tar.bz2 busybox-w32-dd6b21192112711f1b7e89e998891f17f9c21c8d.zip |
hush: optimize type builtin a bit
function old new delta
builtin_type 130 125 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c index efa93c1a6..500091066 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -6766,32 +6766,31 @@ static int builtin_trap(char **argv) | |||
6766 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */ | 6766 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */ |
6767 | static int builtin_type(char **argv) | 6767 | static int builtin_type(char **argv) |
6768 | { | 6768 | { |
6769 | int i, ret = EXIT_SUCCESS; | 6769 | int ret = EXIT_SUCCESS; |
6770 | 6770 | ||
6771 | for (i = 1; argv[i]; ++i) { | 6771 | while (*++argv) { |
6772 | void *path; | 6772 | char *path; |
6773 | const void *find_ret; | ||
6774 | const char *type; | 6773 | const char *type; |
6775 | 6774 | ||
6776 | type = path = NULL; | 6775 | type = path = NULL; |
6777 | 6776 | ||
6778 | if (0) {} /* make conditional compile easier below */ | 6777 | if (0) {} /* make conditional compile easier below */ |
6779 | /*else if ((find_ret = find_alias(argv[i]))) | 6778 | /*else if (find_alias(*argv)) |
6780 | type = "an alias";*/ | 6779 | type = "an alias";*/ |
6781 | #if ENABLE_HUSH_FUNCTIONS | 6780 | #if ENABLE_HUSH_FUNCTIONS |
6782 | else if ((find_ret = find_function(argv[i]))) | 6781 | else if (find_function(*argv)) |
6783 | type = "a function"; | 6782 | type = "a function"; |
6784 | #endif | 6783 | #endif |
6785 | else if ((find_ret = find_builtin(argv[i]))) | 6784 | else if (find_builtin(*argv)) |
6786 | type = "a shell builtin"; | 6785 | type = "a shell builtin"; |
6787 | else if ((find_ret = path = find_in_path(argv[i]))) | 6786 | else if ((path = find_in_path(*argv)) != NULL) |
6788 | type = find_ret; | 6787 | type = path; |
6789 | 6788 | ||
6790 | if (!type) { | 6789 | if (!type) { |
6791 | bb_error_msg("type: %s: not found", argv[i]); | 6790 | bb_error_msg("type: %s: not found", *argv); |
6792 | ret = EXIT_FAILURE; | 6791 | ret = EXIT_FAILURE; |
6793 | } else | 6792 | } else |
6794 | printf("%s is %s\n", argv[i], type); | 6793 | printf("%s is %s\n", *argv, type); |
6795 | 6794 | ||
6796 | if (path) | 6795 | if (path) |
6797 | free(path); | 6796 | free(path); |