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
This commit is contained in:
Denis Vlasenko 2008-07-19 08:15:13 +00:00
parent 5f116629d8
commit bd28f6bf7f
3 changed files with 268 additions and 83 deletions

View file

@ -196,8 +196,12 @@ void lbb_prepare(const char *applet
#if ENABLE_FEATURE_INDIVIDUAL
/* Redundant for busybox (run_applet_and_exit covers that case)
* but needed for "individual applet" mode */
if (argv[1] && strcmp(argv[1], "--help") == 0)
bb_show_usage();
if (argv[1] && !argv[2] && strcmp(argv[1], "--help") == 0) {
/* Special case. POSIX says "test --help"
* should be no different from e.g. "test --foo". */
if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
bb_show_usage();
}
#endif
}
@ -715,8 +719,13 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
xfunc_error_retval = EXIT_FAILURE;
applet_name = APPLET_NAME(applet_no);
if (argc == 2 && !strcmp(argv[1], "--help"))
bb_show_usage();
if (argc == 2 && strcmp(argv[1], "--help") == 0) {
/* Special case. POSIX says "test --help"
* should be no different from e.g. "test --foo". */
//TODO: just compare applet_no with APPLET_NO_test
if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
bb_show_usage();
}
if (ENABLE_FEATURE_SUID)
check_suid(applet_no);
exit(applet_main[applet_no](argc, argv));