]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxchar.cpp
Applied patch [ 549256 ] fix minor bug in widgets sample
[wxWidgets.git] / src / common / wxchar.cpp
index c19ed120c72541a67c47724be584649a7f777447..63ae0e26e7ab12bc8078e51eace2f52c0000c978 100644 (file)
@@ -163,15 +163,11 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                 buf[lenCur++] = ch
 
 #define APPEND_STR(s) \
-                for ( const char *p = s; *p; p++ ) \
                 { \
-                    APPEND_CH((wchar_t)(*p)); \
-                }
-
-#define APPEND_WSTR(s) \
-                for ( const wchar_t *p = s; *p; p++ ) \
-                { \
-                    APPEND_CH(*p); \
+                    for ( const wxChar *p = s; *p; p++ ) \
+                    { \
+                        APPEND_CH(*p); \
+                    } \
                 }
 
                 switch (format[++n]) {
@@ -284,7 +280,9 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             ::sprintf(szScratch, s_szFlags, val);
                         }
                         else if (ilen == -1) {
-                            short int val = va_arg(argptr, short int);
+                            // NB: 'short int' value passed through '...'
+                            //      is promoted to 'int'
+                            short int val = (short int) va_arg(argptr, int);
                             ::sprintf(szScratch, s_szFlags, val);
                         }
                         else if (ilen == 1) {
@@ -305,7 +303,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             ::sprintf(szScratch, s_szFlags, val);
                         }
 
-                        APPEND_STR(szScratch);
+                        APPEND_STR(wxConvLibc.cMB2WX(szScratch));
 
                         done = TRUE;
                         break;
@@ -326,7 +324,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             ::sprintf(szScratch, s_szFlags, val);
                         }
 
-                        APPEND_STR(szScratch);
+                        APPEND_STR(wxConvLibc.cMB2WX(szScratch));
 
                         done = TRUE;
                         break;
@@ -339,7 +337,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             s_szFlags[flagofs] = '\0';
                             ::sprintf(szScratch, s_szFlags, val);
 
-                            APPEND_STR(szScratch);
+                            APPEND_STR(wxConvLibc.cMB2WX(szScratch));
 
                             done = TRUE;
                         }
@@ -372,7 +370,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             if (s.Len() < min_width)
                                 s.Pad(min_width - s.Len(), wxT(' '), adj_left);
 
-                            APPEND_WSTR(s);
+                            APPEND_STR(s);
                         } else {
                             wxChar *val = va_arg(argptr, wxChar *);
                             size_t len = wxSTRING_MAXLEN;
@@ -383,7 +381,7 @@ int WXDLLEXPORT wxVsnprintf_(wxChar *buf, size_t lenMax,
                             if (s.Len() < min_width)
                                 s.Pad(min_width - s.Len(), wxT(' '), adj_left);
 
-                            APPEND_WSTR(s);
+                            APPEND_STR(s);
                         }
                         done = TRUE;
                         break;
@@ -451,7 +449,7 @@ int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...)
 // implement the standard IO functions for wide char if libc doesn't have them
 // ----------------------------------------------------------------------------
 
-#ifndef HAVE_FPUTWC
+#ifdef wxNEED_FPUTWC
 
 int wxFputs(const wchar_t *ws, FILE *stream)
 {
@@ -467,7 +465,7 @@ int /* not wint_t */ wxPutc(wchar_t wc, FILE *stream)
     return wxFputs(ws, stream);
 }
 
-#endif // HAVE_FPUTWC
+#endif // wxNEED_FPUTWC
 
 // NB: we only implement va_list functions here, the ones taking ... are
 //     defined below for wxNEED_PRINTF_CONVERSION case anyhow and we reuse