X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..f239a20092359e3c914adb79bd39f3f5d2b2e06f:/src/common/strvararg.cpp diff --git a/src/common/strvararg.cpp b/src/common/strvararg.cpp index 09b8ca0b98..a4c2256dfb 100644 --- a/src/common/strvararg.cpp +++ b/src/common/strvararg.cpp @@ -375,7 +375,7 @@ private: size_t m_nCopied; }; -#ifdef __WINDOWS__ +#if defined(__WINDOWS__) && !defined(__CYGWIN__) // on Windows, we should use %s and %c regardless of the build: class wxPrintfFormatConverterWchar : public wxFormatConverterBase @@ -637,12 +637,15 @@ template wxFormatString::ArgumentType DoGetArgumentType(const CharType *format, unsigned n) { - wxCHECK_MSG( format, wxFormatString::Arg_Other, + wxCHECK_MSG( format, wxFormatString::Arg_Unknown, "empty format string not allowed here" ); wxPrintfConvSpecParser parser(format); - wxCHECK_MSG( parser.pspec[n-1] != NULL, wxFormatString::Arg_Other, + wxCHECK_MSG( n <= parser.nargs, wxFormatString::Arg_Unknown, + "more arguments than format string specifiers?" ); + + wxCHECK_MSG( parser.pspec[n-1] != NULL, wxFormatString::Arg_Unknown, "requested argument not found - invalid format string?" ); switch ( parser.pspec[n-1]->m_type ) @@ -651,9 +654,48 @@ wxFormatString::ArgumentType DoGetArgumentType(const CharType *format, case wxPAT_WCHAR: return wxFormatString::Arg_Char; - default: - return wxFormatString::Arg_Other; + case wxPAT_PCHAR: + case wxPAT_PWCHAR: + return wxFormatString::Arg_String; + + case wxPAT_INT: + return wxFormatString::Arg_Int; + case wxPAT_LONGINT: + return wxFormatString::Arg_LongInt; +#ifdef wxLongLong_t + case wxPAT_LONGLONGINT: + return wxFormatString::Arg_LongLongInt; +#endif + case wxPAT_SIZET: + return wxFormatString::Arg_Size_t; + + case wxPAT_DOUBLE: + return wxFormatString::Arg_Double; + case wxPAT_LONGDOUBLE: + return wxFormatString::Arg_LongDouble; + + case wxPAT_POINTER: + return wxFormatString::Arg_Pointer; + + case wxPAT_NINT: + return wxFormatString::Arg_IntPtr; + case wxPAT_NSHORTINT: + return wxFormatString::Arg_ShortIntPtr; + case wxPAT_NLONGINT: + return wxFormatString::Arg_LongIntPtr; + + case wxPAT_STAR: + // "*" requires argument of type int + return wxFormatString::Arg_Int; + + case wxPAT_INVALID: + // (handled after the switch statement) + break; } + + // silence warning + wxFAIL_MSG( "unexpected argument type" ); + return wxFormatString::Arg_Unknown; } } // anonymous namespace @@ -670,5 +712,5 @@ wxFormatString::ArgumentType wxFormatString::GetArgumentType(unsigned n) const return DoGetArgumentType(m_cstr->AsInternal(), n); wxFAIL_MSG( "unreachable code" ); - return Arg_Other; + return Arg_Unknown; }