diff options
| author | Mattias EngdegÄrd | 2022-06-01 11:39:44 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-06-01 19:47:30 +0200 |
| commit | c50718dcfa54293b695f8a3fa5cd4d77848ee084 (patch) | |
| tree | ff0c224f50af5365e7fc3cb03c7cab5011eca50f /test | |
| parent | 84e122dc9676f1bcf36db62f313b0343a073982b (diff) | |
| download | emacs-c50718dcfa54293b695f8a3fa5cd4d77848ee084.tar.gz emacs-c50718dcfa54293b695f8a3fa5cd4d77848ee084.zip | |
Fix reader char escape bugs (bug#55738)
Make the character literal ?\LF (linefeed) generate 10, not -1.
Ensure that Control escape sequences in character literals are
idempotent: ?\C-\C-a and ?\^\^a mean the same thing as ?\C-a and ?\^a,
generating the control character with value 1. "\C-\C-a" no longer
signals an error.
* src/lread.c (read_escape): Make nonrecursive and only combine
the base char with modifiers at the end, creating control chars
if applicable. Remove the `stringp` argument; assume character
literal syntax. Never return -1.
(read_string_literal): Handle string-specific escape semantics here
and simplify.
* test/src/lread-tests.el (lread-misc-2): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/lread-tests.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 47351c1d116..59d5ca076f1 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -317,4 +317,14 @@ literals (Bug#20852)." | |||
| 317 | (should (equal (read-from-string "#_") | 317 | (should (equal (read-from-string "#_") |
| 318 | '(## . 2)))) | 318 | '(## . 2)))) |
| 319 | 319 | ||
| 320 | (ert-deftest lread-misc-2 () | ||
| 321 | ;; ?\LF should produce LF (only inside string literals do we ignore \LF). | ||
| 322 | (should (equal (read-from-string "?\\\n") '(?\n . 3))) | ||
| 323 | (should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6))) | ||
| 324 | ;; The Control modifier constructs should be idempotent. | ||
| 325 | (should (equal ?\C-\C-x ?\C-x)) | ||
| 326 | (should (equal ?\^\^x ?\C-x)) | ||
| 327 | (should (equal ?\C-\^x ?\C-x)) | ||
| 328 | (should (equal ?\^\C-x ?\C-x))) | ||
| 329 | |||
| 320 | ;;; lread-tests.el ends here | 330 | ;;; lread-tests.el ends here |