]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strconv.cpp
don't allocate system fonts/colours dynamically
[wxWidgets.git] / src / common / strconv.cpp
index dd7e60edfbb11c17d9ce69a5b3dd07fc029a93c4..f13005cb373963954ffb3d47d16244583246b2fd 100644 (file)
@@ -111,7 +111,8 @@ static size_t encode_utf16(wxUint32 input, wxUint16 *output)
 {
     if (input<=0xffff)
     {
-        if (output) *output++ = (wxUint16) input;
+        if (output)
+            *output = (wxUint16) input;
         return 1;
     }
     else if (input>=0x110000)
@@ -123,7 +124,7 @@ static size_t encode_utf16(wxUint32 input, wxUint16 *output)
         if (output)
         {
             *output++ = (wxUint16) ((input >> 10)+0xd7c0);
-            *output++ = (wxUint16) ((input&0x3ff)+0xdc00);
+            *output = (wxUint16) ((input&0x3ff)+0xdc00);
         }
         return 2;
     }
@@ -1137,9 +1138,10 @@ public:
                                 buf ? n : 0     // size of output buffer
                              );
 
-        // note that it returns # of written chars for buf != NULL and *size*
-        // of the needed buffer for buf == NULL
-        return len ? (buf ? len : len - 1) : (size_t)-1;
+        // note that it returns count of written chars for buf != NULL and size
+        // of the needed buffer for buf == NULL so in either case the length of
+        // the string (which never includes the terminating NUL) is one less
+        return len ? len - 1 : (size_t)-1;
     }
 
     size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const
@@ -1156,8 +1158,8 @@ public:
                                 NULL            // [out] was it used?
                              );
 
-        // see the comment above!
-        return len ? (buf ? len : len - 1) : (size_t)-1;
+        // see the comment above for the reason of "len - 1"
+        return len ? len - 1 : (size_t)-1;
     }
 
     bool IsOk() const
@@ -1388,18 +1390,12 @@ wxMBConv *wxCSConv::DoCreate() const
         case wxFONTENCODING_UTF8:
              return new wxMBConvUTF8;
 
-        case wxFONTENCODING_UTF16:
-             return new wxMBConvUTF16;
-
         case wxFONTENCODING_UTF16BE:
              return new wxMBConvUTF16BE;
 
         case wxFONTENCODING_UTF16LE:
              return new wxMBConvUTF16LE;
 
-        case wxFONTENCODING_UTF32:
-             return new wxMBConvUTF32;
-
         case wxFONTENCODING_UTF32BE:
              return new wxMBConvUTF32BE;