diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-02 20:24:09 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-02 20:24:09 +0000 |
commit | a7f4e4bbd8d7a47a49404d28bc07ab3b5dc1c19b (patch) | |
tree | 3ec79d4f425e7a5977cb54d0bf83e3eb615fa786 /testsuite/expr | |
parent | 2e4c3c4cc3c2f6bdd3bfbafe9980f46b24971009 (diff) | |
download | busybox-w32-a7f4e4bbd8d7a47a49404d28bc07ab3b5dc1c19b.tar.gz busybox-w32-a7f4e4bbd8d7a47a49404d28bc07ab3b5dc1c19b.tar.bz2 busybox-w32-a7f4e4bbd8d7a47a49404d28bc07ab3b5dc1c19b.zip |
expr: fix comparisons 'a < b' where we were overflowing a-b
(not to mention that we used int, not arith_t). closes bug 2744.
Also, shrink a bit and add testsuite entry
function old new delta
nextarg 75 84 +9
tostring 38 35 -3
toarith 89 86 -3
str_value 35 32 -3
eval6 555 552 -3
int_value 29 23 -6
eval4 128 120 -8
eval3 112 104 -8
eval2 512 417 -95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/8 up/down: 9/-129) Total: -120 bytes
Diffstat (limited to 'testsuite/expr')
-rw-r--r-- | testsuite/expr/expr-big | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/testsuite/expr/expr-big b/testsuite/expr/expr-big new file mode 100644 index 000000000..23dbbb3c8 --- /dev/null +++ b/testsuite/expr/expr-big | |||
@@ -0,0 +1,16 @@ | |||
1 | # busybox expr | ||
2 | |||
3 | # 3*1000*1000*1000 overflows 32-bit signed int | ||
4 | res=`busybox expr 0 '<' 3000000000` | ||
5 | [ x"$res" = x1 ] || exit 1 | ||
6 | |||
7 | # 9223372036854775807 = 2^31-1 | ||
8 | res=`busybox expr 0 '<' 9223372036854775807` | ||
9 | [ x"$res" = x1 ] || exit 1 | ||
10 | # coreutils fails this one! | ||
11 | res=`busybox expr -9223372036854775800 '<' 9223372036854775807` | ||
12 | [ x"$res" = x1 ] || exit 1 | ||
13 | |||
14 | # This one works only by chance | ||
15 | # res=`busybox expr 0 '<' 9223372036854775808` | ||
16 | # [ x"$res" = x1 ] || exit 1 | ||