# HG changeset patch # User Aidan Kehoe # Date 1431098697 -3600 # Node ID 85fd1ab80057f5f1bcf8d04852d1e3b797782568 # Parent ee27ca517e9070423b5a0423dd38061e694d266c Fix a bug in #'parse-integer with negative bignums and non-nil JUNK-ALLOWED src/ChangeLog addition: 2015-05-08 Aidan Kehoe * data.c (parse_integer): Fix a bug here with the interaction of negative bignums and a non-zero JUNK-ALLOWED argument. tests/ChangeLog addition: 2015-05-08 Aidan Kehoe * automated/lisp-tests.el: Check for a bug just fixed with the interaction of negative bignums and :junk-allowed non-nil. diff -r ee27ca517e90 -r 85fd1ab80057 src/ChangeLog --- a/src/ChangeLog Fri May 08 14:33:46 2015 +0100 +++ b/src/ChangeLog Fri May 08 16:24:57 2015 +0100 @@ -1,3 +1,9 @@ +2015-05-08 Aidan Kehoe + + * data.c (parse_integer): + Fix a bug here with the interaction of negative bignums and a + non-zero JUNK-ALLOWED argument. + 2015-05-08 Aidan Kehoe * print.c (print_symbol): diff -r ee27ca517e90 -r 85fd1ab80057 src/data.c --- a/src/data.c Fri May 08 14:33:46 2015 +0100 +++ b/src/data.c Fri May 08 16:24:57 2015 +0100 @@ -1899,7 +1899,13 @@ if (!NILP (result)) { /* Bignum terminated by whitespace or by non-digit. */ - return Fcanonicalize_number (result); + if (negativland) + { + bignum_set_long (scratch_bignum, -1L); + bignum_mul (XBIGNUM_DATA (result), XBIGNUM_DATA (result), + scratch_bignum); + } + return result; } #endif diff -r ee27ca517e90 -r 85fd1ab80057 tests/ChangeLog --- a/tests/ChangeLog Fri May 08 14:33:46 2015 +0100 +++ b/tests/ChangeLog Fri May 08 16:24:57 2015 +0100 @@ -1,3 +1,9 @@ +2015-05-08 Aidan Kehoe + + * automated/lisp-tests.el: + Check for a bug just fixed with the interaction of negative + bignums and :junk-allowed non-nil. + 2015-05-08 Aidan Kehoe * automated/lisp-reader-tests.el: diff -r ee27ca517e90 -r 85fd1ab80057 tests/automated/lisp-tests.el --- a/tests/automated/lisp-tests.el Fri May 08 14:33:46 2015 +0100 +++ b/tests/automated/lisp-tests.el Fri May 08 16:24:57 2015 +0100 @@ -3612,8 +3612,15 @@ "checking an overflow bug has been fixed") (Assert (eql (ignore-errors (parse-integer "-100000000" :radix 16)) - (if (featurep 'bignum) (- (lsh 1 32) nil)) + (if (featurep 'bignum) (- (lsh 1 32)) nil)) "checking an overflow bug has been fixed, negative int") + (Assert (eql (ignore-errors (parse-integer + (format "%d4/" most-negative-fixnum) + :junk-allowed t)) + (if (featurep 'bignum) + (- (* most-negative-fixnum 10) 4) + nil)) + "checking a bug with :junk-allowed, negative bignum") (Check-Error invalid-argument (parse-integer "0123456789" :radix 8)) (Check-Error invalid-argument (parse-integer "abc"))