X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=test.c;h=ab9c23e4b629f718503afa073ab8b3ae169d09a6;hb=44a991470955ec3018ba8f40cc3be7b864dc8cce;hp=bf1622cde717b3b1ae98523be983892ccf83cd65;hpb=3bd8bd89ee9d0b65bf279e1ecad826a5f2f0a217;p=oweals%2Fbusybox.git diff --git a/test.c b/test.c index bf1622cde..ab9c23e4b 100644 --- a/test.c +++ b/test.c @@ -31,14 +31,13 @@ * "This program is in the Public Domain." */ -#include "internal.h" #include -#include #include #include #include #include #include +#include "busybox.h" #define BB_DECLARE_EXTERN #define bb_need_help #include "messages.c" @@ -157,8 +156,8 @@ struct t_op { {0, 0, 0} }; -char **t_wp; -struct t_op const *t_wp_op; +static char **t_wp; +static struct t_op const *t_wp_op; static gid_t *group_array = NULL; static int ngroups; @@ -178,15 +177,6 @@ static int test_eaccess(); static int is_a_group_member(); static void initialize_group_array(); -const char test_usage[] = - "test EXPRESSION\n" - "or [ EXPRESSION ]\n" -#ifndef BB_FEATURE_TRIVIAL_HELP - "\nChecks file types and compares values returning an exit\n" - "code determined by the value of EXPRESSION.\n" -#endif - ; - extern int test_main(int argc, char** argv) { @@ -194,12 +184,9 @@ test_main(int argc, char** argv) if (strcmp(applet_name, "[") == 0) { if (strcmp(argv[--argc], "]")) - fatalError("missing ]\n"); + error_msg_and_die("missing ]"); argv[argc] = NULL; } - if (strcmp(argv[1], dash_dash_help) == 0) - usage(test_usage); - /* Implement special cases from POSIX.2, section 4.62.4 */ switch (argc) { case 1: @@ -246,9 +233,9 @@ syntax(op, msg) char *msg; { if (op && *op) - fatalError("%s: %s\n", op, msg); + error_msg_and_die("%s: %s", op, msg); else - fatalError("%s\n", msg); + error_msg_and_die("%s", msg); } static int @@ -483,13 +470,13 @@ getn(s) r = strtol(s, &p, 10); if (errno != 0) - fatalError("%s: out of range\n", s); + error_msg_and_die("%s: out of range", s); while (isspace(*p)) p++; if (*p) - fatalError("%s: bad number\n", s); + error_msg_and_die("%s: bad number", s); return (int) r; } @@ -568,9 +555,7 @@ static void initialize_group_array () { ngroups = getgroups(0, NULL); - if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL) - fatalError("Out of space\n"); - + group_array = xrealloc(group_array, ngroups * sizeof(gid_t)); getgroups(ngroups, group_array); }