From a1992932b5aa53a9d1f1a8ad7f9ef63683ab55e4 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Tue, 28 Jul 2009 21:38:28 +0000 Subject: [PATCH] ICU-6708 Fix tab character format issue. X-SVN-Rev: 26452 --- icu4c/source/i18n/numfmt.cpp | 114 +++++++++++++++++------------------ 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/icu4c/source/i18n/numfmt.cpp b/icu4c/source/i18n/numfmt.cpp index f3f0515d59b..1963a82f83f 100644 --- a/icu4c/source/i18n/numfmt.cpp +++ b/icu4c/source/i18n/numfmt.cpp @@ -956,69 +956,69 @@ NumberFormat::makeInstance(const Locale& desiredLocale, // Use numbering system cache hashtable UMTX_CHECK(NULL, (UBool)(cache != NumberingSystem_cache), getCache); if (getCache) { - umtx_lock(NULL); - cache = NumberingSystem_cache; - umtx_unlock(NULL); - } - + umtx_lock(NULL); + cache = NumberingSystem_cache; + umtx_unlock(NULL); + } + // Check cache we got, create if non-existant - status = U_ZERO_ERROR; - if (cache == NULL) { - cache = uhash_open(uhash_hashLong, - uhash_compareLong, - NULL, - &status); - - if (cache == NULL || U_FAILURE(status)) { - // cache not created - out of memory - cache = NULL; - } - else { - // cache created + status = U_ZERO_ERROR; + if (cache == NULL) { + cache = uhash_open(uhash_hashLong, + uhash_compareLong, + NULL, + &status); + + if (cache == NULL || U_FAILURE(status)) { + // cache not created - out of memory + cache = NULL; + } + else { + // cache created uhash_setValueDeleter(cache, deleteNumberingSystem); - - // set final NumberingSystem_cache value - UHashtable* h; + + // set final NumberingSystem_cache value + UHashtable* h; UMTX_CHECK(NULL, (UBool)(h != NumberingSystem_cache), getCache); if (getCache) { - umtx_lock(NULL); - h = NumberingSystem_cache; - if (h == NULL) { - NumberingSystem_cache = h = cache; - cache = NULL; - ucln_i18n_registerCleanup(UCLN_I18N_NUMFMT, NSCache_cleanup); - } - umtx_unlock(NULL); - } - - if(cache != NULL) { - delete cache; - } - cache = h; - } - } - - // Get cached numbering system - if (cache != NULL) { - hashKey = desiredLocale.hashCode(); - UMTX_CHECK(NULL, (UBool)(ns == NULL), getCache); - if (getCache) { - umtx_lock(NULL); - ns = (NumberingSystem *)uhash_iget(cache, hashKey); - if (ns == NULL) { - ns = NumberingSystem::createInstance(desiredLocale,status); - uhash_iput(cache, hashKey, (void*)ns, &status); - } - umtx_unlock(NULL); - } - } - else { - ns = NumberingSystem::createInstance(desiredLocale,status); - } - + umtx_lock(NULL); + h = NumberingSystem_cache; + if (h == NULL) { + NumberingSystem_cache = h = cache; + cache = NULL; + ucln_i18n_registerCleanup(UCLN_I18N_NUMFMT, NSCache_cleanup); + } + umtx_unlock(NULL); + } + + if(cache != NULL) { + delete cache; + } + cache = h; + } + } + + // Get cached numbering system + if (cache != NULL) { + hashKey = desiredLocale.hashCode(); + UMTX_CHECK(NULL, (UBool)(ns == NULL), getCache); + if (getCache) { + umtx_lock(NULL); + ns = (NumberingSystem *)uhash_iget(cache, hashKey); + if (ns == NULL) { + ns = NumberingSystem::createInstance(desiredLocale,status); + uhash_iput(cache, hashKey, (void*)ns, &status); + } + umtx_unlock(NULL); + } + } + else { + ns = NumberingSystem::createInstance(desiredLocale,status); + } + // check results of getting a numbering system - if ((ns == NULL) || (U_FAILURE(status))) { + if ((ns == NULL) || (U_FAILURE(status))) { goto cleanup; }