emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 28622d4dd0 2/2: Let ?\LF signal an error (bug#55738)


From: Mattias Engdegård
Subject: master 28622d4dd0 2/2: Let ?\LF signal an error (bug#55738)
Date: Fri, 3 Jun 2022 05:23:47 -0400 (EDT)

branch: master
commit 28622d4dd0347227a28b7b25c674437239a00a06
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    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.
---
 etc/NEWS                | 3 +++
 src/lread.c             | 4 ++++
 test/src/lread-tests.el | 4 ++--
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index f9409bb24f..54bc6d80e1 100644
--- a/etc/NEWS
+++ b/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
 
diff --git a/src/lread.c b/src/lread.c
index 4b7d38a8e6..1d20470a8b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -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 != '-')
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 99eec9d548..f190f14781 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]