Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
2009:1388c8b3e663 | 2010:a9cdbfb4716e |
---|---|
80 DEFINE_LRECORD_IMPLEMENTATION ("bignum", bignum, 0, 0, | 80 DEFINE_LRECORD_IMPLEMENTATION ("bignum", bignum, 0, 0, |
81 bignum_print, bignum_finalize, bignum_equal, | 81 bignum_print, bignum_finalize, bignum_equal, |
82 bignum_hash, bignum_description, Lisp_Bignum); | 82 bignum_hash, bignum_description, Lisp_Bignum); |
83 | 83 |
84 Lisp_Object | 84 Lisp_Object |
85 string_to_bignum(const Ibyte *str, Bytecount len, int base) | 85 string_to_bignum (const Ibyte *str, Bytecount len, int base) |
86 { | 86 { |
87 Lisp_Object b = make_bignum (0L); | 87 Lisp_Object b = make_bignum (0L); |
88 /* GMP bignum_set_string returns random values with initial + sign */ | |
89 if (*str == '+') | |
90 str++; | |
91 /* GMP bignum_set_string returns random values when fed an empty string */ | |
92 if (*str == '\0') | |
93 return make_int (0); | |
88 return (bignum_set_string (XBIGNUM_DATA (b), (const char *) str, base) < 0) | 94 return (bignum_set_string (XBIGNUM_DATA (b), (const char *) str, base) < 0) |
89 ? Fsignal (Qinvalid_read_syntax, | 95 ? Fsignal (Qinvalid_read_syntax, |
90 list3 (build_msg_string | 96 list3 (build_msg_string |
91 ("Invalid integer constant in reader"), | 97 ("Invalid integer constant in reader"), |
92 make_string (str, len), | 98 make_string (str, len), |