diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-14 11:10:45 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-14 11:10:45 +0200 |
| commit | 5febdb122357dbe39e236c9e93d06dab328edb45 (patch) | |
| tree | 1ee7a0811c9fa07031479af1f7ae8abb4d403bcf /shell | |
| parent | 46dccd2ec0eafd850b2168d4dfe4e74949fd3424 (diff) | |
| download | busybox-w32-5febdb122357dbe39e236c9e93d06dab328edb45.tar.gz busybox-w32-5febdb122357dbe39e236c9e93d06dab328edb45.tar.bz2 busybox-w32-5febdb122357dbe39e236c9e93d06dab328edb45.zip | |
shell/math: remove now-unused second_val
function old new delta
arith_apply 1137 1134 -3
evaluate_string 1101 1095 -6
arith_lookup_val 150 143 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-16) Total: -16 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/math.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/shell/math.c b/shell/math.c index 2b7a3494f..fa22bc400 100644 --- a/shell/math.c +++ b/shell/math.c | |||
| @@ -246,24 +246,11 @@ is_right_associative(operator prec) | |||
| 246 | 246 | ||
| 247 | typedef struct { | 247 | typedef struct { |
| 248 | arith_t val; | 248 | arith_t val; |
| 249 | /* We acquire second_val only when "expr1 : expr2" part | ||
| 250 | * of ternary ?: op is evaluated. | ||
| 251 | * We treat ?: as two binary ops: (expr ? (expr1 : expr2)). | ||
| 252 | * ':' produces a new value which has two parts, val and second_val; | ||
| 253 | * then '?' selects one of them based on its left side. | ||
| 254 | */ | ||
| 255 | arith_t second_val; | ||
| 256 | #define SECOND_VAL_VALID ((char*)(intptr_t)-1) | ||
| 257 | /* If NULL then it's just a number, if SECOND_VAL_VALID, | ||
| 258 | * it's a result of "expr : expr", else it's a named variable. | ||
| 259 | * (We use SECOND_VAL_VALID instead of a bit flag to keep | ||
| 260 | * var_or_num_t smaller, we allocate a lot of them on stack). | ||
| 261 | */ | ||
| 262 | char *var_name; | 249 | char *var_name; |
| 263 | } var_or_num_t; | 250 | } var_or_num_t; |
| 264 | 251 | ||
| 265 | #define VALID_NAME(name) ((name) && (name) != SECOND_VAL_VALID) | 252 | #define VALID_NAME(name) (name) |
| 266 | #define NOT_NAME(name) (!(name) || (name) == SECOND_VAL_VALID) | 253 | #define NOT_NAME(name) (!(name)) |
| 267 | 254 | ||
| 268 | 255 | ||
| 269 | typedef struct remembered_name { | 256 | typedef struct remembered_name { |
| @@ -854,11 +841,7 @@ evaluate_string(arith_state_t *math_state, const char *expr) | |||
| 854 | errmsg = arith_apply(math_state, prev_op, numstack, &numstackptr); | 841 | errmsg = arith_apply(math_state, prev_op, numstack, &numstackptr); |
| 855 | if (errmsg) | 842 | if (errmsg) |
| 856 | goto err_with_custom_msg; | 843 | goto err_with_custom_msg; |
| 857 | dbg(" numstack:%d val:%lld %lld %p", (int)(numstackptr - numstack), | 844 | dbg(" numstack:%d val:%lld '%s'", (int)(numstackptr - numstack), numstackptr[-1].val, numstackptr[-1].var_name); |
| 858 | numstackptr[-1].val, | ||
| 859 | numstackptr[-1].var_name == SECOND_VAL_VALID ? numstackptr[-1].second_val : 0, | ||
| 860 | numstackptr[-1].var_name | ||
| 861 | ); | ||
| 862 | /* For ternary ?: we need to remove ? from opstack too, not just : */ | 845 | /* For ternary ?: we need to remove ? from opstack too, not just : */ |
| 863 | if (prev_op == TOK_CONDITIONAL_SEP) { | 846 | if (prev_op == TOK_CONDITIONAL_SEP) { |
| 864 | // This is caught in arith_apply() | 847 | // This is caught in arith_apply() |
