summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2009-06-13 22:49:08 +0200
committerDenys Vlasenko2009-06-13 22:49:08 +0200
commit16635cc2e052897ce7c2d4989acd0b706c3ac3dd (patch)
tree35af25c96f7f6e6340c043a91b10f46593c6afce /coreutils
parenta3dcee3e8a2d41e90cc235fd407dff9fe99d8604 (diff)
downloadbusybox-16635cc2e052897ce7c2d4989acd0b706c3ac3dd.zip
busybox-16635cc2e052897ce7c2d4989acd0b706c3ac3dd.tar.gz
test, tcpsvd, tcpsvd: shrink
function old new delta nexpr 825 826 +1 tcpudpsvd_main 1830 1822 -8 test_main 257 247 -10 binop 584 525 -59 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-77) Total: -76 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/test.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index ae40192..cfaf4ca 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -51,39 +51,49 @@
enum token {
EOI,
- FILRD,
+
+ FILRD, /* file access */
FILWR,
FILEX,
+
FILEXIST,
- FILREG,
+
+ FILREG, /* file type */
FILDIR,
FILCDEV,
FILBDEV,
FILFIFO,
FILSOCK,
+
FILSYM,
FILGZ,
FILTT,
- FILSUID,
+
+ FILSUID, /* file bit */
FILSGID,
FILSTCK,
- FILNT,
+
+ FILNT, /* file ops */
FILOT,
FILEQ,
+
FILUID,
FILGID,
- STREZ,
+
+ STREZ, /* str ops */
STRNZ,
STREQ,
STRNE,
STRLT,
STRGT,
- INTEQ,
+
+ INTEQ, /* int ops */
INTNE,
INTGE,
INTGT,
INTLE,
INTLT,
+
UNOT,
BAND,
BOR,
@@ -385,8 +395,8 @@ static int binop(void)
return val1 > val2;
if (op->op_num == INTLE)
return val1 <= val2;
- if (op->op_num == INTLT)
- return val1 < val2;
+ /*if (op->op_num == INTLT)*/
+ return val1 < val2;
}
if (is_str_op(op->op_num)) {
val1 = strcmp(opnd1, opnd2);
@@ -396,8 +406,8 @@ static int binop(void)
return val1 != 0;
if (op->op_num == STRLT)
return val1 < 0;
- if (op->op_num == STRGT)
- return val1 > 0;
+ /*if (op->op_num == STRGT)*/
+ return val1 > 0;
}
/* We are sure that these three are by now the only binops we didn't check
* yet, so we do not check if the class is correct:
@@ -412,25 +422,29 @@ static int binop(void)
return b1.st_mtime > b2.st_mtime;
if (op->op_num == FILOT)
return b1.st_mtime < b2.st_mtime;
- if (op->op_num == FILEQ)
- return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
+ /*if (op->op_num == FILEQ)*/
+ return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
}
- return 1; /* NOTREACHED */
+ /*return 1; - NOTREACHED */
}
static void initialize_group_array(void)
{
- ngroups = getgroups(0, NULL);
- if (ngroups > 0) {
+ int n;
+
+ /* getgroups may be expensive, try to use it only once */
+ ngroups = 32;
+ do {
/* FIXME: ash tries so hard to not die on OOM,
* and we spoil it with just one xrealloc here */
/* We realloc, because test_main can be entered repeatedly by shell.
* Testcase (ash): 'while true; do test -x some_file; done'
* and watch top. (some_file must have owner != you) */
- group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
- getgroups(ngroups, group_array);
- }
+ n = ngroups;
+ group_array = xrealloc(group_array, n * sizeof(gid_t));
+ ngroups = getgroups(n, group_array);
+ } while (ngroups > n);
}
@@ -717,7 +731,7 @@ int test_main(int argc, char **argv)
* isn't likely in the case of a shell. paranoia
* prevails...
*/
- ngroups = 0;
+ /*ngroups = 0; - done by INIT_S() */
//argc--;
argv++;