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/data.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/data.c')
| -rw-r--r-- | src/data.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/data.c b/src/data.c index ce2d842de44..0f47556fe45 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1770,7 +1770,7 @@ BUFFER defaults to the current buffer. */) | |||
| 1770 | CHECK_SYMBOL (variable); | 1770 | CHECK_SYMBOL (variable); |
| 1771 | sym = indirect_variable (XSYMBOL (variable)); | 1771 | sym = indirect_variable (XSYMBOL (variable)); |
| 1772 | XSETSYMBOL (variable, sym); | 1772 | XSETSYMBOL (variable, sym); |
| 1773 | 1773 | ||
| 1774 | valcontents = sym->value; | 1774 | valcontents = sym->value; |
| 1775 | if (BUFFER_LOCAL_VALUEP (valcontents)) | 1775 | if (BUFFER_LOCAL_VALUEP (valcontents)) |
| 1776 | { | 1776 | { |
| @@ -2353,11 +2353,11 @@ digit_to_number (character, base) | |||
| 2353 | DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0, | 2353 | DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0, |
| 2354 | doc: /* Parse STRING as a decimal number and return the number. | 2354 | doc: /* Parse STRING as a decimal number and return the number. |
| 2355 | This parses both integers and floating point numbers. | 2355 | This parses both integers and floating point numbers. |
| 2356 | It ignores leading spaces and tabs. | 2356 | It ignores leading spaces and tabs, and all trailing chars. |
| 2357 | 2357 | ||
| 2358 | If BASE, interpret STRING as a number in that base. If BASE isn't | 2358 | If BASE, interpret STRING as a number in that base. If BASE isn't |
| 2359 | present, base 10 is used. BASE must be between 2 and 16 (inclusive). | 2359 | present, base 10 is used. BASE must be between 2 and 16 (inclusive). |
| 2360 | If the base used is not 10, floating point is not recognized. */) | 2360 | If the base used is not 10, STRING is always parsed as integer. */) |
| 2361 | (string, base) | 2361 | (string, base) |
| 2362 | register Lisp_Object string, base; | 2362 | register Lisp_Object string, base; |
| 2363 | { | 2363 | { |
| @@ -2392,7 +2392,7 @@ If the base used is not 10, floating point is not recognized. */) | |||
| 2392 | else if (*p == '+') | 2392 | else if (*p == '+') |
| 2393 | p++; | 2393 | p++; |
| 2394 | 2394 | ||
| 2395 | if (isfloat_string (p) && b == 10) | 2395 | if (isfloat_string (p, 1) && b == 10) |
| 2396 | val = make_float (sign * atof (p)); | 2396 | val = make_float (sign * atof (p)); |
| 2397 | else | 2397 | else |
| 2398 | { | 2398 | { |