Use 64 bit comparisons.

This commit is contained in:
Rob Landley 2023-09-07 03:48:54 -05:00
parent 0c13db5030
commit 251be88968
2 changed files with 4 additions and 6 deletions

View File

@ -18,6 +18,7 @@ testing "% * same priority" "expr 3 % 2 \* 4" "4\n" "" ""
testing "* % same priority" "expr 3 \* 2 % 4" "2\n" "" ""
testing "= > same priority" "expr 0 = 2 \> 3" "0\n" "" ""
testing "> = same priority" "expr 3 \> 2 = 1" "1\n" "" ""
testing "64 bit comparison" "expr 100000000000 \> 1" "1\n" "" ""
testing "00 | 1" "expr 00 \| 1" "1\n" "" ""
testing "-0 | 1" "expr -0 \| 2" "2\n" "" ""
@ -31,8 +32,7 @@ testing "regex no match" "expr ab21xx : x" "0\n" "" ""
testing "long str" "expr abcdefghijklmnopqrstuvwxyz : '\(.*\)' = a" "0\n" "" ""
# result of ':' regex match can subsequently be used for arithmetic
testing "string becomes integer" "expr ab21xx : '[^0-9]*\([0-9]*\)' + 3" \
"24\n" "" ""
testing "str becomes int" "expr ab21xx : '[^0-9]*\([0-9]*\)' + 3" "24\n" "" ""
testing "integer comparison" "expr -3 \< -2" "1\n" "" ""
testing "string comparison" "expr -3 \< -2s" "0\n" "" ""
@ -44,8 +44,7 @@ testing "parens around literal" "expr \( a \)" "a\n" "" ""
testing "exit code when true" "expr a; echo \$?" "a\n0\n" "" ""
testing "exit code when false" "expr 0; echo \$?" "0\n1\n" "" ""
testing "exit code with syntax error" "expr \( 2>/dev/null; echo \$?" \
"2\n" "" ""
testing "exit code with syntax err" "expr \( 2>/dev/null; echo \$?" "2\n" "" ""
testing "exit code when evaluating to 0" "expr -1 + 1; echo \$?" "0\n1\n" "" ""
# BUG: segfaults because '3' is coerced to integer and regexc gets NULL

View File

@ -146,9 +146,8 @@ static struct op_def {
void eval_op(struct op_def *o, struct value *ret, struct value *rhs)
{
long long a, b, x = 0; // x = a OP b for ints.
long long cmp, a, b, x = 0; // x = a OP b for ints.
char *s, *t; // string operands
int cmp;
switch (o->sig) {