diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-15 17:16:46 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-15 17:16:46 +0200 |
commit | f8263528cd44ac5dc95778556c6fd3feea14742e (patch) | |
tree | 875ed4a7ef967f5fed11e2955b0bcf8e70f20a54 | |
parent | 38f423cc9c6419f86e8ab602f195a9035a879001 (diff) | |
download | busybox-w32-f8263528cd44ac5dc95778556c6fd3feea14742e.tar.gz busybox-w32-f8263528cd44ac5dc95778556c6fd3feea14742e.tar.bz2 busybox-w32-f8263528cd44ac5dc95778556c6fd3feea14742e.zip |
shell/math: simplify handling of unary plus
function old new delta
evaluate_string 1257 1271 +14
arith_apply 977 968 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-9) Total: 5 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/math.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/shell/math.c b/shell/math.c index 4623c979e..a398bcb98 100644 --- a/shell/math.c +++ b/shell/math.c | |||
@@ -345,7 +345,7 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_ | |||
345 | rez++; | 345 | rez++; |
346 | else if (op == TOK_POST_DEC || op == TOK_PRE_DEC) | 346 | else if (op == TOK_POST_DEC || op == TOK_PRE_DEC) |
347 | rez--; | 347 | rez--; |
348 | else if (op != TOK_UPLUS) { | 348 | else /*if (op != TOK_UPLUS) - always true, we drop TOK_UPLUS earlier */ { |
349 | /* Binary operators */ | 349 | /* Binary operators */ |
350 | arith_t right_side_val; | 350 | arith_t right_side_val; |
351 | 351 | ||
@@ -770,8 +770,10 @@ evaluate_string(arith_state_t *math_state, const char *expr) | |||
770 | if (lasttok != TOK_NUM) { | 770 | if (lasttok != TOK_NUM) { |
771 | switch (op) { | 771 | switch (op) { |
772 | case TOK_ADD: | 772 | case TOK_ADD: |
773 | op = TOK_UPLUS; | 773 | //op = TOK_UPLUS; |
774 | break; | 774 | //break; |
775 | /* Unary plus does nothing, do not even push it to opstack */ | ||
776 | continue; | ||
775 | case TOK_SUB: | 777 | case TOK_SUB: |
776 | op = TOK_UMINUS; | 778 | op = TOK_UMINUS; |
777 | break; | 779 | break; |