diff options
| author | Mattias EngdegÄrd | 2022-06-03 10:12:24 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-06-03 11:23:30 +0200 |
| commit | 28622d4dd0347227a28b7b25c674437239a00a06 (patch) | |
| tree | 194fe6c6de674eec25f4126fd5d772000fd1b99a | |
| parent | e48c9181b1c103b42032a5fb6547184da75bd773 (diff) | |
| download | emacs-28622d4dd0347227a28b7b25c674437239a00a06.tar.gz emacs-28622d4dd0347227a28b7b25c674437239a00a06.zip | |
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.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | src/lread.c | 4 | ||||
| -rw-r--r-- | test/src/lread-tests.el | 4 |
3 files changed, 9 insertions, 2 deletions
| @@ -1922,6 +1922,9 @@ It was previously only run by 'clone-indirect-buffer' and | |||
| 1922 | called by both of these, the hook is now run by all 3 of these | 1922 | called by both of these, the hook is now run by all 3 of these |
| 1923 | functions. | 1923 | functions. |
| 1924 | 1924 | ||
| 1925 | --- | ||
| 1926 | ** '?\' at the end of a line now signals an error. | ||
| 1927 | Previously it produced a nonsense value, -1, that was never intended. | ||
| 1925 | 1928 | ||
| 1926 | * Lisp Changes in Emacs 29.1 | 1929 | * Lisp Changes in Emacs 29.1 |
| 1927 | 1930 | ||
diff --git a/src/lread.c b/src/lread.c index 4b7d38a8e6c..1d20470a8bf 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2664,6 +2664,10 @@ read_escape (Lisp_Object readcharfun) | |||
| 2664 | case 'v': | 2664 | case 'v': |
| 2665 | return '\v'; | 2665 | return '\v'; |
| 2666 | 2666 | ||
| 2667 | case '\n': | ||
| 2668 | /* ?\LF is an error; it's probably a user mistake. */ | ||
| 2669 | error ("Invalid escape character syntax"); | ||
| 2670 | |||
| 2667 | case 'M': | 2671 | case 'M': |
| 2668 | c = READCHAR; | 2672 | c = READCHAR; |
| 2669 | if (c != '-') | 2673 | if (c != '-') |
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 99eec9d5487..f190f14781e 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -318,8 +318,8 @@ literals (Bug#20852)." | |||
| 318 | '(## . 2)))) | 318 | '(## . 2)))) |
| 319 | 319 | ||
| 320 | (ert-deftest lread-escaped-lf () | 320 | (ert-deftest lread-escaped-lf () |
| 321 | ;; ?\LF should produce LF (only inside string literals do we ignore \LF). | 321 | ;; ?\LF should signal an error; \LF is ignored inside string literals. |
| 322 | (should (equal (read-from-string "?\\\n") '(?\n . 3))) | 322 | (should-error (read-from-string "?\\\n x")) |
| 323 | (should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6)))) | 323 | (should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6)))) |
| 324 | 324 | ||
| 325 | ;;; lread-tests.el ends here | 325 | ;;; lread-tests.el ends here |