aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-21 13:35:52 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-21 13:35:52 +0000
commitb304eadca8c551672d07a12c08b2f92456819187 (patch)
tree12bfc1411df6e262738f9a9ff04afe91c5505528
parentd67a6064893a6d9f36539a66ba897840b811f219 (diff)
downloadbusybox-w32-b304eadca8c551672d07a12c08b2f92456819187.tar.gz
busybox-w32-b304eadca8c551672d07a12c08b2f92456819187.tar.bz2
busybox-w32-b304eadca8c551672d07a12c08b2f92456819187.zip
test: shrink a bit
function old new delta test_main 5 434 +429 bb_test 473 - -473 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 429/-473) Total: -44 bytes text data bss dec hex filename 735073 3028 14408 752509 b7b7d busybox_old 735029 3028 14408 752465 b7b51 busybox_unstripped
-rw-r--r--coreutils/test.c23
-rw-r--r--include/libbb.h2
-rw-r--r--shell/ash.c2
3 files changed, 8 insertions, 19 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index 3796e2cd2..5ca46725b 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -155,7 +155,7 @@ typedef int arith_t;
155#endif 155#endif
156 156
157/* Cannot eliminate these static data (do the G trick) 157/* Cannot eliminate these static data (do the G trick)
158 * because of bb_test usage from other applets */ 158 * because of test_main usage from other applets */
159static char **t_wp; 159static char **t_wp;
160static struct t_op const *t_wp_op; 160static struct t_op const *t_wp_op;
161static gid_t *group_array; 161static gid_t *group_array;
@@ -179,7 +179,7 @@ static int test_eaccess(char *path, int mode);
179static int is_a_group_member(gid_t gid); 179static int is_a_group_member(gid_t gid);
180static void initialize_group_array(void); 180static void initialize_group_array(void);
181 181
182int bb_test(int argc, char **argv) 182int test_main(int argc, char **argv)
183{ 183{
184 int res; 184 int res;
185 char *arg0; 185 char *arg0;
@@ -188,21 +188,19 @@ int bb_test(int argc, char **argv)
188 arg0 = strrchr(argv[0], '/'); 188 arg0 = strrchr(argv[0], '/');
189 if (!arg0++) arg0 = argv[0]; 189 if (!arg0++) arg0 = argv[0];
190 if (arg0[0] == '[') { 190 if (arg0[0] == '[') {
191 --argc;
191 if (!arg0[1]) { /* "[" ? */ 192 if (!arg0[1]) { /* "[" ? */
192 --argc;
193 if (NOT_LONE_CHAR(argv[argc], ']')) { 193 if (NOT_LONE_CHAR(argv[argc], ']')) {
194 bb_error_msg("missing ]"); 194 bb_error_msg("missing ]");
195 return 2; 195 return 2;
196 } 196 }
197 argv[argc] = NULL; 197 } else { /* assuming "[[" */
198 } else if (LONE_CHAR(arg0+1, '[') == 0) { /* "[[" ? */
199 --argc;
200 if (strcmp(argv[argc], "]]") != 0) { 198 if (strcmp(argv[argc], "]]") != 0) {
201 bb_error_msg("missing ]]"); 199 bb_error_msg("missing ]]");
202 return 2; 200 return 2;
203 } 201 }
204 argv[argc] = NULL;
205 } 202 }
203 argv[argc] = NULL;
206 } 204 }
207 205
208 res = setjmp(leaving); 206 res = setjmp(leaving);
@@ -571,7 +569,7 @@ static void initialize_group_array(void)
571 if (ngroups > 0) { 569 if (ngroups > 0) {
572 /* FIXME: ash tries so hard to not die on OOM, 570 /* FIXME: ash tries so hard to not die on OOM,
573 * and we spoil it with just one xrealloc here */ 571 * and we spoil it with just one xrealloc here */
574 /* We realloc, because bb_test can be entered repeatedly by shell. 572 /* We realloc, because test_main can be entered repeatedly by shell.
575 * Testcase (ash): 'while true; do test -x some_file; done' 573 * Testcase (ash): 'while true; do test -x some_file; done'
576 * and watch top. (some_file must have owner != you) */ 574 * and watch top. (some_file must have owner != you) */
577 group_array = xrealloc(group_array, ngroups * sizeof(gid_t)); 575 group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
@@ -601,12 +599,3 @@ static int is_a_group_member(gid_t gid)
601 599
602 return 0; 600 return 0;
603} 601}
604
605
606/* applet entry point */
607
608int test_main(int argc, char **argv);
609int test_main(int argc, char **argv)
610{
611 return bb_test(argc, argv);
612}
diff --git a/include/libbb.h b/include/libbb.h
index 9ca565348..b7b0657b6 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -653,7 +653,7 @@ extern void bb_vinfo_msg(const char *s, va_list p);
653/* applets which are useful from another applets */ 653/* applets which are useful from another applets */
654int bb_cat(char** argv); 654int bb_cat(char** argv);
655int bb_echo(char** argv); 655int bb_echo(char** argv);
656int bb_test(int argc, char** argv); 656int test_main(int argc, char** argv);
657int kill_main(int argc, char **argv); 657int kill_main(int argc, char **argv);
658#if ENABLE_ROUTE 658#if ENABLE_ROUTE
659void bb_displayroutes(int noresolve, int netstatfmt); 659void bb_displayroutes(int noresolve, int netstatfmt);
diff --git a/shell/ash.c b/shell/ash.c
index 35eec42a7..b54f66609 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10985,7 +10985,7 @@ echocmd(int argc, char **argv)
10985static int 10985static int
10986testcmd(int argc, char **argv) 10986testcmd(int argc, char **argv)
10987{ 10987{
10988 return bb_test(argc, argv); 10988 return test_main(argc, argv);
10989} 10989}
10990#endif 10990#endif
10991 10991