← Commit list

66139330f

Denys Vlasenko
Denys Vlasenko
2023-06-14
SUCCESS Duration: 153s

Subject

shell/math: trivial code shrink

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/math.c+3 -4
@@ -321,9 +321,9 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
if (op == TOK_CONDITIONAL_SEP) {
/* "expr1 ? expr2 : expr3" operation */
var_or_num_t *expr1 = &top_of_stack[-2];
- if (expr1 < numstack) {
+ NUMPTR = expr1 + 1;
+ if (expr1 < numstack) /* Example: $((2:3)) */
return "malformed ?: operator";
- }
err = arith_lookup_val(math_state, expr1);
if (err)
return err;
@@ -332,7 +332,6 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
err = arith_lookup_val(math_state, top_of_stack);
if (err)
return err;
- NUMPTR = expr1 + 1;
expr1->val = top_of_stack->val;
expr1->var_name = NULL;
return NULL;
@@ -343,7 +342,7 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
if (PREC(op) < UNARYPREC) {
/* In binops a ~ b, variables are resolved left-to-right,
* resolve top_of_stack[-1] _before_ resolving top_of_stack[0]
- */
+ */
if (top_of_stack == numstack) /* need two arguments */
goto syntax_err;
/* Unless it is =, resolve top_of_stack[-1] name to value */