changeset 5489:159face738c3

Never pass a leading + to mpz_set_string, parse_integer (). src/ChangeLog addition: 2011-05-01 Aidan Kehoe <kehoea@parhasard.net> * lread.c (parse_integer): GMP's mpz_set_string deals with a leading plus badly, make sure it never sees one coming from this function. tests/ChangeLog addition: 2011-05-01 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-reader-tests.el: If the bignum feature is available, check that a leading plus sign is treated correctly when reading bignum integers.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 01 May 2011 13:51:33 +0100
parents 1e544fd7be12
children 8861440b1aa4
files src/ChangeLog src/lread.c tests/ChangeLog tests/automated/lisp-reader-tests.el
diffstat 4 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Apr 30 17:38:35 2011 +0200
+++ b/src/ChangeLog	Sun May 01 13:51:33 2011 +0100
@@ -1,3 +1,9 @@
+2011-05-01  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* lread.c (parse_integer):
+	GMP's mpz_set_string deals with a leading plus badly, make sure it
+	never sees one coming from this function.
+
 2010-12-31  Mike Kupfer  <mike.kupfer@xemacs.org>
 
 	* redisplay.c (pixel_to_glyph_translation):
--- a/src/lread.c	Sat Apr 30 17:38:35 2011 +0200
+++ b/src/lread.c	Sun May 01 13:51:33 2011 +0100
@@ -2028,6 +2028,9 @@
   else if (*p == '+')
     {
       p++;
+      /* GMP deals with a leading plus sign, badly, make sure it doesn't see
+	 it. */
+      buf++;
     }
 
   if (p == lim)
--- a/tests/ChangeLog	Sat Apr 30 17:38:35 2011 +0200
+++ b/tests/ChangeLog	Sun May 01 13:51:33 2011 +0100
@@ -1,3 +1,9 @@
+2011-05-01  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* automated/lisp-reader-tests.el:
+	If the bignum feature is available, check that a leading plus sign
+	is treated correctly when reading bignum integers.
+
 2011-04-29  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.31 "ginger" is released.
--- a/tests/automated/lisp-reader-tests.el	Sat Apr 30 17:38:35 2011 +0200
+++ b/tests/automated/lisp-reader-tests.el	Sun May 01 13:51:33 2011 +0100
@@ -76,3 +76,14 @@
     (insert string)
     (Check-Error-Message invalid-read-syntax "unrecognized raw string"
                          (eval-buffer))))
+
+(when (featurep 'bignum)
+  ;; This failed, up to 20110501.
+  (Assert (eql (1+ most-positive-fixnum)
+	       (read (format "+%d" (1+ most-positive-fixnum))))
+	  "checking leading + is handled properly if reading a bignum")
+  ;; This never did.
+  (Assert (eql (1- most-positive-fixnum)
+	       (read (format "+%d" (1- most-positive-fixnum))))
+	  "checking leading + is handled properly if reading a fixnum"))
+