Let ?\LF signal an error (bug#55738)
As suggested by Stefan Monnier. * src/lread.c (read_escape): Signal an error for ?\LF since it cannot reasonably be intended. * test/src/lread-tests.el (lread-escaped-lf): Update test. * etc/NEWS: Announce.
This commit is contained in:
parent
e48c9181b1
commit
28622d4dd0
3 changed files with 9 additions and 2 deletions
3
etc/NEWS
3
etc/NEWS
|
@ -1922,6 +1922,9 @@ It was previously only run by 'clone-indirect-buffer' and
|
|||
called by both of these, the hook is now run by all 3 of these
|
||||
functions.
|
||||
|
||||
---
|
||||
** '?\' at the end of a line now signals an error.
|
||||
Previously it produced a nonsense value, -1, that was never intended.
|
||||
|
||||
* Lisp Changes in Emacs 29.1
|
||||
|
||||
|
|
|
@ -2664,6 +2664,10 @@ read_escape (Lisp_Object readcharfun)
|
|||
case 'v':
|
||||
return '\v';
|
||||
|
||||
case '\n':
|
||||
/* ?\LF is an error; it's probably a user mistake. */
|
||||
error ("Invalid escape character syntax");
|
||||
|
||||
case 'M':
|
||||
c = READCHAR;
|
||||
if (c != '-')
|
||||
|
|
|
@ -318,8 +318,8 @@ literals (Bug#20852)."
|
|||
'(## . 2))))
|
||||
|
||||
(ert-deftest lread-escaped-lf ()
|
||||
;; ?\LF should produce LF (only inside string literals do we ignore \LF).
|
||||
(should (equal (read-from-string "?\\\n") '(?\n . 3)))
|
||||
;; ?\LF should signal an error; \LF is ignored inside string literals.
|
||||
(should-error (read-from-string "?\\\n x"))
|
||||
(should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6))))
|
||||
|
||||
;;; lread-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue