diff --git a/include/wx/strvararg.h b/include/wx/strvararg.h index 6562ee3150..f96ed85f5d 100644 --- a/include/wx/strvararg.h +++ b/include/wx/strvararg.h @@ -155,6 +155,9 @@ public: // a char* string is also a pointer and an integer is also a char. enum ArgumentType { + Arg_Unused = 0, // not used at all; the value of 0 is chosen to + // conveniently pass wxASSERT_ARG_TYPE's check + Arg_Char = 0x0001, // character as char %c Arg_Pointer = 0x0002, // %p Arg_String = 0x0004 | Arg_Pointer, // any form of string (%s and %p too) diff --git a/src/common/strvararg.cpp b/src/common/strvararg.cpp index 9112bbf8f9..83d82b3383 100644 --- a/src/common/strvararg.cpp +++ b/src/common/strvararg.cpp @@ -654,8 +654,17 @@ wxFormatString::ArgumentType DoGetArgumentType(const CharType *format, wxPrintfConvSpecParser parser(format); - wxCHECK_MSG( n <= parser.nargs, wxFormatString::Arg_Unknown, - "more arguments than format string specifiers?" ); + if ( n > parser.nargs ) + { + // The n-th argument doesn't appear in the format string and is unused. + // This can happen e.g. if a translation of the format string is used + // and the translation language tends to avoid numbers in singular forms. + // The translator would then typically replace "%d" with "One" (e.g. in + // Hebrew). Passing too many vararg arguments does not harm, so its + // better to be more permissive here and allow legitimate uses in favour + // of catching harmless errors. + return wxFormatString::Arg_Unused; + } wxCHECK_MSG( parser.pspec[n-1] != NULL, wxFormatString::Arg_Unknown, "requested argument not found - invalid format string?" );