diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2022-10-07 18:17:40 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-10-08 18:48:30 +0200 |
commit | 71b3a37569ffa58f3640a742e31eade42cc26f98 (patch) | |
tree | face77aae16e51a726ba11afa5b7a6587d9ab6b5 /src/editfns.c | |
parent | 8de7995ae6388e5ae5418cb6af579281121f14a4 (diff) | |
download | emacs-71b3a37569ffa58f3640a742e31eade42cc26f98.tar.gz |
Improved format string error message (bug#58168)
* src/editfns.c (styled_format): Better message when the conversion
char is non-ASCII from a unibyte format string.
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c index c1414071c79..3f9618edb08 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3551,10 +3551,15 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) || float_conversion || conversion == 'i' || conversion == 'o' || conversion == 'x' || conversion == 'X')) - error ("Invalid format operation %%%c", - multibyte_format - ? STRING_CHAR ((unsigned char *) format - 1) - : *((unsigned char *) format - 1)); + { + unsigned char *p = (unsigned char *) format - 1; + if (multibyte_format) + error ("Invalid format operation %%%c", STRING_CHAR (p)); + else + error (*p <= 127 ? "Invalid format operation %%%c" + : "Invalid format operation char #o%03o", + *p); + } else if (! (FIXNUMP (arg) || ((BIGNUMP (arg) || FLOATP (arg)) && conversion != 'c'))) error ("Format specifier doesn't match argument type"); |