summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2023-06-14 13:59:11 +0200
committerDenys Vlasenko2023-06-14 13:59:11 +0200
commit66139330fc09384f2ce95e60ea1f5268badbafc9 (patch)
tree108626f4abfcc6144f03ae38acaece3ecbd0dfb1
parent3df885abe340c5feaed212536139ee24d60e40a2 (diff)
downloadbusybox-66139330fc09384f2ce95e60ea1f5268badbafc9.zip
busybox-66139330fc09384f2ce95e60ea1f5268badbafc9.tar.gz
shell/math: trivial code shrink
function old new delta arith_apply 1143 1132 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/math.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/shell/math.c b/shell/math.c
index 077aba8..c1bf324 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -321,9 +321,9 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
if (op == TOK_CONDITIONAL_SEP) {
/* "expr1 ? expr2 : expr3" operation */
var_or_num_t *expr1 = &top_of_stack[-2];
- if (expr1 < numstack) {
+ NUMPTR = expr1 + 1;
+ if (expr1 < numstack) /* Example: $((2:3)) */
return "malformed ?: operator";
- }
err = arith_lookup_val(math_state, expr1);
if (err)
return err;
@@ -332,7 +332,6 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
err = arith_lookup_val(math_state, top_of_stack);
if (err)
return err;
- NUMPTR = expr1 + 1;
expr1->val = top_of_stack->val;
expr1->var_name = NULL;
return NULL;
@@ -343,7 +342,7 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
if (PREC(op) < UNARYPREC) {
/* In binops a ~ b, variables are resolved left-to-right,
* resolve top_of_stack[-1] _before_ resolving top_of_stack[0]
- */
+ */
if (top_of_stack == numstack) /* need two arguments */
goto syntax_err;
/* Unless it is =, resolve top_of_stack[-1] name to value */