changeset 5905:85fd1ab80057

Fix a bug in #'parse-integer with negative bignums and non-nil JUNK-ALLOWED src/ChangeLog addition: 2015-05-08 Aidan Kehoe <kehoea@parhasard.net> * 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 <kehoea@parhasard.net> * automated/lisp-tests.el: Check for a bug just fixed with the interaction of negative bignums and :junk-allowed non-nil.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 08 May 2015 16:24:57 +0100
parents ee27ca517e90
children 4d5a5a80aba2
files src/ChangeLog src/data.c tests/ChangeLog tests/automated/lisp-tests.el
diffstat 4 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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  <kehoea@parhasard.net>
+
+	* 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  <kehoea@parhasard.net>
 
 	* print.c (print_symbol):
--- 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
 
--- 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  <kehoea@parhasard.net>
+
+	* 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  <kehoea@parhasard.net>
 
 	* automated/lisp-reader-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"))