]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/anytrans.cpp
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / i18n / anytrans.cpp
index bd76fe148a74e28f0c6583aaffe23eb9c116a3ed..c3b3b67c25ce89940e210fcc4375590bf99834d0 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *****************************************************************
-* Copyright (c) 2002-2005, International Business Machines Corporation
+* Copyright (c) 2002-2011, International Business Machines Corporation
 * and others.  All Rights Reserved.
 *****************************************************************
 * Date        Name        Description
@@ -39,7 +39,7 @@ U_CDECL_BEGIN
  */
 static void U_CALLCONV
 _deleteTransliterator(void *obj) {
-    delete (Transliterator*) obj;    
+    delete (icu::Transliterator*) obj;    
 }
 U_CDECL_END
 
@@ -183,6 +183,9 @@ AnyTransliterator::AnyTransliterator(const UnicodeString& id,
     targetScript(theTargetScript) 
 {
     cache = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &ec);
+    if (U_FAILURE(ec)) {
+        return;
+    }
     uhash_setValueDeleter(cache, _deleteTransliterator);
 
     target = theTarget;
@@ -206,6 +209,9 @@ AnyTransliterator::AnyTransliterator(const AnyTransliterator& o) :
     // Don't copy the cache contents
     UErrorCode ec = U_ZERO_ERROR;
     cache = uhash_open(uhash_hashLong, uhash_compareLong, NULL, &ec);
+    if (U_FAILURE(ec)) {
+        return;
+    }
     uhash_setValueDeleter(cache, _deleteTransliterator);
 }
 
@@ -282,7 +288,7 @@ Transliterator* AnyTransliterator::getTransliterator(UScriptCode source) const {
             
             // Try to pivot around Latin, our most common script
             id = sourceName;
-            id.append(LATIN_PIVOT).append(target);
+            id.append(LATIN_PIVOT, -1).append(target);
             t = Transliterator::createInstance(id, UTRANS_FORWARD, ec);
             if (U_FAILURE(ec) || t == NULL) {
                 delete t;
@@ -335,7 +341,7 @@ void AnyTransliterator::registerIDs() {
         Transliterator::_getAvailableSource(s, source);
 
         // Ignore the "Any" source
-        if (source.caseCompare(ANY, 0 /*U_FOLD_CASE_DEFAULT*/) == 0) continue;
+        if (source.caseCompare(ANY, 3, 0 /*U_FOLD_CASE_DEFAULT*/) == 0) continue;
 
         int32_t targetCount = Transliterator::_countAvailableTargets(source);
         for (int32_t t=0; t<targetCount; ++t) {
@@ -358,7 +364,7 @@ void AnyTransliterator::registerIDs() {
                 Transliterator::_getAvailableVariant(v, source, target, variant);
                 
                 UnicodeString id;
-                TransliteratorIDParser::STVtoID(ANY, target, variant, id);
+                TransliteratorIDParser::STVtoID(UnicodeString(TRUE, ANY, 3), target, variant, id);
                 ec = U_ZERO_ERROR;
                 AnyTransliterator* t = new AnyTransliterator(id, target, variant,
                                                              targetScript, ec);
@@ -366,7 +372,7 @@ void AnyTransliterator::registerIDs() {
                     delete t;
                 } else {
                     Transliterator::_registerInstance(t);
-                    Transliterator::_registerSpecialInverse(target, NULL_ID, FALSE);
+                    Transliterator::_registerSpecialInverse(target, UnicodeString(TRUE, NULL_ID, 4), FALSE);
                 }
             }
         }