]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxchar.cpp
remove redundant GdkBitmap representation from wxBitmap
[wxWidgets.git] / src / common / wxchar.cpp
index a547a1e201f71756f29c3d8ac690e9520e387f9b..56095eefa816f62417332e8072a4e5d5033901b9 100644 (file)
@@ -752,11 +752,13 @@ int wxPrintfConvSpec::Process(wxChar *buf, size_t lenMax, wxPrintfArg *p)
 #else
                     p->pad_char;
 
+#if wxUSE_WCHAR_T
                 if (type == wxPAT_WCHAR) {
                     // user passed a character explicitely indicated as Unicode...
                     const wchar_t buf[2] = { p->pad_wchar, 0 };
                     val = wxString(buf, wxConvLibc)[0u];
                 }
+#endif
 #endif
 
                 size_t i;
@@ -783,22 +785,26 @@ 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;
 
+#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
                 int len;
 
                 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++ )
                         ;
@@ -824,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
@@ -950,15 +958,25 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
         return -1;      // format strings with both positional and
                         // non-positional conversion specifier are unsupported !!
 
+    // on platforms where va_list is an array type, it is necessary to make a
+    // copy to be able to pass it to LoadArg as a reference.
+    bool ok = true;
+    va_list ap;
+    wxVaCopy(ap, argptr);
+
     // now load arguments from stack
-    for (i=0; i < nargs; i++) {
-        if (!pspec[i])
-            return -1;  // user forgot a positional parameter (e.g. %$1s %$3s) ?
-        if (!pspec[i]->LoadArg(&argdata[i], argptr))
-            return -1;  // this means that wxPrintfConvSpec::Parse failed
-                        // to set its 'type' to a valid value...
+    for (i=0; i < nargs && ok; i++) {
+        // !pspec[i] if user forgot a positional parameter (e.g. %$1s %$3s) ?
+        // or LoadArg false if wxPrintfConvSpec::Parse failed to set its 'type'
+        // to a valid value...
+        ok = pspec[i] && pspec[i]->LoadArg(&argdata[i], ap);
     }
 
+    va_end(ap);
+
+    if (!ok)
+        return -1;
+
     // finally, process each conversion specifier with its own argument
     toparse = format;
     for (i=0; i < nargs; i++)