Bug 744541. r=bz
authorMats Palmgren <matspal@gmail.com>
Tue, 17 Apr 2012 18:53:06 +0200
changeset 91874 6c0fdf2079a96dc609f000d5f4943d181de5c144
parent 91873 4a5d25e138e23585c50cf6fdd1f2093908f92da2
child 91875 328b56d0b34c1a66427111df96a2f98d45e71f5b
push id22480
push useremorley@mozilla.com
push dateWed, 18 Apr 2012 00:48:48 +0000
treeherdermozilla-central@93dfd98900ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs744541
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 744541. r=bz
xpcom/io/nsNativeCharsetUtils.cpp
--- a/xpcom/io/nsNativeCharsetUtils.cpp
+++ b/xpcom/io/nsNativeCharsetUtils.cpp
@@ -559,19 +559,19 @@ nsNativeCharsetConverter::UnicodeToNativ
 {
     size_t res = 0;
     size_t inLeft = (size_t) *inputLeft * 2;
     size_t outLeft = (size_t) *outputLeft;
 
     if (gUnicodeToNative != INVALID_ICONV_T) {
         res = xp_iconv(gUnicodeToNative, (const char **) input, &inLeft, output, &outLeft);
 
+        *inputLeft = inLeft / 2;
+        *outputLeft = outLeft;
         if (res != (size_t) -1) {
-            *inputLeft = inLeft / 2;
-            *outputLeft = outLeft;
             return NS_OK;
         }
 
         NS_ERROR("iconv failed");
 
         // reset converter
         xp_iconv_reset(gUnicodeToNative);
     }
@@ -602,30 +602,31 @@ nsNativeCharsetConverter::UnicodeToNativ
                 }
                 else
                     NS_ERROR("conversion from utf-8 to native failed");
                 break;
             }
             inLeft -= sizeof(PRUnichar);
         }
 
+        (*input) += (*inputLeft - inLeft / 2);
+        *inputLeft = inLeft / 2;
+        *outputLeft = outLeft;
         if (res != (size_t) -1) {
-            (*input) += (*inputLeft - inLeft/2);
-            *inputLeft = inLeft/2;
-            *outputLeft = outLeft;
             return NS_OK;
         }
 
         // reset converters
         xp_iconv_reset(gUnicodeToUTF8);
         xp_iconv_reset(gUTF8ToNative);
     }
 #endif
 
     // fallback: truncate and hope for the best
+    // XXX This is lame and we have to do better.
     utf16_to_isolatin1(input, inputLeft, output, outputLeft);
 
     return NS_OK;
 }
 
 bool
 nsNativeCharsetConverter::IsNativeUTF8()
 {