diff options
| author | Paul Eggert | 2018-03-29 10:16:29 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-03-29 11:03:07 -0700 |
| commit | 6b3d01dad415230ad0bd0d01a05351d7a8b0e8c3 (patch) | |
| tree | d49bf4520d6afc830aa9d016be3d57349b251c4f /src/data.c | |
| parent | 3409fe0362c52127c52f854a7300f4dde4b8fffe (diff) | |
| download | emacs-6b3d01dad415230ad0bd0d01a05351d7a8b0e8c3.tar.gz emacs-6b3d01dad415230ad0bd0d01a05351d7a8b0e8c3.zip | |
Lisp reader now checks for integer overflow
* doc/lispref/numbers.texi (Integer Basics), etc/NEWS:
Document this.
* src/lisp.h (S2N_IGNORE_TRAILING, S2N_OVERFLOW_TO_FLOAT):
New constants.
* src/lread.c (string_to_number): Change trailing bool arg to
integer argument with flags, to support S2N_OVERFLOW_TO_FLOAT.
All uses changed.
* test/src/editfns-tests.el (read-large-integer): New test.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/data.c b/src/data.c index a7fab1ef58a..6f23a26757a 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -2716,9 +2716,7 @@ present, base 10 is used. BASE must be between 2 and 16 (inclusive). | |||
| 2716 | If the base used is not 10, STRING is always parsed as an integer. */) | 2716 | If the base used is not 10, STRING is always parsed as an integer. */) |
| 2717 | (register Lisp_Object string, Lisp_Object base) | 2717 | (register Lisp_Object string, Lisp_Object base) |
| 2718 | { | 2718 | { |
| 2719 | register char *p; | 2719 | int b; |
| 2720 | register int b; | ||
| 2721 | Lisp_Object val; | ||
| 2722 | 2720 | ||
| 2723 | CHECK_STRING (string); | 2721 | CHECK_STRING (string); |
| 2724 | 2722 | ||
| @@ -2732,11 +2730,12 @@ If the base used is not 10, STRING is always parsed as an integer. */) | |||
| 2732 | b = XINT (base); | 2730 | b = XINT (base); |
| 2733 | } | 2731 | } |
| 2734 | 2732 | ||
| 2735 | p = SSDATA (string); | 2733 | char *p = SSDATA (string); |
| 2736 | while (*p == ' ' || *p == '\t') | 2734 | while (*p == ' ' || *p == '\t') |
| 2737 | p++; | 2735 | p++; |
| 2738 | 2736 | ||
| 2739 | val = string_to_number (p, b, true); | 2737 | int flags = S2N_IGNORE_TRAILING | S2N_OVERFLOW_TO_FLOAT; |
| 2738 | Lisp_Object val = string_to_number (p, b, flags); | ||
| 2740 | return NILP (val) ? make_number (0) : val; | 2739 | return NILP (val) ? make_number (0) : val; |
| 2741 | } | 2740 | } |
| 2742 | 2741 | ||