From: Mattias EngdegÄrd Date: Fri, 7 Oct 2022 16:17:40 +0000 (+0200) Subject: Improved format string error message (bug#58168) X-Git-Tag: emacs-29.0.90~1616^2~689 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=71b3a37569ffa58f3640a742e31eade42cc26f98;p=emacs.git 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. --- 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");