summaryrefslogtreecommitdiff
path: root/coreutils/test.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-12-21 13:23:14 +0000
committerDenis Vlasenko2006-12-21 13:23:14 +0000
commitbf66fbc8e2380717c1fab860cfc60c78582839dd (patch)
tree3ab3dd4df901851ff7f4345708592118766ba4aa /coreutils/test.c
parent6910741067913d131d931b1e6424d3b8ed43e64f (diff)
downloadbusybox-bf66fbc8e2380717c1fab860cfc60c78582839dd.zip
busybox-bf66fbc8e2380717c1fab860cfc60c78582839dd.tar.gz
introduce LONE_CHAR (optimized strcmp with one-char string)
Diffstat (limited to 'coreutils/test.c')
-rw-r--r--coreutils/test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index ebb4f90..d3d7604 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -175,14 +175,16 @@ int bb_test(int argc, char **argv)
{
int res;
- if (strcmp(argv[0], "[") == 0) {
- if (strcmp(argv[--argc], "]")) {
+ if (LONE_CHAR(argv[0], '[')) {
+ --argc;
+ if (NOT_LONE_CHAR(argv[argc], ']')) {
bb_error_msg("missing ]");
return 2;
}
argv[argc] = NULL;
} else if (strcmp(argv[0], "[[") == 0) {
- if (strcmp(argv[--argc], "]]")) {
+ --argc;
+ if (strcmp(argv[argc], "]]")) {
bb_error_msg("missing ]]");
return 2;
}
@@ -578,6 +580,6 @@ static int is_a_group_member(gid_t gid)
int test_main(int argc, char **argv)
{
- exit(bb_test(argc, argv));
+ return bb_test(argc, argv);
}