]> git.saurik.com Git - wxWidgets.git/commitdiff
fixes for wxVsnprintf() in Unicode build (2nd part of patch 1462778)
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 30 May 2006 17:14:35 +0000 (17:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 30 May 2006 17:14:35 +0000 (17:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/wxchar.cpp

index da53404e287203e87317a8d4997f949573928bc2..3532e0533bc5cf95be0cd44f5280518dbe60ba2e 100644 (file)
@@ -785,7 +785,7 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p)
 
                 if (type == wxPAT_PCHAR) {
                     // user passed a string explicitely indicated as ANSI...
-                    val = wxString(p->pad_pchar, wxConvLibc);
+                    val = s = wxString(p->pad_pchar, wxConvLibc);
                 }
 #else
                     p->pad_pchar;
@@ -793,7 +793,7 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p)
 #if wxUSE_WCHAR_T
                 if (type == wxPAT_PWCHAR) {
                     // user passed a string explicitely indicated as Unicode...
-                    val = wxString(p->pad_pwchar, wxConvLibc);
+                    val = s = wxString(p->pad_pwchar, wxConvLibc);
                 }
 #endif
 #endif
@@ -802,7 +802,9 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p)
                 if (val)
                 {
 #if wxUSE_STRUTILS
-                    len = wxMin(max_width, wxStrlen(val));
+                    // at this point we are sure that max_width is positive or null
+                    // (see top of wxPrintfConvSpec::LoadArg)
+                    len = wxMin((unsigned int)max_width, wxStrlen(val));
 #else
                     for ( len = 0; val[len] && (len < max_width); len++ )
                         ;
@@ -828,7 +830,9 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p)
                 }
 
 #if wxUSE_STRUTILS
-                len = wxMin(len, lenMax-lenCur);
+                // at this point we are sure that max_width is positive or null
+                // (see top of wxPrintfConvSpec::LoadArg)
+                len = wxMin((unsigned int)len, lenMax-lenCur);
                 wxStrncpy(buf+lenCur, val, len);
                 lenCur += len;
 #else