]> git.saurik.com Git - wxWidgets.git/commitdiff
Correct handling of %hs and %ls in our wxPrintf() implementation.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 30 Sep 2010 14:30:35 +0000 (14:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 30 Sep 2010 14:30:35 +0000 (14:30 +0000)
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

include/wx/private/wxprintf.h

index f60d9e8ea99da61c68647e87cf3e359ffcf8ef60..ff74ee11ca4eb9f933e2adf3557116f98d1342be 100644 (file)
@@ -700,11 +700,16 @@ int wxPrintfConvSpec<CharType>::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<const char *>(p->pad_str));
+                else // m_type == wxPAT_PWCHAR
+                    s.assign(static_cast<const wchar_t *>(p->pad_str));
 
                 typename wxPrintfStringHelper<CharType>::ConvertedType strbuf(
                         wxPrintfStringHelper<CharType>::Convert(s));