emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c213f46 2/2: New experimental variable read-integer


From: Paul Eggert
Subject: [Emacs-diffs] master c213f46 2/2: New experimental variable read-integer-overflow-as-float.
Date: Thu, 29 Mar 2018 14:03:15 -0400 (EDT)

branch: master
commit c213f465ba8038ce93314b96fd53ec3e35d34609
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    New experimental variable read-integer-overflow-as-float.
    
    Following a suggestion by Eli Zaretskii (Bug#30408#46).
    * etc/NEWS: Mention it.
    * src/lread.c (syms_of_lread): Add it.
    (read1): Treat out-of-range integers as floats if
    read-integer-overflow-as-float is non-nil.
---
 etc/NEWS    |  6 ++++--
 src/lread.c | 11 ++++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 9161f2b..9dddc90 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -356,8 +356,10 @@ implementation to format (Bug#30408).
 ** The Lisp reader now signals an overflow for plain decimal integers
 that do not end in '.' and are outside Emacs range.  Formerly the Lisp
 reader silently converted them to floating-point numbers, and signaled
-overflow only for integers with a radix that are outside machine range
-(Bug#30408).
+overflow only for integers with a radix that are outside machine range.
+To get the old behavior, set the new, experimental variable
+read-integer-overflow-as-float to t and please email
address@hidden if you need that.  (Bug#30408).
 
 ---
 ** Some functions and variables obsolete since Emacs 22 have been removed:
diff --git a/src/lread.c b/src/lread.c
index a774524..8fb61f5 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3502,7 +3502,9 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
 
        if (!quoted && !uninterned_symbol)
          {
-           Lisp_Object result = string_to_number (read_buffer, 10, 0);
+           int flags = (read_integer_overflow_as_float
+                        ? S2N_OVERFLOW_TO_FLOAT : 0);
+           Lisp_Object result = string_to_number (read_buffer, 10, flags);
            if (! NILP (result))
              return unbind_to (count, result);
          }
@@ -4830,6 +4832,13 @@ were read in.  */);
               doc: /* Non-nil means read recursive structures using #N= and 
#N# syntax.  */);
   Vread_circle = Qt;
 
+  DEFVAR_BOOL ("read-integer-overflow-as-float",
+              read_integer_overflow_as_float,
+              doc: /* Non-nil means `read' quietly treats an out-of-range 
integer as floating point.
+Nil (the default) means signal an overflow unless the integer ends in `.'.
+This variable is experimental; email address@hidden if you need it.  */);
+  read_integer_overflow_as_float = false;
+
   DEFVAR_LISP ("load-path", Vload_path,
               doc: /* List of directories to search for files to load.
 Each element is a string (directory file name) or nil (meaning



reply via email to

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