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 12:19:15 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-15 12:22:13 +0300
commit61a4959251667751e424e600c6cb75de39d6b1c3 (patch)
tree3207a4f46eeac1db063c7b0edd0181661e781d3f /shell
parent5f56a0388271d2de6cf31af1041bdcb3d11029fc (diff)
shell/math: remove special code to handle a?b?c:d:e, it works without it now
The "hack" to virtually parenthesize ? EXPR : made this unnecessary. The expression is effectively a?(b?(c):d):e and thus b?c:d is evaluated before continuing with the second : function old new delta evaluate_string 1148 1132 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash_test/ash-arith/arith-ternary_nested2.right1
-rwxr-xr-xshell/ash_test/ash-arith/arith-ternary_nested2.tests2
-rw-r--r--shell/hush_test/hush-arith/arith-ternary_nested2.right1
-rwxr-xr-xshell/hush_test/hush-arith/arith-ternary_nested2.tests2
-rw-r--r--shell/math.c12
5 files changed, 9 insertions, 9 deletions
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested2.right b/shell/ash_test/ash-arith/arith-ternary_nested2.right
new file mode 100644
index 000000000..d80319695
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary_nested2.right
@@ -0,0 +1 @@
+3:3
diff --git a/shell/ash_test/ash-arith/arith-ternary_nested2.tests b/shell/ash_test/ash-arith/arith-ternary_nested2.tests
new file mode 100755
index 000000000..e8b8a9e1a
--- /dev/null
+++ b/shell/ash_test/ash-arith/arith-ternary_nested2.tests
@@ -0,0 +1,2 @@
+exec 2>&1
+echo 3:$((0?1:2?3:4?5:6?7:8))
diff --git a/shell/hush_test/hush-arith/arith-ternary_nested2.right b/shell/hush_test/hush-arith/arith-ternary_nested2.right
new file mode 100644
index 000000000..d80319695
--- /dev/null
+++ b/shell/hush_test/hush-arith/arith-ternary_nested2.right
@@ -0,0 +1 @@
+3:3
diff --git a/shell/hush_test/hush-arith/arith-ternary_nested2.tests b/shell/hush_test/hush-arith/arith-ternary_nested2.tests
new file mode 100755
index 000000000..e8b8a9e1a
--- /dev/null
+++ b/shell/hush_test/hush-arith/arith-ternary_nested2.tests
@@ -0,0 +1,2 @@
+exec 2>&1
+echo 3:$((0?1:2?3:4?5:6?7:8))
diff --git a/shell/math.c b/shell/math.c
index f6aa02ac2..8d0c9dea7 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -840,15 +840,9 @@ evaluate_string(arith_state_t *math_state, const char *expr)
if (prev_prec < prec
|| (prev_prec == prec && is_right_associative(prec))
) {
- /* Unless a?b?c:d:... and we are at the second : */
- if (op != TOK_CONDITIONAL_SEP
- || prev_op != TOK_CONDITIONAL_SEP
- ) {
- /* ...x~y@: push @ on opstack */
- opstackptr++; /* undo removal of ~ op */
- goto push_op;
- }
- /* else: a?b?c:d:. Evaluate b?c:d, replace it on stack with result. Then repeat */
+ /* ...x~y@: push @ on opstack */
+ opstackptr++; /* undo removal of ~ op */
+ goto push_op;
}
/* else: ...x~y@. Evaluate x~y, replace it on stack with result. Then repeat */
}