Fix an edge case when parsing large numbers which resulted in inconsistent
results between an expression that refers to a variable by name and the same expression that includes the same variable by value. Submitted by: se@ MFC after: 1 week
This commit is contained in:
parent
10731c54b6
commit
a96301b673
@ -59,8 +59,7 @@
|
||||
*/
|
||||
typedef intmax_t arith_t;
|
||||
#define ARITH_FORMAT_STR "%" PRIdMAX
|
||||
#define atoarith_t(arg) strtoimax(arg, NULL, 0)
|
||||
#define strtoarith_t(nptr, endptr, base) strtoimax(nptr, endptr, base)
|
||||
#define strtoarith_t(nptr, endptr, base) (intmax_t)strtoumax(nptr, endptr, base)
|
||||
#define ARITH_MIN INTMAX_MIN
|
||||
#define ARITH_MAX INTMAX_MAX
|
||||
|
||||
|
@ -21,6 +21,7 @@ ${PACKAGE}FILES+= arith11.0
|
||||
${PACKAGE}FILES+= arith12.0
|
||||
${PACKAGE}FILES+= arith13.0
|
||||
${PACKAGE}FILES+= arith14.0
|
||||
${PACKAGE}FILES+= arith15.0
|
||||
${PACKAGE}FILES+= assign1.0
|
||||
${PACKAGE}FILES+= cmdsubst1.0
|
||||
${PACKAGE}FILES+= cmdsubst2.0
|
||||
|
20
bin/sh/tests/expansion/arith15.0
Normal file
20
bin/sh/tests/expansion/arith15.0
Normal file
@ -0,0 +1,20 @@
|
||||
# $FreeBSD$
|
||||
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
if [ $(($1)) != $2 ]; then
|
||||
failures=$((failures+1))
|
||||
echo "For $1, expected $2 actual $(($1))"
|
||||
fi
|
||||
}
|
||||
|
||||
XXX=-9223372036854775808
|
||||
check "XXX" -9223372036854775808
|
||||
check "XXX - 1" 9223372036854775807
|
||||
check $(($XXX - 1)) 9223372036854775807
|
||||
check $(($XXX - 2)) 9223372036854775806
|
||||
check $((0x8000000000000000 == 0x7fffffffffffffff)) \
|
||||
0
|
||||
|
||||
exit $((failures != 0))
|
Loading…
Reference in New Issue
Block a user