diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-05-11 11:49:06 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-05-11 11:52:47 +0200 |
commit | 1174e8ba4d7196a770214721e5973a037684a130 (patch) | |
tree | d9f950656178d8235b1191eded7b20091700beb9 | |
parent | e4c8ba6c0589f1ba0ba9993c4f1e9c0821d3ca6c (diff) | |
download | emacs-1174e8ba4d7196a770214721e5973a037684a130.tar.gz |
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.
-rw-r--r-- | src/lread.c | 14 |
1 files 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; |