diff options
| author | Paul Eggert | 2018-03-29 11:01:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-03-29 11:03:07 -0700 |
| commit | c213f465ba8038ce93314b96fd53ec3e35d34609 (patch) | |
| tree | c15b9e7a0617eba9008dd217deaa237b634ec79c /src | |
| parent | 6b3d01dad415230ad0bd0d01a05351d7a8b0e8c3 (diff) | |
| download | emacs-c213f465ba8038ce93314b96fd53ec3e35d34609.tar.gz emacs-c213f465ba8038ce93314b96fd53ec3e35d34609.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lread.c b/src/lread.c index a774524ee43..8fb61f56338 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -3502,7 +3502,9 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 3502 | 3502 | ||
| 3503 | if (!quoted && !uninterned_symbol) | 3503 | if (!quoted && !uninterned_symbol) |
| 3504 | { | 3504 | { |
| 3505 | Lisp_Object result = string_to_number (read_buffer, 10, 0); | 3505 | int flags = (read_integer_overflow_as_float |
| 3506 | ? S2N_OVERFLOW_TO_FLOAT : 0); | ||
| 3507 | Lisp_Object result = string_to_number (read_buffer, 10, flags); | ||
| 3506 | if (! NILP (result)) | 3508 | if (! NILP (result)) |
| 3507 | return unbind_to (count, result); | 3509 | return unbind_to (count, result); |
| 3508 | } | 3510 | } |
| @@ -4830,6 +4832,13 @@ were read in. */); | |||
| 4830 | doc: /* Non-nil means read recursive structures using #N= and #N# syntax. */); | 4832 | doc: /* Non-nil means read recursive structures using #N= and #N# syntax. */); |
| 4831 | Vread_circle = Qt; | 4833 | Vread_circle = Qt; |
| 4832 | 4834 | ||
| 4835 | DEFVAR_BOOL ("read-integer-overflow-as-float", | ||
| 4836 | read_integer_overflow_as_float, | ||
| 4837 | doc: /* Non-nil means `read' quietly treats an out-of-range integer as floating point. | ||
| 4838 | Nil (the default) means signal an overflow unless the integer ends in `.'. | ||
| 4839 | This variable is experimental; email 30408@debbugs.gnu.org if you need it. */); | ||
| 4840 | read_integer_overflow_as_float = false; | ||
| 4841 | |||
| 4833 | DEFVAR_LISP ("load-path", Vload_path, | 4842 | DEFVAR_LISP ("load-path", Vload_path, |
| 4834 | doc: /* List of directories to search for files to load. | 4843 | doc: /* List of directories to search for files to load. |
| 4835 | Each element is a string (directory file name) or nil (meaning | 4844 | Each element is a string (directory file name) or nil (meaning |