OpenSDE Packages Database (without history before r20070)
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

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../gmp/gmp-4.2.2-mpf_set_str.c.patch
  5. # Copyright (C) 2008 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. Origin: http://gmplib.org
  17. Description: When using mpf_set_str, mpf_init_set_str, or mpf_inp_str with
  18. a base > 36, the supplied base will actually be ignored, and
  19. the exponent 0 will be supplanted.
  20. --- gmp-4.2.2/mpf/set_str.c.orig 2007-08-30 18:31:40.000000000 +0000
  21. +++ gmp-4.2.2/mpf/set_str.c 2008-02-25 18:20:36.000000000 +0000
  22. @@ -271,8 +271,29 @@
  23. }
  24. if (expptr != 0)
  25. - /* FIXME: Should do some error checking here. */
  26. - exp_in_base = strtol (expptr, (char **) 0, exp_base);
  27. + {
  28. + /* Scan and convert the exponent, in base exp_base. */
  29. + long dig, neg = -(long) ('-' == expptr[0]);
  30. + expptr -= neg; /* conditional increment */
  31. + c = (unsigned char) *expptr++;
  32. + dig = digit_value[c];
  33. + if (dig >= exp_base)
  34. + {
  35. + TMP_FREE;
  36. + return -1;
  37. + }
  38. + exp_in_base = dig;
  39. + c = (unsigned char) *expptr++;
  40. + dig = digit_value[c];
  41. + while (dig < exp_base)
  42. + {
  43. + exp_in_base = exp_in_base * exp_base;
  44. + exp_in_base += dig;
  45. + c = (unsigned char) *expptr++;
  46. + dig = digit_value[c];
  47. + }
  48. + exp_in_base = (exp_in_base ^ neg) - neg; /* conditional negation */
  49. + }
  50. else
  51. exp_in_base = 0;
  52. if (dotpos != 0)