diff src/number.c @ 2010:a9cdbfb4716e

[xemacs-hg @ 2004-04-13 15:38:30 by james] Handle leading + signs on numbers correctly.
author james
date Tue, 13 Apr 2004 15:38:42 +0000
parents cc5b615380f8
children f2fdfc131770
line wrap: on
line diff
--- a/src/number.c	Tue Apr 13 04:23:50 2004 +0000
+++ b/src/number.c	Tue Apr 13 15:38:42 2004 +0000
@@ -82,9 +82,15 @@
 			       bignum_hash, bignum_description, Lisp_Bignum);
 
 Lisp_Object
-string_to_bignum(const Ibyte *str, Bytecount len, int base)
+string_to_bignum (const Ibyte *str, Bytecount len, int base)
 {
   Lisp_Object b = make_bignum (0L);
+  /* GMP bignum_set_string returns random values with initial + sign */
+  if (*str == '+')
+    str++;
+  /* GMP bignum_set_string returns random values when fed an empty string */
+  if (*str == '\0')
+    return make_int (0);
   return (bignum_set_string (XBIGNUM_DATA (b), (const char *) str, base) < 0)
     ? Fsignal (Qinvalid_read_syntax,
 	       list3 (build_msg_string