From: Vadim Zeitlin Date: Thu, 30 Sep 2010 14:30:35 +0000 (+0000) Subject: Correct handling of %hs and %ls in our wxPrintf() implementation. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/37513b6715f79de70b8bfa9791fedb1b3c3b9931 Correct handling of %hs and %ls in our wxPrintf() implementation. The strings corresponding to %hs and %ls are always narrow/wide independently of the build so using wxArgNormalizedString which is defined differently in different builds doesn't make sense in wxPrintf(). Instead, simply expect the parameter of the appropriate matching type for these conversion specifications. Any conversions to it, if necessary, had been already done before by wxFormatString. This fixes some VsnprintfTestCase::BigToSmallBuffer() unit test failures. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65690 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/private/wxprintf.h b/include/wx/private/wxprintf.h index f60d9e8ea9..ff74ee11ca 100644 --- a/include/wx/private/wxprintf.h +++ b/include/wx/private/wxprintf.h @@ -700,11 +700,16 @@ int wxPrintfConvSpec::Process(CharType *buf, size_t lenMax, wxPrintfAr case wxPAT_PCHAR: case wxPAT_PWCHAR: { - wxArgNormalizedString arg(p->pad_str); - wxString s = arg; - - if ( !arg.IsValid() && m_nMaxWidth >= 6 ) - s = wxT("(null)"); + wxString s; + if ( !p->pad_str ) + { + if ( m_nMaxWidth >= 6 ) + s = wxT("(null)"); + } + else if (m_type == wxPAT_PCHAR) + s.assign(static_cast(p->pad_str)); + else // m_type == wxPAT_PWCHAR + s.assign(static_cast(p->pad_str)); typename wxPrintfStringHelper::ConvertedType strbuf( wxPrintfStringHelper::Convert(s));