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
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-15 18:16:46 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-15 18:16:46 +0300
commitf8263528cd44ac5dc95778556c6fd3feea14742e (patch)
tree875ed4a7ef967f5fed11e2955b0bcf8e70f20a54 /shell
parent38f423cc9c6419f86e8ab602f195a9035a879001 (diff)
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>
Diffstat (limited to 'shell')
-rw-r--r--shell/math.c8
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_
rez++;
else if (op == TOK_POST_DEC || op == TOK_PRE_DEC)
rez--;
- else if (op != TOK_UPLUS) {
+ else /*if (op != TOK_UPLUS) - always true, we drop TOK_UPLUS earlier */ {
/* Binary operators */
arith_t right_side_val;
@@ -770,8 +770,10 @@ evaluate_string(arith_state_t *math_state, const char *expr)
if (lasttok != TOK_NUM) {
switch (op) {
case TOK_ADD:
- op = TOK_UPLUS;
- break;
+ //op = TOK_UPLUS;
+ //break;
+ /* Unary plus does nothing, do not even push it to opstack */
+ continue;
case TOK_SUB:
op = TOK_UMINUS;
break;