diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-18 19:13:22 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-18 19:20:10 +0200 |
commit | 7701b526a720c4a84839174fe6b084d831ac90c9 (patch) | |
tree | 036ff61cd36dfdda567223fc627c82987d89a85e | |
parent | 8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9 (diff) | |
download | busybox-w32-7701b526a720c4a84839174fe6b084d831ac90c9.tar.gz busybox-w32-7701b526a720c4a84839174fe6b084d831ac90c9.tar.bz2 busybox-w32-7701b526a720c4a84839174fe6b084d831ac90c9.zip |
shell/math: code shrink
function old new delta
evaluate_string 1498 1491 -7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/math.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/shell/math.c b/shell/math.c index cb702b7f4..6784eeeb0 100644 --- a/shell/math.c +++ b/shell/math.c | |||
@@ -363,7 +363,6 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ | |||
363 | 363 | ||
364 | /* Pop numstack */ | 364 | /* Pop numstack */ |
365 | NUMSTACKPTR = top_of_stack; /* this decrements NUMSTACKPTR */ | 365 | NUMSTACKPTR = top_of_stack; /* this decrements NUMSTACKPTR */ |
366 | top_of_stack--; /* now points to left side */ | ||
367 | 366 | ||
368 | if (math_state->evaluation_disabled) { | 367 | if (math_state->evaluation_disabled) { |
369 | dbg("binary op %02x skipped", op); | 368 | dbg("binary op %02x skipped", op); |
@@ -375,6 +374,7 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ | |||
375 | */ | 374 | */ |
376 | } | 375 | } |
377 | 376 | ||
377 | top_of_stack--; /* now points to left side */ | ||
378 | right_side_val = rez; | 378 | right_side_val = rez; |
379 | rez = top_of_stack->val; | 379 | rez = top_of_stack->val; |
380 | if (op == TOK_BOR || op == TOK_OR_ASSIGN) | 380 | if (op == TOK_BOR || op == TOK_OR_ASSIGN) |
@@ -703,9 +703,12 @@ evaluate_string(arith_state_t *math_state, const char *expr) | |||
703 | 703 | ||
704 | if (isdigit(*expr)) { | 704 | if (isdigit(*expr)) { |
705 | /* Number */ | 705 | /* Number */ |
706 | char *end; | ||
706 | numstackptr->var_name = NULL; | 707 | numstackptr->var_name = NULL; |
707 | errno = 0; | 708 | errno = 0; |
708 | numstackptr->val = strto_arith_t(expr, (char**) &expr); | 709 | end = (char*) expr; /* separate variable to go on stack */ |
710 | numstackptr->val = strto_arith_t(expr, &end); | ||
711 | expr = end; | ||
709 | dbg("[%d] val:%lld", (int)(numstackptr - numstack), numstackptr->val); | 712 | dbg("[%d] val:%lld", (int)(numstackptr - numstack), numstackptr->val); |
710 | /* A number can't be followed by another number, or a variable name. | 713 | /* A number can't be followed by another number, or a variable name. |
711 | * We'd catch this later anyway, but this would require numstack[] | 714 | * We'd catch this later anyway, but this would require numstack[] |