From 8d87a6aa12745d01abb8ef8468b8e3f258af1996 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 30 Jan 2025 15:28:14 -0500 Subject: Unify invalid input character error reporting Puts all error messages that print input characters in the same place, so that potentially printing them can be handled properly. Most notably this avoids printing EOF and control characters in error messages. --- src/reader.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/reader.h') diff --git a/src/reader.h b/src/reader.h index d7b06a98..65c49f2c 100644 --- a/src/reader.h +++ b/src/reader.h @@ -69,6 +69,9 @@ SERD_LOG_FUNC(3, 4) SerdStatus r_err(SerdReader* reader, SerdStatus st, const char* fmt, ...); +SerdStatus +r_err_char(SerdReader* reader, const char* kind, int c); + Ref push_node_padded(SerdReader* reader, size_t maxlen, @@ -143,7 +146,7 @@ eat_byte_check(SerdReader* const reader, const int byte) { const int c = peek_byte(reader); if (c != byte) { - r_err(reader, SERD_ERR_BAD_SYNTAX, "expected '%c', not '%c'\n", byte, c); + r_err(reader, SERD_ERR_BAD_SYNTAX, "expected '%c'\n", byte); return 0; } return eat_byte_safe(reader, byte); -- cgit v1.2.1