diff options
| author | Juanma Barranquero | 2009-12-04 16:16:26 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2009-12-04 16:16:26 +0000 |
| commit | be95bee9b8cf3f771fdb6438a44ded2880e65617 (patch) | |
| tree | fe4ccba69d57fbd4f7d72bcc0f37d24a3fd490a5 /src/lread.c | |
| parent | 24c2d7ce87ac4e656d3c9c55b39f7b44d76e8f7a (diff) | |
| download | emacs-be95bee9b8cf3f771fdb6438a44ded2880e65617.tar.gz emacs-be95bee9b8cf3f771fdb6438a44ded2880e65617.zip | |
Fix `string-to-number' to deal consistently with integers and floats.
* lread.c (isfloat_string): New argument ignore_trailing to accept all
trailing characters, not just whitespace.
(read1): Pass new arg 0 to keep old behavior.
* data.c (Fstring_to_number): Pass 1 to isfloat_string to ignore
trailing chars, as it is already done for integers. Doc fixes.
* lisp.h (isfloat_string): Add new arg to declaration of isfloat_string.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lread.c b/src/lread.c index 97b9410b038..0649c638d98 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -3026,7 +3026,7 @@ read1 (readcharfun, pch, first_in_list) | |||
| 3026 | } | 3026 | } |
| 3027 | } | 3027 | } |
| 3028 | } | 3028 | } |
| 3029 | if (isfloat_string (read_buffer)) | 3029 | if (isfloat_string (read_buffer, 0)) |
| 3030 | { | 3030 | { |
| 3031 | /* Compute NaN and infinities using 0.0 in a variable, | 3031 | /* Compute NaN and infinities using 0.0 in a variable, |
| 3032 | to cope with compilers that think they are smarter | 3032 | to cope with compilers that think they are smarter |
| @@ -3244,8 +3244,9 @@ substitute_in_interval (interval, arg) | |||
| 3244 | #define EXP_INT 16 | 3244 | #define EXP_INT 16 |
| 3245 | 3245 | ||
| 3246 | int | 3246 | int |
| 3247 | isfloat_string (cp) | 3247 | isfloat_string (cp, ignore_trailing) |
| 3248 | register char *cp; | 3248 | register char *cp; |
| 3249 | int ignore_trailing; | ||
| 3249 | { | 3250 | { |
| 3250 | register int state; | 3251 | register int state; |
| 3251 | 3252 | ||
| @@ -3299,7 +3300,8 @@ isfloat_string (cp) | |||
| 3299 | cp += 3; | 3300 | cp += 3; |
| 3300 | } | 3301 | } |
| 3301 | 3302 | ||
| 3302 | return (((*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f')) | 3303 | return ((ignore_trailing |
| 3304 | || (*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f')) | ||
| 3303 | && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) | 3305 | && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) |
| 3304 | || state == (DOT_CHAR|TRAIL_INT) | 3306 | || state == (DOT_CHAR|TRAIL_INT) |
| 3305 | || state == (LEAD_INT|E_CHAR|EXP_INT) | 3307 | || state == (LEAD_INT|E_CHAR|EXP_INT) |