diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-19 08:15:13 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-19 08:15:13 +0000 |
commit | bd28f6bf7f53ede8df39112d40cb52f2a3d00177 (patch) | |
tree | 0e2cc7fa0864c8998d4483fc2398a3c3e9791a0f /libbb/appletlib.c | |
parent | 5f116629d80b66bd09d8dc2b849befb1e27cd21a (diff) | |
download | busybox-w32-bd28f6bf7f53ede8df39112d40cb52f2a3d00177.tar.gz busybox-w32-bd28f6bf7f53ede8df39112d40cb52f2a3d00177.tar.bz2 busybox-w32-bd28f6bf7f53ede8df39112d40cb52f2a3d00177.zip |
test: fix parser to prefer binop over unop, as coreutils does.
remove bogus workaround in main(). rename atrocious variables/functions.
much expand testsuite.
libbb: fix --help to not affect "test --help"
function old new delta
run_applet_no_and_exit 421 440 +19
nexpr 817 825 +8
static.no_op - 6 +6
test_main 397 257 -140
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/1 up/down: 104/-211) Total: -107 bytes
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r-- | libbb/appletlib.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index eb98f1cd2..8c35450f8 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -196,8 +196,12 @@ void lbb_prepare(const char *applet | |||
196 | #if ENABLE_FEATURE_INDIVIDUAL | 196 | #if ENABLE_FEATURE_INDIVIDUAL |
197 | /* Redundant for busybox (run_applet_and_exit covers that case) | 197 | /* Redundant for busybox (run_applet_and_exit covers that case) |
198 | * but needed for "individual applet" mode */ | 198 | * but needed for "individual applet" mode */ |
199 | if (argv[1] && strcmp(argv[1], "--help") == 0) | 199 | if (argv[1] && !argv[2] && strcmp(argv[1], "--help") == 0) { |
200 | bb_show_usage(); | 200 | /* Special case. POSIX says "test --help" |
201 | * should be no different from e.g. "test --foo". */ | ||
202 | if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) | ||
203 | bb_show_usage(); | ||
204 | } | ||
201 | #endif | 205 | #endif |
202 | } | 206 | } |
203 | 207 | ||
@@ -715,8 +719,13 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) | |||
715 | xfunc_error_retval = EXIT_FAILURE; | 719 | xfunc_error_retval = EXIT_FAILURE; |
716 | 720 | ||
717 | applet_name = APPLET_NAME(applet_no); | 721 | applet_name = APPLET_NAME(applet_no); |
718 | if (argc == 2 && !strcmp(argv[1], "--help")) | 722 | if (argc == 2 && strcmp(argv[1], "--help") == 0) { |
719 | bb_show_usage(); | 723 | /* Special case. POSIX says "test --help" |
724 | * should be no different from e.g. "test --foo". */ | ||
725 | //TODO: just compare applet_no with APPLET_NO_test | ||
726 | if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) | ||
727 | bb_show_usage(); | ||
728 | } | ||
720 | if (ENABLE_FEATURE_SUID) | 729 | if (ENABLE_FEATURE_SUID) |
721 | check_suid(applet_no); | 730 | check_suid(applet_no); |
722 | exit(applet_main[applet_no](argc, argv)); | 731 | exit(applet_main[applet_no](argc, argv)); |