summaryrefslogtreecommitdiff
path: root/miscutils/bc.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-12 00:50:23 +0100
committerDenys Vlasenko2018-12-12 00:51:53 +0100
commit16494f557fd742ca484943407888fb8a349c01ee (patch)
tree353f1aeeec49b21fd47c9ff7ca8658e27e555863 /miscutils/bc.c
parent69171dc466ab94daf14e7560efe92c5050b0c1b1 (diff)
downloadbusybox-16494f557fd742ca484943407888fb8a349c01ee.zip
busybox-16494f557fd742ca484943407888fb8a349c01ee.tar.gz
bc: simplify zbc_program_logical()
function old new delta bc_program_exec 3918 3876 -42 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-42) Total: -42 bytes text data bss dec hex filename 982061 485 7296 989842 f1a92 busybox_old 982019 485 7296 989800 f1a68 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r--miscutils/bc.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 791275c..8426998 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -5793,8 +5793,7 @@ static BC_STATUS zbc_program_logical(char inst)
BcStatus s;
BcResult *opd1, *opd2, res;
BcNum *n1, *n2;
- bool cond = 0;
- ssize_t cmp;
+ ssize_t cond;
s = zbc_program_binOpPrep(&opd1, &n1, &opd2, &n2, false);
if (s) RETURN_STATUS(s);
@@ -5806,25 +5805,25 @@ static BC_STATUS zbc_program_logical(char inst)
else if (inst == BC_INST_BOOL_OR)
cond = bc_num_cmp(n1, &G.prog.zero) || bc_num_cmp(n2, &G.prog.zero);
else {
- cmp = bc_num_cmp(n1, n2);
+ cond = bc_num_cmp(n1, n2);
switch (inst) {
case BC_INST_REL_EQ:
- cond = cmp == 0;
+ cond = (cond == 0);
break;
case BC_INST_REL_LE:
- cond = cmp <= 0;
+ cond = (cond <= 0);
break;
case BC_INST_REL_GE:
- cond = cmp >= 0;
- break;
- case BC_INST_REL_NE:
- cond = cmp != 0;
+ cond = (cond >= 0);
break;
case BC_INST_REL_LT:
- cond = cmp < 0;
+ cond = (cond < 0);
break;
case BC_INST_REL_GT:
- cond = cmp > 0;
+ cond = (cond > 0);
+ break;
+ default: // = case BC_INST_REL_NE:
+ //cond = (cond != 0); - not needed
break;
}
}