]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/locresdata.cpp
ICU-64252.0.1.tar.gz
[apple/icu.git] / icuSources / common / locresdata.cpp
index 2c601c28c8811a4cbbd32ad28153c8a0c78d797f..d1d9a4729f107be97d8ff493800b5b94eef0f2a1 100644 (file)
@@ -1,12 +1,14 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1997-2010, International Business Machines
+*   Copyright (C) 1997-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
 *   file name:  loclikely.cpp
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -47,7 +49,6 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
                               UErrorCode *pErrorCode)
 {
 /*    char localeBuffer[ULOC_FULLNAME_CAPACITY*4];*/
-    UResourceBundle *rb=NULL, table, subTable;
     const UChar *item=NULL;
     UErrorCode errorCode;
     char explicitFallbackName[ULOC_FULLNAME_CAPACITY] = {0};
@@ -57,7 +58,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
      * this falls back through the locale's chain to root
      */
     errorCode=U_ZERO_ERROR;
-    rb=ures_open(path, locale, &errorCode);
+    icu::LocalUResourceBundlePointer rb(ures_open(path, locale, &errorCode));
 
     if(U_FAILURE(errorCode)) {
         /* total failure, not even root could be opened */
@@ -71,24 +72,24 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
     }
 
     for(;;){
-        ures_initStackObject(&table);
-        ures_initStackObject(&subTable);
-        ures_getByKeyWithFallback(rb, tableKey, &table, &errorCode);
+        icu::StackUResourceBundle table;
+        icu::StackUResourceBundle subTable;
+        ures_getByKeyWithFallback(rb.getAlias(), tableKey, table.getAlias(), &errorCode);
 
         if (subTableKey != NULL) {
             /*
-            ures_getByKeyWithFallback(&table,subTableKey, &subTable, &errorCode);
-            item = ures_getStringByKeyWithFallback(&subTable, itemKey, pLength, &errorCode);
+            ures_getByKeyWithFallback(table.getAlias(), subTableKey, subTable.getAlias(), &errorCode);
+            item = ures_getStringByKeyWithFallback(subTable.getAlias(), itemKey, pLength, &errorCode);
             if(U_FAILURE(errorCode)){
                 *pErrorCode = errorCode;
             }
             
             break;*/
             
-            ures_getByKeyWithFallback(&table,subTableKey, &table, &errorCode);
+            ures_getByKeyWithFallback(table.getAlias(), subTableKey, table.getAlias(), &errorCode);
         }
         if(U_SUCCESS(errorCode)){
-            item = ures_getStringByKeyWithFallback(&table, itemKey, pLength, &errorCode);
+            item = ures_getStringByKeyWithFallback(table.getAlias(), itemKey, pLength, &errorCode);
             if(U_FAILURE(errorCode)){
                 const char* replacement = NULL;
                 *pErrorCode = errorCode; /*save the errorCode*/
@@ -101,7 +102,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
                 }
                 /*pointer comparison is ok since uloc_getCurrentCountryID & uloc_getCurrentLanguageID return the key itself is replacement is not found*/
                 if(replacement!=NULL && itemKey != replacement){
-                    item = ures_getStringByKeyWithFallback(&table, replacement, pLength, &errorCode);
+                    item = ures_getStringByKeyWithFallback(table.getAlias(), replacement, pLength, &errorCode);
                     if(U_SUCCESS(errorCode)){
                         *pErrorCode = errorCode;
                         break;
@@ -120,7 +121,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
             *pErrorCode = errorCode;
             errorCode = U_ZERO_ERROR;
 
-            fallbackLocale = ures_getStringByKeyWithFallback(&table, "Fallback", &len, &errorCode);
+            fallbackLocale = ures_getStringByKeyWithFallback(table.getAlias(), "Fallback", &len, &errorCode);
             if(U_FAILURE(errorCode)){
                *pErrorCode = errorCode;
                 break;
@@ -133,8 +134,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
                 *pErrorCode = U_INTERNAL_PROGRAM_ERROR;
                 break;
             }
-            ures_close(rb);
-            rb = ures_open(path, explicitFallbackName, &errorCode);
+            rb.adoptInstead(ures_open(path, explicitFallbackName, &errorCode));
             if(U_FAILURE(errorCode)){
                 *pErrorCode = errorCode;
                 break;
@@ -144,10 +144,7 @@ uloc_getTableStringWithFallback(const char *path, const char *locale,
             break;
         }
     }
-    /* done with the locale string - ready to close table and rb */
-    ures_close(&subTable);
-    ures_close(&table);
-    ures_close(rb);
+
     return item;
 }
 
@@ -201,7 +198,7 @@ _uloc_getOrientationHelper(const char* localeId,
     return result;
 }
 
-U_DRAFT ULayoutType U_EXPORT2
+U_CAPI ULayoutType U_EXPORT2
 uloc_getCharacterOrientation(const char* localeId,
                              UErrorCode *status)
 {
@@ -214,9 +211,8 @@ uloc_getCharacterOrientation(const char* localeId,
  * @param localeID locale name
  * @param status Error status
  * @return an enum indicating the layout orientation for lines.
- * @stable ICU 4.0
  */
-U_DRAFT ULayoutType U_EXPORT2
+U_CAPI ULayoutType U_EXPORT2
 uloc_getLineOrientation(const char* localeId,
                         UErrorCode *status)
 {