small fix for mpz_set_str()

Torbjörn Granlund tg at gmplib.org
Mon Feb 19 12:05:38 UTC 2018


Trevor Spiteri <tspiteri at ieee.org> writes:

  This is a fix for the bug
  https://gmplib.org/list-archives/gmp-bugs/2018-February/004304.html
  
  Regards.
  
  Trevor Spiteri
  
  
  diff -r 164971d5c8d0 mpz/set_str.c
  --- a/mpz/set_str.c    Sat Feb 10 18:05:32 2018 +0100
  +++ b/mpz/set_str.c    Wed Feb 14 00:35:11 2018 +0100
  @@ -71,7 +71,9 @@
     if (c == '-')
       {
         negative = 1;
  -      c = (unsigned char) *str++;
  +      do
  +        c = (unsigned char) *str++;
  +      while (isspace (c));
       }
   
     if (digit_value[c] >= (base == 0 ? 10 : base))
  
I believe the GMP developers discussed this some years ago, and IIRC we
decided not to skip more spaces.  The reason would be that we don't
consider the (documented) space skipping of mp{z,q,f}_set_str to be a
nice feature.

(We might want to update the documentation, though.)


-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list