# HG changeset patch # User Aidan Kehoe # Date 1304254293 -3600 # Node ID 159face738c3bfd6691d64cc235fa13fc84e61b5 # Parent 1e544fd7be12682d959a810d0970e29107669a3f Never pass a leading + to mpz_set_string, parse_integer (). src/ChangeLog addition: 2011-05-01 Aidan Kehoe * 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 * automated/lisp-reader-tests.el: If the bignum feature is available, check that a leading plus sign is treated correctly when reading bignum integers. diff -r 1e544fd7be12 -r 159face738c3 src/ChangeLog --- 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 + + * 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 * redisplay.c (pixel_to_glyph_translation): diff -r 1e544fd7be12 -r 159face738c3 src/lread.c --- 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) diff -r 1e544fd7be12 -r 159face738c3 tests/ChangeLog --- 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 + + * 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 * XEmacs 21.5.31 "ginger" is released. diff -r 1e544fd7be12 -r 159face738c3 tests/automated/lisp-reader-tests.el --- 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")) +