changeset 1993:e567417c2e5d

[xemacs-hg @ 2004-04-07 02:41:29 by james] Read negative bignums correctly with BSD MP.
author james
date Wed, 07 Apr 2004 02:41:30 +0000
parents 4529ff71e646
children cb7f3be19e9f
files src/ChangeLog src/number-mp.c
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Apr 07 02:20:14 2004 +0000
+++ b/src/ChangeLog	Wed Apr 07 02:41:30 2004 +0000
@@ -1,3 +1,7 @@
+2004-04-06  Jerry James  <james@xemacs.org>
+
+	* number-mp.c (bignum_set_string): Read negative numbers correctly.
+
 2004-04-06  Jerry James  <james@xemacs.org>
 
 	* data.c (Flogand): Fix for --use-union-type.
--- a/src/number-mp.c	Wed Apr 07 02:20:14 2004 +0000
+++ b/src/number-mp.c	Wed Apr 07 02:41:30 2004 +0000
@@ -193,6 +193,7 @@
 {
   MINT *mbase;
   short digit;
+  int neg = 0;
 
   if (base == 0)
     {
@@ -212,6 +213,12 @@
 
   /* FIXME: signal something if base is < 2 or doesn't fit into a short. */
 
+  if (*s == '-')
+    {
+      s++;
+      neg = 1;
+    }
+
   mbase = MP_ITOM ((short) base);
   MP_MOVE (bignum_zero, b);
   
@@ -226,6 +233,9 @@
       MP_MFREE (temp);
     }
 
+  if (neg)
+    MP_MSUB (bignum_zero, b, b);
+
   return (digit >= 0) ? -1 : 0;
 }