diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-14 13:59:11 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-14 13:59:11 +0200 |
commit | 66139330fc09384f2ce95e60ea1f5268badbafc9 (patch) | |
tree | 108626f4abfcc6144f03ae38acaece3ecbd0dfb1 | |
parent | 3df885abe340c5feaed212536139ee24d60e40a2 (diff) | |
download | busybox-w32-66139330fc09384f2ce95e60ea1f5268badbafc9.tar.gz busybox-w32-66139330fc09384f2ce95e60ea1f5268badbafc9.tar.bz2 busybox-w32-66139330fc09384f2ce95e60ea1f5268badbafc9.zip |
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.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/shell/math.c b/shell/math.c index 077aba848..c1bf324f8 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_ | |||
321 | if (op == TOK_CONDITIONAL_SEP) { | 321 | if (op == TOK_CONDITIONAL_SEP) { |
322 | /* "expr1 ? expr2 : expr3" operation */ | 322 | /* "expr1 ? expr2 : expr3" operation */ |
323 | var_or_num_t *expr1 = &top_of_stack[-2]; | 323 | var_or_num_t *expr1 = &top_of_stack[-2]; |
324 | if (expr1 < numstack) { | 324 | NUMPTR = expr1 + 1; |
325 | if (expr1 < numstack) /* Example: $((2:3)) */ | ||
325 | return "malformed ?: operator"; | 326 | return "malformed ?: operator"; |
326 | } | ||
327 | err = arith_lookup_val(math_state, expr1); | 327 | err = arith_lookup_val(math_state, expr1); |
328 | if (err) | 328 | if (err) |
329 | return err; | 329 | return err; |
@@ -332,7 +332,6 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ | |||
332 | err = arith_lookup_val(math_state, top_of_stack); | 332 | err = arith_lookup_val(math_state, top_of_stack); |
333 | if (err) | 333 | if (err) |
334 | return err; | 334 | return err; |
335 | NUMPTR = expr1 + 1; | ||
336 | expr1->val = top_of_stack->val; | 335 | expr1->val = top_of_stack->val; |
337 | expr1->var_name = NULL; | 336 | expr1->var_name = NULL; |
338 | return NULL; | 337 | return NULL; |
@@ -343,7 +342,7 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ | |||
343 | if (PREC(op) < UNARYPREC) { | 342 | if (PREC(op) < UNARYPREC) { |
344 | /* In binops a ~ b, variables are resolved left-to-right, | 343 | /* In binops a ~ b, variables are resolved left-to-right, |
345 | * resolve top_of_stack[-1] _before_ resolving top_of_stack[0] | 344 | * resolve top_of_stack[-1] _before_ resolving top_of_stack[0] |
346 | */ | 345 | */ |
347 | if (top_of_stack == numstack) /* need two arguments */ | 346 | if (top_of_stack == numstack) /* need two arguments */ |
348 | goto syntax_err; | 347 | goto syntax_err; |
349 | /* Unless it is =, resolve top_of_stack[-1] name to value */ | 348 | /* Unless it is =, resolve top_of_stack[-1] name to value */ |