]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strconv.cpp
re-renamed DoCreate() to XmDoCreateTLW() to avoid virtual function hiding in other...
[wxWidgets.git] / src / common / strconv.cpp
index bb08007cf4b0d7a4a1a57e2c243e109df43eccb3..63de22405cdd3213bf2ba09bba09adbffe278b64 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-  #pragma implementation "strconv.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -690,11 +686,11 @@ size_t wxMBConvUTF8::MB2WC(wchar_t *buf, const char *psz, size_t n) const
                     {
                         if ( buf && len + 3 < n )
                         {
-                            unsigned char n = *opsz;
+                            unsigned char on = *opsz;
                             *buf++ = L'\\';
-                            *buf++ = (wchar_t)( L'0' + n / 0100 );
-                            *buf++ = (wchar_t)( L'0' + (n % 0100) / 010 );
-                            *buf++ = (wchar_t)( L'0' + n % 010 );
+                            *buf++ = (wchar_t)( L'0' + on / 0100 );
+                            *buf++ = (wchar_t)( L'0' + (on % 0100) / 010 );
+                            *buf++ = (wchar_t)( L'0' + on % 010 );
                         }
                         opsz++;
                         len += 4;
@@ -1341,7 +1337,7 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name )
     return result;
 }
 
-wxString wxMBConv_iconv::ms_wcCharsetName = NULL;
+wxString wxMBConv_iconv::ms_wcCharsetName;
 bool wxMBConv_iconv::ms_wcNeedsSwap = false;
 
 wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
@@ -1369,10 +1365,10 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
 
         for ( ; *names; ++names )
         {
-            const wxString name(*names);
+            const wxString nameCS(*names);
 
             // first try charset with explicit bytesex info (e.g. "UCS-4LE"):
-            wxString nameXE(name);
+            wxString nameXE(nameCS);
             #ifdef WORDS_BIGENDIAN
                 nameXE += _T("BE");
             #else // little endian
@@ -1383,7 +1379,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
             if ( m2w == ICONV_T_INVALID )
             {
                 // try charset w/o bytesex info (e.g. "UCS4")
-                m2w = iconv_open(name.ToAscii(), cname);
+                m2w = iconv_open(nameCS.ToAscii(), cname);
 
                 // and check for bytesex ourselves:
                 if ( m2w != ICONV_T_INVALID )
@@ -1407,11 +1403,12 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
                     if (ICONV_FAILED(res, insz))
                     {
                         wxLogLastError(wxT("iconv"));
-                        wxLogError(_("Conversion to charset '%s' doesn't work."), name);
+                        wxLogError(_("Conversion to charset '%s' doesn't work."),
+                                   nameCS.c_str());
                     }
                     else // ok, can convert to this encoding, remember it
                     {
-                        ms_wcCharsetName = name
+                        ms_wcCharsetName = nameCS;
                         ms_wcNeedsSwap = wbuf[0] != (wchar_t)buf[0];
                     }
                 }
@@ -1424,7 +1421,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
 
         wxLogTrace(TRACE_STRCONV,
                    wxT("iconv wchar_t charset is \"%s\"%s"),
-                   ms_wcCharsetName.empty() ? "<none>"
+                   ms_wcCharsetName.empty() ? _T("<none>")
                                             : ms_wcCharsetName.c_str(),
                    ms_wcNeedsSwap ? _T(" (needs swap)")
                                   : _T(""));
@@ -1445,7 +1442,7 @@ wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
         {
             wxLogTrace(TRACE_STRCONV,
                        wxT("\"%s\" -> \"%s\" works but not the converse!?"),
-                       ms_wcCharsetName.c_str(), cname);
+                       ms_wcCharsetName.c_str(), cname.data());
         }
     }
 }
@@ -1488,8 +1485,8 @@ size_t wxMBConv_iconv::MB2WC(wchar_t *buf, const char *psz, size_t n) const
         if (ms_wcNeedsSwap)
         {
             // convert to native endianness
-            for ( unsigned n = 0; n < res; n++ )
-                buf[n] = WC_BSWAP(buf[n]);
+            for ( unsigned i = 0; i < res; i++ )
+                buf[n] = WC_BSWAP(buf[i]);
         }
 
         // NB: iconv was given only strlen(psz) characters on input, and so
@@ -1533,7 +1530,8 @@ size_t wxMBConv_iconv::WC2MB(char *buf, const wchar_t *psz, size_t n) const
     wxMutexLocker lock(wxConstCast(this, wxMBConv_iconv)->m_iconvMutex);
 #endif
 
-    size_t inbuf = wxWcslen(psz) * SIZEOF_WCHAR_T;
+    size_t inlen = wxWcslen(psz);
+    size_t inbuf = inlen * SIZEOF_WCHAR_T;
     size_t outbuf = n;
     size_t res, cres;
 
@@ -1545,9 +1543,9 @@ size_t wxMBConv_iconv::WC2MB(char *buf, const wchar_t *psz, size_t n) const
         // (doing WC_BSWAP twice on the original buffer won't help, as it
         //  could be in read-only memory, or be accessed in some other thread)
         tmpbuf = (wchar_t *)malloc(inbuf + SIZEOF_WCHAR_T);
-        for ( size_t n = 0; n < inbuf; n++ )
-            tmpbuf[n] = WC_BSWAP(psz[n]);
-        tmpbuf[inbuf] = L'\0';
+        for ( size_t i = 0; i < inlen; i++ )
+            tmpbuf[n] = WC_BSWAP(psz[i]);
+        tmpbuf[inlen] = L'\0';
         psz = tmpbuf;
     }