mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-10799 ICU initialization code, review & cleanup.
X-SVN-Rev: 35649
This commit is contained in:
parent
3cc66e5be4
commit
dbcf79f57b
33 changed files with 134 additions and 168 deletions
|
@ -333,11 +333,8 @@
|
|||
<ClCompile Include="ucnvsel.cpp">
|
||||
</ClCompile>
|
||||
<ClCompile Include="cmemory.c" />
|
||||
<ClCompile Include="ucln_cmn.c">
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>
|
||||
<ClCompile Include="ucln_cmn.cpp">
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucmndata.c" />
|
||||
<ClCompile Include="udata.cpp" />
|
||||
|
|
|
@ -247,7 +247,7 @@
|
|||
<ClCompile Include="sharedobject.cpp">
|
||||
<Filter>data & memory</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucln_cmn.c">
|
||||
<ClCompile Include="ucln_cmn.cpp">
|
||||
<Filter>data & memory</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucmndata.c">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1997-2012, International Business Machines
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*
|
||||
|
@ -50,7 +50,8 @@ U_CDECL_END
|
|||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
static Locale *gLocaleCache = NULL;
|
||||
static Locale *gLocaleCache = NULL;
|
||||
static UInitOnce gLocaleCacheInitOnce = U_INITONCE_INITIALIZER;
|
||||
|
||||
// gDefaultLocaleMutex protects all access to gDefaultLocalesHashT and gDefaultLocale.
|
||||
static UMutex gDefaultLocaleMutex = U_MUTEX_INITIALIZER;
|
||||
|
@ -106,19 +107,50 @@ static UBool U_CALLCONV locale_cleanup(void)
|
|||
{
|
||||
U_NAMESPACE_USE
|
||||
|
||||
if (gLocaleCache) {
|
||||
delete [] gLocaleCache;
|
||||
gLocaleCache = NULL;
|
||||
}
|
||||
delete [] gLocaleCache;
|
||||
gLocaleCache = NULL;
|
||||
gLocaleCacheInitOnce.reset();
|
||||
|
||||
if (gDefaultLocalesHashT) {
|
||||
uhash_close(gDefaultLocalesHashT); // Automatically deletes all elements, using deleter func.
|
||||
gDefaultLocalesHashT = NULL;
|
||||
gDefaultLocale = NULL;
|
||||
}
|
||||
|
||||
gDefaultLocale = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void U_CALLCONV locale_init(UErrorCode &status) {
|
||||
U_NAMESPACE_USE
|
||||
|
||||
U_ASSERT(gLocaleCache == NULL);
|
||||
gLocaleCache = new Locale[(int)eMAX_LOCALES];
|
||||
if (gLocaleCache == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
ucln_common_registerCleanup(UCLN_COMMON_LOCALE, locale_cleanup);
|
||||
gLocaleCache[eROOT] = Locale("");
|
||||
gLocaleCache[eENGLISH] = Locale("en");
|
||||
gLocaleCache[eFRENCH] = Locale("fr");
|
||||
gLocaleCache[eGERMAN] = Locale("de");
|
||||
gLocaleCache[eITALIAN] = Locale("it");
|
||||
gLocaleCache[eJAPANESE] = Locale("ja");
|
||||
gLocaleCache[eKOREAN] = Locale("ko");
|
||||
gLocaleCache[eCHINESE] = Locale("zh");
|
||||
gLocaleCache[eFRANCE] = Locale("fr", "FR");
|
||||
gLocaleCache[eGERMANY] = Locale("de", "DE");
|
||||
gLocaleCache[eITALY] = Locale("it", "IT");
|
||||
gLocaleCache[eJAPAN] = Locale("ja", "JP");
|
||||
gLocaleCache[eKOREA] = Locale("ko", "KR");
|
||||
gLocaleCache[eCHINA] = Locale("zh", "CN");
|
||||
gLocaleCache[eTAIWAN] = Locale("zh", "TW");
|
||||
gLocaleCache[eUK] = Locale("en", "GB");
|
||||
gLocaleCache[eUS] = Locale("en", "US");
|
||||
gLocaleCache[eCANADA] = Locale("en", "CA");
|
||||
gLocaleCache[eCANADA_FRENCH] = Locale("fr", "CA");
|
||||
}
|
||||
|
||||
U_CDECL_END
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
@ -126,7 +158,7 @@ U_NAMESPACE_BEGIN
|
|||
Locale *locale_set_default_internal(const char *id, UErrorCode& status) {
|
||||
// Synchronize this entire function.
|
||||
Mutex lock(&gDefaultLocaleMutex);
|
||||
|
||||
|
||||
UBool canonicalize = FALSE;
|
||||
|
||||
// If given a NULL string for the locale id, grab the default
|
||||
|
@ -842,46 +874,8 @@ initialization and static destruction.
|
|||
Locale *
|
||||
Locale::getLocaleCache(void)
|
||||
{
|
||||
umtx_lock(NULL);
|
||||
UBool needInit = (gLocaleCache == NULL);
|
||||
umtx_unlock(NULL);
|
||||
|
||||
if (needInit) {
|
||||
Locale *tLocaleCache = new Locale[(int)eMAX_LOCALES];
|
||||
if (tLocaleCache == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
tLocaleCache[eROOT] = Locale("");
|
||||
tLocaleCache[eENGLISH] = Locale("en");
|
||||
tLocaleCache[eFRENCH] = Locale("fr");
|
||||
tLocaleCache[eGERMAN] = Locale("de");
|
||||
tLocaleCache[eITALIAN] = Locale("it");
|
||||
tLocaleCache[eJAPANESE] = Locale("ja");
|
||||
tLocaleCache[eKOREAN] = Locale("ko");
|
||||
tLocaleCache[eCHINESE] = Locale("zh");
|
||||
tLocaleCache[eFRANCE] = Locale("fr", "FR");
|
||||
tLocaleCache[eGERMANY] = Locale("de", "DE");
|
||||
tLocaleCache[eITALY] = Locale("it", "IT");
|
||||
tLocaleCache[eJAPAN] = Locale("ja", "JP");
|
||||
tLocaleCache[eKOREA] = Locale("ko", "KR");
|
||||
tLocaleCache[eCHINA] = Locale("zh", "CN");
|
||||
tLocaleCache[eTAIWAN] = Locale("zh", "TW");
|
||||
tLocaleCache[eUK] = Locale("en", "GB");
|
||||
tLocaleCache[eUS] = Locale("en", "US");
|
||||
tLocaleCache[eCANADA] = Locale("en", "CA");
|
||||
tLocaleCache[eCANADA_FRENCH] = Locale("fr", "CA");
|
||||
|
||||
umtx_lock(NULL);
|
||||
if (gLocaleCache == NULL) {
|
||||
gLocaleCache = tLocaleCache;
|
||||
tLocaleCache = NULL;
|
||||
ucln_common_registerCleanup(UCLN_COMMON_LOCALE, locale_cleanup);
|
||||
}
|
||||
umtx_unlock(NULL);
|
||||
if (tLocaleCache) {
|
||||
delete [] tLocaleCache; // Fancy array delete will destruct each member.
|
||||
}
|
||||
}
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
umtx_initOnce(gLocaleCacheInitOnce, locale_init, status);
|
||||
return gLocaleCache;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2011, International Business Machines Corporation and
|
||||
* Copyright (C) 2002-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@
|
|||
#include "umutex.h"
|
||||
|
||||
// see LocaleUtility::getAvailableLocaleNames
|
||||
static icu::UInitOnce LocaleUtilityInitOnce = U_INITONCE_INITIALIZER;
|
||||
static icu::Hashtable * LocaleUtility_cache = NULL;
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
|
@ -39,6 +40,25 @@ static UBool U_CALLCONV service_cleanup(void) {
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void U_CALLCONV locale_utility_init(UErrorCode &status) {
|
||||
using namespace icu;
|
||||
U_ASSERT(LocaleUtility_cache == NULL);
|
||||
ucln_common_registerCleanup(UCLN_COMMON_SERVICE, service_cleanup);
|
||||
LocaleUtility_cache = new Hashtable(status);
|
||||
if (U_FAILURE(status)) {
|
||||
delete LocaleUtility_cache;
|
||||
LocaleUtility_cache = NULL;
|
||||
return;
|
||||
}
|
||||
if (LocaleUtility_cache == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
LocaleUtility_cache->setValueDeleter(uhash_deleteHashtable);
|
||||
}
|
||||
|
||||
U_CDECL_END
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
@ -189,34 +209,13 @@ LocaleUtility::getAvailableLocaleNames(const UnicodeString& bundleID)
|
|||
// garbage ((void*)1 or other random pointer).
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Hashtable* cache;
|
||||
umtx_lock(NULL);
|
||||
cache = LocaleUtility_cache;
|
||||
umtx_unlock(NULL);
|
||||
|
||||
umtx_initOnce(LocaleUtilityInitOnce, locale_utility_init, status);
|
||||
Hashtable *cache = LocaleUtility_cache;
|
||||
if (cache == NULL) {
|
||||
cache = new Hashtable(status);
|
||||
if (cache == NULL || U_FAILURE(status)) {
|
||||
return NULL; // catastrophic failure; e.g. out of memory
|
||||
}
|
||||
cache->setValueDeleter(uhash_deleteHashtable);
|
||||
Hashtable* h; // set this to final LocaleUtility_cache value
|
||||
umtx_lock(NULL);
|
||||
h = LocaleUtility_cache;
|
||||
if (h == NULL) {
|
||||
LocaleUtility_cache = h = cache;
|
||||
cache = NULL;
|
||||
ucln_common_registerCleanup(UCLN_COMMON_SERVICE, service_cleanup);
|
||||
}
|
||||
umtx_unlock(NULL);
|
||||
if(cache != NULL) {
|
||||
delete cache;
|
||||
}
|
||||
cache = h;
|
||||
// Catastrophic failure.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U_ASSERT(cache != NULL);
|
||||
|
||||
Hashtable* htp;
|
||||
umtx_lock(NULL);
|
||||
htp = (Hashtable*) cache->get(bundleID);
|
||||
|
@ -241,6 +240,7 @@ LocaleUtility::getAvailableLocaleNames(const UnicodeString& bundleID)
|
|||
delete htp;
|
||||
return NULL;
|
||||
}
|
||||
// See ticket #10803
|
||||
umtx_lock(NULL);
|
||||
cache->put(bundleID, (void*)htp, status);
|
||||
umtx_unlock(NULL);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2011, International Business Machines
|
||||
* Copyright (c) 2002-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
|
@ -16,7 +16,6 @@
|
|||
#include "umutex.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "uarrsort.h"
|
||||
#include "uinvchar.h"
|
||||
|
||||
|
|
|
@ -1743,8 +1743,6 @@ int32_t RuleBasedBreakIterator::checkDictionary(int32_t startPos,
|
|||
return (reverse ? startPos : endPos);
|
||||
}
|
||||
|
||||
// defined in ucln_cmn.h
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
#include "ustrfmt.h"
|
||||
#include "uhash.h"
|
||||
#include "charstr.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "uassert.h"
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2012, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -16,7 +16,6 @@
|
|||
#include "servloc.h"
|
||||
#include "ustrfmt.h"
|
||||
#include "charstr.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "uassert.h"
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
#include "ustrfmt.h"
|
||||
#include "uhash.h"
|
||||
#include "charstr.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "uassert.h"
|
||||
|
||||
#define UNDERSCORE_CHAR ((UChar)0x005f)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2004-2012, International Business Machines
|
||||
* Copyright (C) 2004-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
|
@ -29,7 +29,6 @@
|
|||
#include "cmemory.h"
|
||||
#include "utrie2.h"
|
||||
#include "ucase.h"
|
||||
#include "ucln_cmn.h"
|
||||
|
||||
struct UCaseProps {
|
||||
UDataMemory *mem;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2001-2013, International Business Machines
|
||||
* Copyright (C) 2001-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
* file name: ucln_cmn.c
|
||||
* file name: ucln_cmn.cpp
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
|
@ -84,11 +84,11 @@ ucln_registerCleanup(ECleanupLibraryType type,
|
|||
}
|
||||
|
||||
U_CFUNC UBool ucln_lib_cleanup(void) {
|
||||
ECleanupLibraryType libType = UCLN_START;
|
||||
ECleanupCommonType commonFunc = UCLN_COMMON_START;
|
||||
int32_t libType = UCLN_START;
|
||||
int32_t commonFunc = UCLN_COMMON_START;
|
||||
|
||||
for (libType++; libType<UCLN_COMMON; libType++) {
|
||||
ucln_cleanupOne(libType);
|
||||
ucln_cleanupOne(static_cast<ECleanupLibraryType>(libType));
|
||||
}
|
||||
|
||||
for (commonFunc++; commonFunc<UCLN_COMMON_COUNT; commonFunc++) {
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* *
|
||||
* Copyright (C) 2001-2013, International Business Machines *
|
||||
* Copyright (C) 2001-2014, International Business Machines *
|
||||
* Corporation and others. All Rights Reserved. *
|
||||
* *
|
||||
******************************************************************************
|
||||
|
@ -56,6 +56,7 @@ typedef enum ECleanupCommonType {
|
|||
|
||||
/* Main library cleanup registration function. */
|
||||
/* See common/ucln.h for details on adding a cleanup function. */
|
||||
/* Note: the global mutex must not be held when calling this function. */
|
||||
U_CFUNC void U_EXPORT2 ucln_common_registerCleanup(ECleanupCommonType type,
|
||||
cleanupFunc *func);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2013, International Business Machines
|
||||
* Copyright (C) 1999-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
|
@ -178,7 +178,6 @@ setCommonICUData(UDataMemory *pData, /* The new common data. Belongs to ca
|
|||
for (i = 0; i < LENGTHOF(gCommonICUDataArray); ++i) {
|
||||
if (gCommonICUDataArray[i] == NULL) {
|
||||
gCommonICUDataArray[i] = newCommonData;
|
||||
ucln_common_registerCleanup(UCLN_COMMON_UDATA, udata_cleanup);
|
||||
didUpdate = TRUE;
|
||||
break;
|
||||
} else if (gCommonICUDataArray[i]->pHeader == pData->pHeader) {
|
||||
|
@ -191,7 +190,9 @@ setCommonICUData(UDataMemory *pData, /* The new common data. Belongs to ca
|
|||
if (i == LENGTHOF(gCommonICUDataArray) && warn) {
|
||||
*pErr = U_USING_DEFAULT_WARNING;
|
||||
}
|
||||
if (!didUpdate) {
|
||||
if (didUpdate) {
|
||||
ucln_common_registerCleanup(UCLN_COMMON_UDATA, udata_cleanup);
|
||||
} else {
|
||||
uprv_free(newCommonData);
|
||||
}
|
||||
return didUpdate;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1997-2013, International Business Machines
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*
|
||||
|
@ -38,7 +38,6 @@
|
|||
#include "umutex.h"
|
||||
#include "cstring.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "locmap.h"
|
||||
#include "uarrsort.h"
|
||||
#include "uenumimp.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2013, International Business Machines
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
|
@ -23,7 +23,6 @@
|
|||
#include "unicode/utypes.h"
|
||||
#include "uassert.h"
|
||||
#include "cmemory.h"
|
||||
#include "ucln_cmn.h"
|
||||
|
||||
|
||||
// The ICU global mutex. Used when ICU implementation code passes NULL for the mutex pointer.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2013, International Business Machines
|
||||
* Copyright (C) 2002-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
|
@ -28,7 +28,6 @@
|
|||
#include "unicode/ustring.h"
|
||||
#include "cstring.h"
|
||||
#include "normalizer2impl.h"
|
||||
#include "ucln_cmn.h"
|
||||
#include "umutex.h"
|
||||
#include "ubidi_props.h"
|
||||
#include "uprops.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2007-2013, International Business Machines Corporation
|
||||
* Copyright (C) 2007-2014, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -49,10 +49,13 @@ static void debug_chnsecal_msg(const char *pat, ...)
|
|||
|
||||
|
||||
// --- The cache --
|
||||
static UMutex astroLock = U_MUTEX_INITIALIZER; // pod bay door lock
|
||||
static UMutex astroLock = U_MUTEX_INITIALIZER; // Protects access to gChineseCalendarAstro.
|
||||
static icu::CalendarAstronomer *gChineseCalendarAstro = NULL;
|
||||
|
||||
// Lazy Creation & Access synchronized by class CalendarCache with a mutex.
|
||||
static icu::CalendarCache *gChineseCalendarWinterSolsticeCache = NULL;
|
||||
static icu::CalendarCache *gChineseCalendarNewYearCache = NULL;
|
||||
|
||||
static icu::TimeZone *gChineseCalendarZoneAstroCalc = NULL;
|
||||
static icu::UInitOnce gChineseCalendarZoneAstroCalcInitOnce = U_INITONCE_INITIALIZER;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "unicode/msgfmt.h"
|
||||
#include "unicode/tznames.h"
|
||||
#include "cpputils.h"
|
||||
#include "ucln_in.h"
|
||||
#include "umutex.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "unicode/ustring.h"
|
||||
#include "unicode/rep.h"
|
||||
#include "cpputils.h"
|
||||
#include "ucln_in.h"
|
||||
#include "mutex.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
|
|
|
@ -396,11 +396,8 @@
|
|||
<ClCompile Include="zonemeta.cpp" />
|
||||
<ClCompile Include="zrule.cpp" />
|
||||
<ClCompile Include="ztrans.cpp" />
|
||||
<ClCompile Include="ucln_in.c">
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>
|
||||
<ClCompile Include="ucln_in.cpp">
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="regexcmp.cpp" />
|
||||
<ClCompile Include="regeximp.cpp" />
|
||||
|
|
|
@ -321,7 +321,7 @@
|
|||
<ClCompile Include="ztrans.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucln_in.c">
|
||||
<ClCompile Include="ucln_in.cpp">
|
||||
<Filter>misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="regexcmp.cpp">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2009, International Business Machines Corporation
|
||||
* Copyright (C) 2003-2014, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*
|
||||
|
@ -16,7 +16,6 @@
|
|||
#include "gregoimp.h" // Math
|
||||
#include "astro.h" // CalendarAstronomer
|
||||
#include "uhash.h"
|
||||
#include "ucln_in.h"
|
||||
|
||||
// Debugging
|
||||
#ifdef U_DEBUG_INDIANCAL
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "uvectr32.h"
|
||||
#include "uvectr64.h"
|
||||
#include "uassert.h"
|
||||
#include "ucln_in.h"
|
||||
#include "uinvchar.h"
|
||||
|
||||
#include "regeximp.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2012, International Business Machines
|
||||
* Copyright (C) 1999-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
|
@ -1619,7 +1619,7 @@ UBool Transliterator::initializeRegistry(UErrorCode &status) {
|
|||
|
||||
U_NAMESPACE_END
|
||||
|
||||
// Defined in ucln_in.h:
|
||||
// Defined in transreg.h:
|
||||
|
||||
/**
|
||||
* Release all static memory held by transliterator. This will
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2001-2008, International Business Machines
|
||||
* Copyright (c) 2001-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
|
@ -456,6 +456,8 @@ class TransliteratorRegistry : public UMemory {
|
|||
|
||||
U_NAMESPACE_END
|
||||
|
||||
U_CFUNC UBool utrans_transliterator_cleanup(void);
|
||||
|
||||
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2012, International Business Machines Corporation
|
||||
* Copyright (c) 2002-2014, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
|
@ -15,6 +15,8 @@
|
|||
#include "tridpars.h"
|
||||
#include "hash.h"
|
||||
#include "mutex.h"
|
||||
#include "transreg.h"
|
||||
#include "uassert.h"
|
||||
#include "ucln_in.h"
|
||||
#include "unicode/parsepos.h"
|
||||
#include "unicode/translit.h"
|
||||
|
@ -41,6 +43,7 @@ static const int32_t FORWARD = UTRANS_FORWARD;
|
|||
static const int32_t REVERSE = UTRANS_REVERSE;
|
||||
|
||||
static Hashtable* SPECIAL_INVERSES = NULL;
|
||||
static UInitOnce gSpecialInversesInitOnce = U_INITONCE_INITIALIZER;
|
||||
|
||||
/**
|
||||
* The mutex controlling access to SPECIAL_INVERSES
|
||||
|
@ -644,7 +647,7 @@ void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target,
|
|||
const UnicodeString& inverseTarget,
|
||||
UBool bidirectional,
|
||||
UErrorCode &status) {
|
||||
init(status);
|
||||
umtx_initOnce(gSpecialInversesInitOnce, init, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
|
@ -851,7 +854,10 @@ TransliteratorIDParser::specsToSpecialInverse(const Specs& specs, UErrorCode &st
|
|||
if (0!=specs.source.caseCompare(ANY, 3, U_FOLD_CASE_DEFAULT)) {
|
||||
return NULL;
|
||||
}
|
||||
init(status);
|
||||
umtx_initOnce(gSpecialInversesInitOnce, init, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UnicodeString* inverseTarget;
|
||||
|
||||
|
@ -894,30 +900,18 @@ Transliterator* TransliteratorIDParser::createBasicInstance(const UnicodeString&
|
|||
}
|
||||
|
||||
/**
|
||||
* Initialize static memory.
|
||||
* Initialize static memory. Called through umtx_initOnce only.
|
||||
*/
|
||||
void TransliteratorIDParser::init(UErrorCode &status) {
|
||||
if (SPECIAL_INVERSES != NULL) {
|
||||
return;
|
||||
}
|
||||
U_ASSERT(SPECIAL_INVERSES == NULL);
|
||||
ucln_i18n_registerCleanup(UCLN_I18N_TRANSLITERATOR, utrans_transliterator_cleanup);
|
||||
|
||||
Hashtable* special_inverses = new Hashtable(TRUE, status);
|
||||
// Null pointer check
|
||||
if (special_inverses == NULL) {
|
||||
SPECIAL_INVERSES = new Hashtable(TRUE, status);
|
||||
if (SPECIAL_INVERSES == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
special_inverses->setValueDeleter(uprv_deleteUObject);
|
||||
|
||||
umtx_lock(&LOCK);
|
||||
if (SPECIAL_INVERSES == NULL) {
|
||||
SPECIAL_INVERSES = special_inverses;
|
||||
special_inverses = NULL;
|
||||
}
|
||||
umtx_unlock(&LOCK);
|
||||
delete special_inverses; /*null instance*/
|
||||
|
||||
ucln_i18n_registerCleanup(UCLN_I18N_TRANSLITERATOR, utrans_transliterator_cleanup);
|
||||
SPECIAL_INVERSES->setValueDeleter(uprv_deleteUObject);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -928,6 +922,7 @@ void TransliteratorIDParser::cleanup() {
|
|||
delete SPECIAL_INVERSES;
|
||||
SPECIAL_INVERSES = NULL;
|
||||
}
|
||||
gSpecialInversesInitOnce.reset();
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Corporation and others. All Rights Reserved. *
|
||||
* *
|
||||
******************************************************************************
|
||||
* file name: ucln_in.c
|
||||
* file name: ucln_in.cpp
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
|
@ -29,7 +29,7 @@ static cleanupFunc *gCleanupFunctions[UCLN_I18N_COUNT];
|
|||
|
||||
static UBool i18n_cleanup(void)
|
||||
{
|
||||
ECleanupI18NType libType = UCLN_I18N_START;
|
||||
int32_t libType = UCLN_I18N_START;
|
||||
(void)copyright; /* Suppress unused variable warning with clang. */
|
||||
|
||||
while (++libType<UCLN_I18N_COUNT) {
|
|
@ -59,9 +59,8 @@ typedef enum ECleanupI18NType {
|
|||
|
||||
/* Main library cleanup registration function. */
|
||||
/* See common/ucln.h for details on adding a cleanup function. */
|
||||
/* Note: the global mutex must not be held when calling this function. */
|
||||
U_CFUNC void U_EXPORT2 ucln_i18n_registerCleanup(ECleanupI18NType type,
|
||||
cleanupFunc *func);
|
||||
|
||||
U_CFUNC UBool utrans_transliterator_cleanup(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -247,11 +247,8 @@
|
|||
<ClCompile Include="locbund.cpp" />
|
||||
<ClCompile Include="sprintf.c" />
|
||||
<ClCompile Include="sscanf.c" />
|
||||
<ClCompile Include="ucln_io.c">
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>
|
||||
<ClCompile Include="ucln_io.cpp">
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ufile.c" />
|
||||
<ClCompile Include="ufmt_cmn.c" />
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<ClCompile Include="sscanf.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucln_io.c">
|
||||
<ClCompile Include="ucln_io.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ufile.c">
|
||||
|
@ -85,4 +85,4 @@
|
|||
<Filter>Header Files</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Corporation and others. All Rights Reserved. *
|
||||
* *
|
||||
******************************************************************************
|
||||
* file name: ucln_io.c
|
||||
* file name: ucln_io.cpp
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
|
@ -34,7 +34,7 @@ static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT];
|
|||
|
||||
static UBool io_cleanup(void)
|
||||
{
|
||||
ECleanupIOType libType = UCLN_IO_START;
|
||||
int32_t libType = UCLN_IO_START;
|
||||
|
||||
(void)copyright; // Suppress unused variable warning.
|
||||
while (++libType<UCLN_IO_COUNT) {
|
|
@ -271,10 +271,7 @@
|
|||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="toolutil.cpp">
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ucbuf.c" />
|
||||
<ClCompile Include="ucm.c" />
|
||||
|
@ -286,11 +283,8 @@
|
|||
<ClCompile Include="xmlparser.cpp" />
|
||||
<ClCompile Include="dbgutil.cpp" />
|
||||
<ClCompile Include="udbgutil.cpp" />
|
||||
<ClCompile Include="ucln_tu.c">
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</DisableLanguageExtensions>
|
||||
<ClCompile Include="ucln_tu.cpp">
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2007-2013, International Business Machines Corporation and
|
||||
* Copyright (c) 2007-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
Loading…
Add table
Reference in a new issue