patches/gmp/4.2.2/100-mpf_set_str.c.patch
changeset 466 7f9bbf94b0bb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gmp/4.2.2/100-mpf_set_str.c.patch	Wed Apr 30 10:43:41 2008 +0000
     1.3 @@ -0,0 +1,38 @@
     1.4 +Original patch from http://gmplib.org/patches/mpf_set_str.c.diff
     1.5 +Re-diffed to match crosstool-NG conventions.
     1.6 +
     1.7 +diff -dur gmp-4.2.2.orig/mpf/set_str.c gmp-4.2.2/mpf/set_str.c
     1.8 +--- gmp-4.2.2.orig/mpf/set_str.c	2007-08-30 20:31:40.000000000 +0200
     1.9 ++++ gmp-4.2.2/mpf/set_str.c	2008-01-28 23:05:29.000000000 +0100
    1.10 +@@ -271,8 +271,29 @@
    1.11 +       }
    1.12 + 
    1.13 +     if (expptr != 0)
    1.14 +-      /* FIXME: Should do some error checking here.  */
    1.15 +-      exp_in_base = strtol (expptr, (char **) 0, exp_base);
    1.16 ++      {
    1.17 ++	/* Scan and convert the exponent, in base exp_base.  */
    1.18 ++	long dig, neg = -(long) ('-' == expptr[0]);
    1.19 ++	expptr -= neg;			/* conditional increment */
    1.20 ++	c = (unsigned char) *expptr++;
    1.21 ++	dig = digit_value[c];
    1.22 ++	if (dig >= exp_base)
    1.23 ++	  {
    1.24 ++	    TMP_FREE;
    1.25 ++	    return -1;
    1.26 ++	  }
    1.27 ++	exp_in_base = dig;
    1.28 ++	c = (unsigned char) *expptr++;
    1.29 ++	dig = digit_value[c];
    1.30 ++	while (dig < exp_base)
    1.31 ++	  {
    1.32 ++	    exp_in_base = exp_in_base * exp_base;
    1.33 ++	    exp_in_base += dig;
    1.34 ++	    c = (unsigned char) *expptr++;
    1.35 ++	    dig = digit_value[c];
    1.36 ++	  }
    1.37 ++	exp_in_base = (exp_in_base ^ neg) - neg; /* conditional negation */
    1.38 ++      }
    1.39 +     else
    1.40 +       exp_in_base = 0;
    1.41 +     if (dotpos != 0)