Remove workaround for pre-10.2 systems in nsLocalFileOSX, no need to look for CFStringNormalize. b=490959 r=mstange sr=roc
authorJosh Aas <joshmoz@gmail.com>
Fri, 01 May 2009 09:59:33 -0700
changeset 27937 f32cd8660af5b847d3611c06168c27b0ed81ecd4
parent 27936 66c6b924875d1df154f3012ea40fde5846fef821
child 27938 30f91b70a4411e0766d96d23cd63fa2a6e4445e4
push id6786
push userjosh@mozilla.com
push dateFri, 01 May 2009 16:57:29 +0000
treeherdermozilla-central@f32cd8660af5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, roc
bugs490959
milestone1.9.2a1pre
Remove workaround for pre-10.2 systems in nsLocalFileOSX, no need to look for CFStringNormalize. b=490959 r=mstange sr=roc
xpcom/io/nsLocalFileOSX.mm
--- a/xpcom/io/nsLocalFileOSX.mm
+++ b/xpcom/io/nsLocalFileOSX.mm
@@ -2418,67 +2418,47 @@ static nsresult MacErrorMapper(OSErr inE
     }
     return outErr;
 }
 
 // Convert a UTF-8 string to a UTF-16 string while normalizing to
 // Normalization Form C (composed Unicode). We need this because
 // Mac OS X file system uses NFD (Normalization Form D : decomposed Unicode)
 // while most other OS', server-side programs usually expect NFC.
-
-typedef void (*UnicodeNormalizer) (CFMutableStringRef, CFStringNormalizationForm);
 static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult)
 {
-    NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-    static PRBool sChecked = PR_FALSE;
-    static UnicodeNormalizer sUnicodeNormalizer = NULL;
-
-    // CFStringNormalize was not introduced until Mac OS 10.2
-    if (!sChecked) {
-        CFBundleRef carbonBundle =
-            CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon"));
-        if (carbonBundle)
-            sUnicodeNormalizer = (UnicodeNormalizer)
-                ::CFBundleGetFunctionPointerForName(carbonBundle,
-                                                    CFSTR("CFStringNormalize"));
-        sChecked = PR_TRUE;
-    }
-
-    if (!sUnicodeNormalizer) {  // OS X 10.2 or earlier
-        CopyUTF8toUTF16(aSrc, aResult);
-        return;  
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+  const nsAFlatCString &inFlatSrc = PromiseFlatCString(aSrc);
+
+  // The number of 16bit code units in a UTF-16 string will never be
+  // larger than the number of bytes in the corresponding UTF-8 string.
+  CFMutableStringRef inStr = ::CFStringCreateMutable(NULL, inFlatSrc.Length());
+
+  if (!inStr) {
+    CopyUTF8toUTF16(aSrc, aResult);
+    return;
+  }
+
+  ::CFStringAppendCString(inStr, inFlatSrc.get(), kCFStringEncodingUTF8);
+
+  ::CFStringNormalize(inStr, kCFStringNormalizationFormC);
+
+  CFIndex length = ::CFStringGetLength(inStr);
+  const UniChar* chars = ::CFStringGetCharactersPtr(inStr);
+
+  if (chars) {
+    aResult.Assign(chars, length);
+  }
+  else {
+    nsAutoTArray<UniChar, FILENAME_BUFFER_SIZE> buffer;
+    if (!buffer.SetLength(length)) {
+      CopyUTF8toUTF16(aSrc, aResult);
     }
-
-    const nsAFlatCString &inFlatSrc = PromiseFlatCString(aSrc);
-
-    // The number of 16bit code units in a UTF-16 string will never be
-    // larger than the number of bytes in the corresponding UTF-8 string.
-    CFMutableStringRef inStr =
-        ::CFStringCreateMutable(NULL, inFlatSrc.Length());
-
-    if (!inStr) {
-        CopyUTF8toUTF16(aSrc, aResult);
-        return;  
+    else {
+      ::CFStringGetCharacters(inStr, ::CFRangeMake(0, length), buffer.Elements());
+      aResult.Assign(buffer.Elements(), length);
     }
-     
-    ::CFStringAppendCString(inStr, inFlatSrc.get(), kCFStringEncodingUTF8); 
-
-    sUnicodeNormalizer(inStr, kCFStringNormalizationFormC);
-
-    CFIndex length = CFStringGetLength(inStr);
-    const UniChar* chars = CFStringGetCharactersPtr(inStr);
-
-    if (chars) 
-        aResult.Assign(chars, length);
-    else {
-        nsAutoTArray<UniChar, FILENAME_BUFFER_SIZE> buffer;
-        if (!buffer.SetLength(length))
-            CopyUTF8toUTF16(aSrc, aResult);
-        else {
-            CFStringGetCharacters(inStr, CFRangeMake(0, length), buffer.Elements());
-            aResult.Assign(buffer.Elements(), length);
-        }
-    }
-    CFRelease(inStr);
-
-    NS_OBJC_END_TRY_ABORT_BLOCK;
+  }
+  ::CFRelease(inStr);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }