aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2018-10-10 23:17:18 -0700
committerPaul Eggert2018-10-10 23:19:42 -0700
commit5bd8cfc14d4b0c78c07e65a583f42a10c4cbc06d (patch)
treec51b2a470f62679f5e5c3f6f55d90aa0082d0133 /src/lisp.h
parentfd3a48fcd8bb212ec12b9b10a79de0ae605ee93b (diff)
downloademacs-5bd8cfc14d4b0c78c07e65a583f42a10c4cbc06d.tar.gz
emacs-5bd8cfc14d4b0c78c07e65a583f42a10c4cbc06d.zip
Fix mishandling of symbols that look like numbers
* src/bignum.c (make_neg_biguint): New function. * src/lread.c (read1): Do not mishandle an unquoted symbol with name equal to something like "1\0x", i.e., a string of numeric form followed by a NUL byte. Formerly these symbols were misread as numbers. (string_to_number): Change last argument from an integer flag to a pointer to the length. This lets the caller figure out how much of the prefix was used. All callers changed. Add a fast path if the integer (sans sign) fits in uintmax_t. Update comments and simplify now that bignums are present. * src/print.c (print_object): Fix quoting of symbols that look like numbers, by relying on string_to_number for the tricky cases rather than trying to redo its logic, incorrectly. For example, (read (prin1-to-string '\1e+NaN)) formerly returned "1e+NaN", which was wrong: a backslash is needed in the output to prevent it from being read as a NaN. Escape NO_BREAK_SPACE too, since lread.c treats it like SPACE. * test/src/print-tests.el (print-read-roundtrip): Add tests illustrating the abovementioned bugs.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 2c20b483cad..5ecc48b025c 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2506,7 +2506,7 @@ INTEGERP (Lisp_Object x)
2506 return FIXNUMP (x) || BIGNUMP (x); 2506 return FIXNUMP (x) || BIGNUMP (x);
2507} 2507}
2508 2508
2509/* Return a Lisp integer with value taken from n. */ 2509/* Return a Lisp integer with value taken from N. */
2510INLINE Lisp_Object 2510INLINE Lisp_Object
2511make_int (intmax_t n) 2511make_int (intmax_t n)
2512{ 2512{
@@ -3329,6 +3329,7 @@ extern ptrdiff_t bignum_bufsize (Lisp_Object, int);
3329extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int); 3329extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int);
3330extern Lisp_Object bignum_to_string (Lisp_Object, int); 3330extern Lisp_Object bignum_to_string (Lisp_Object, int);
3331extern Lisp_Object make_bignum_str (char const *, int); 3331extern Lisp_Object make_bignum_str (char const *, int);
3332extern Lisp_Object make_neg_biguint (uintmax_t);
3332extern Lisp_Object double_to_integer (double); 3333extern Lisp_Object double_to_integer (double);
3333 3334
3334/* Converthe integer NUM to *N. Return true if successful, false 3335/* Converthe integer NUM to *N. Return true if successful, false
@@ -3839,7 +3840,7 @@ LOADHIST_ATTACH (Lisp_Object x)
3839extern int openp (Lisp_Object, Lisp_Object, Lisp_Object, 3840extern int openp (Lisp_Object, Lisp_Object, Lisp_Object,
3840 Lisp_Object *, Lisp_Object, bool); 3841 Lisp_Object *, Lisp_Object, bool);
3841enum { S2N_IGNORE_TRAILING = 1 }; 3842enum { S2N_IGNORE_TRAILING = 1 };
3842extern Lisp_Object string_to_number (char const *, int, int); 3843extern Lisp_Object string_to_number (char const *, int, ptrdiff_t *);
3843extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), 3844extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
3844 Lisp_Object); 3845 Lisp_Object);
3845extern void dir_warning (const char *, Lisp_Object); 3846extern void dir_warning (const char *, Lisp_Object);