Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-18 20:13:22 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-18 20:20:10 +0300
commit7701b526a720c4a84839174fe6b084d831ac90c9 (patch)
tree036ff61cd36dfdda567223fc627c82987d89a85e
parent8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9 (diff)
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.c7
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_
/* Pop numstack */
NUMSTACKPTR = top_of_stack; /* this decrements NUMSTACKPTR */
- top_of_stack--; /* now points to left side */
if (math_state->evaluation_disabled) {
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_
*/
}
+ top_of_stack--; /* now points to left side */
right_side_val = rez;
rez = top_of_stack->val;
if (op == TOK_BOR || op == TOK_OR_ASSIGN)
@@ -703,9 +703,12 @@ evaluate_string(arith_state_t *math_state, const char *expr)
if (isdigit(*expr)) {
/* Number */
+ char *end;
numstackptr->var_name = NULL;
errno = 0;
- numstackptr->val = strto_arith_t(expr, (char**) &expr);
+ end = (char*) expr; /* separate variable to go on stack */
+ numstackptr->val = strto_arith_t(expr, &end);
+ expr = end;
dbg("[%d] val:%lld", (int)(numstackptr - numstack), numstackptr->val);
/* A number can't be followed by another number, or a variable name.
* We'd catch this later anyway, but this would require numstack[]