]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxchar.cpp
Removed rundant files, updated readme.txt.
[wxWidgets.git] / src / common / wxchar.cpp
index 4da43cbd344c4b4aedef911b68ce41ef07990fb0..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
@@ -566,7 +564,10 @@ class wxFormatConverter
 public:
     wxFormatConverter(const wxChar *format);
 
-    operator const wxChar *() const { return m_nCopied ? m_fmtOrig : m_fmt.c_str(); }
+    // notice that we only translated the string if m_fmtOrig == NULL (as set
+    // by CopyAllBefore()), otherwise we should simply use the original format
+    operator const wxChar *() const
+        { return m_fmtOrig ? m_fmtOrig : m_fmt.c_str(); }
 
 private:
     // copy another character to the translated format: this function does the
@@ -577,7 +578,7 @@ private:
     {
         if ( !m_fmtOrig )
         {
-            // we're translating, d copy
+            // we're translating, do copy
             m_fmt += ch;
         }
         else