emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/bignum 5ebf062 3/4: Handle leading "+" when conver


From: Tom Tromey
Subject: [Emacs-diffs] feature/bignum 5ebf062 3/4: Handle leading "+" when converting string to bignum
Date: Wed, 8 Aug 2018 19:34:57 -0400 (EDT)

branch: feature/bignum
commit 5ebf062ebe0ec0536efd4f1fb4f37d75f892664b
Author: Tom Tromey <address@hidden>
Commit: Tom Tromey <address@hidden>

    Handle leading "+" when converting string to bignum
    
    * src/lread.c (string_to_number): Skip leading "+" when calling
    make_bignum_str.
---
 src/lread.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/lread.c b/src/lread.c
index bcb695c..3a2d9c8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3792,21 +3792,16 @@ string_to_number (char const *string, int base, int 
flags)
      range, use its value, preferably as a fixnum.  */
   if (leading_digit >= 0 && ! float_syntax)
     {
-      if (state & INTOVERFLOW)
-       {
-         /* Unfortunately there's no simple and accurate way to convert
-            non-base-10 numbers that are out of C-language range.  */
-         if (base != 10)
-           flags = 0;
-       }
-      else if (n <= (negative ? -MOST_NEGATIVE_FIXNUM : MOST_POSITIVE_FIXNUM))
+      if ((state & INTOVERFLOW) == 0
+         && n <= (negative ? -MOST_NEGATIVE_FIXNUM : MOST_POSITIVE_FIXNUM))
        {
          EMACS_INT signed_n = n;
          return make_fixnum (negative ? -signed_n : signed_n);
        }
-      else
-       value = n;
 
+      /* Skip a leading "+".  */
+      if (signedp && !negative)
+       ++string;
       return make_bignum_str (string, base);
     }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]