emacs-diffs
[Top][All Lists]
Advanced

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

master 1174e8ba4d7: More descriptive character escape syntax error messa


From: Mattias Engdegård
Subject: master 1174e8ba4d7: More descriptive character escape syntax error messages (bug#63436)
Date: Thu, 11 May 2023 05:57:29 -0400 (EDT)

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

    More descriptive character escape syntax error messages (bug#63436)
    
    * src/lread.c (invalid_escape_syntax_error): Remove.
    (read_char_escape): Make certain messages more specific
    than just "Invalid escape character syntax" to help finding
    and understanding the error.
---
 src/lread.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/lread.c b/src/lread.c
index 273120315df..67cd7185d04 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2639,12 +2639,6 @@ character_name_to_code (char const *name, ptrdiff_t 
name_len,
    Unicode 9.0.0 the maximum is 83, so this should be safe.  */
 enum { UNICODE_CHARACTER_NAME_LENGTH_BOUND = 200 };
 
-static AVOID
-invalid_escape_syntax_error (void)
-{
-  error ("Invalid escape character syntax");
-}
-
 /* Read a character escape sequence, assuming we just read a backslash
    and one more character (next_char).  */
 static int
@@ -2676,7 +2670,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
 
     case '\n':
       /* ?\LF is an error; it's probably a user mistake.  */
-      error ("Invalid escape character syntax");
+      error ("Invalid escape char syntax: \\<newline>");
 
     /* \M-x etc: set modifier bit and parse the char to which it applies,
        allowing for chains such as \M-\S-\A-\H-\s-\C-q.  */
@@ -2700,7 +2694,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
              }
            else
              /* \M, \S, \H, \A not followed by a hyphen is an error.  */
-             invalid_escape_syntax_error ();
+             error ("Invalid escape char syntax: \\%c not followed by -", c);
          }
        modifiers |= mod;
        c1 = READCHAR;
@@ -2720,7 +2714,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
       {
        int c1 = READCHAR;
        if (c1 != '-')
-         invalid_escape_syntax_error ();
+         error ("Invalid escape char syntax: \\%c not followed by -", c);
       }
       FALLTHROUGH;
     /* The prefixes \C- and \^ are equivalent.  */
@@ -2785,7 +2779,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
          }
 
        if (count == 0)
-         invalid_escape_syntax_error ();
+         error ("Invalid escape char syntax: \\x not followed by hex digit");
        if (count < 3 && i >= 0x80)
          i = BYTE8_TO_CHAR (i);
        modifiers |= i & CHAR_MODIFIER_MASK;



reply via email to

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