You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.9 KiB

# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../gmp/gmp-4.2.2-mpf_set_str.c.patch
# Copyright (C) 2008 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
Origin: http://gmplib.org
Description: When using mpf_set_str, mpf_init_set_str, or mpf_inp_str with
a base > 36, the supplied base will actually be ignored, and
the exponent 0 will be supplanted.
--- gmp-4.2.2/mpf/set_str.c.orig 2007-08-30 18:31:40.000000000 +0000
+++ gmp-4.2.2/mpf/set_str.c 2008-02-25 18:20:36.000000000 +0000
@@ -271,8 +271,29 @@
}
if (expptr != 0)
- /* FIXME: Should do some error checking here. */
- exp_in_base = strtol (expptr, (char **) 0, exp_base);
+ {
+ /* Scan and convert the exponent, in base exp_base. */
+ long dig, neg = -(long) ('-' == expptr[0]);
+ expptr -= neg; /* conditional increment */
+ c = (unsigned char) *expptr++;
+ dig = digit_value[c];
+ if (dig >= exp_base)
+ {
+ TMP_FREE;
+ return -1;
+ }
+ exp_in_base = dig;
+ c = (unsigned char) *expptr++;
+ dig = digit_value[c];
+ while (dig < exp_base)
+ {
+ exp_in_base = exp_in_base * exp_base;
+ exp_in_base += dig;
+ c = (unsigned char) *expptr++;
+ dig = digit_value[c];
+ }
+ exp_in_base = (exp_in_base ^ neg) - neg; /* conditional negation */
+ }
else
exp_in_base = 0;
if (dotpos != 0)