From 0ae3d3a7d4ed9e55afd64c9494e9cbb3bdf2f7e0 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Sat, 11 Aug 2012 04:57:13 +0000 Subject: [PATCH] ICU-9474 Reduce unrename.h namespace pollution X-SVN-Rev: 32157 --- icu4c/source/common/ucln.h | 10 ++-- icu4c/source/common/ucln_cmn.c | 24 ++++++--- icu4c/source/common/uinit.c | 35 ++++++------- icu4c/source/common/unicode/urename.h | 17 ++---- icu4c/source/i18n/colldata.cpp | 74 ++++++++++++++------------- icu4c/source/i18n/decContext.c | 13 +---- icu4c/source/i18n/decNumber.c | 14 ++++- icu4c/source/i18n/decNumberLocal.h | 16 +----- icu4c/source/tools/genren/genren.pl | 5 +- 9 files changed, 97 insertions(+), 111 deletions(-) diff --git a/icu4c/source/common/ucln.h b/icu4c/source/common/ucln.h index 951ad192d9..47f082a154 100644 --- a/icu4c/source/common/ucln.h +++ b/icu4c/source/common/ucln.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2001-2011, International Business Machines +* Copyright (C) 2001-2012, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -69,6 +69,7 @@ typedef enum ECleanupLibraryType { */ U_CDECL_BEGIN typedef UBool U_CALLCONV cleanupFunc(void); +typedef void U_CALLCONV initFunc(UErrorCode *); U_CDECL_END /** @@ -87,11 +88,6 @@ U_CAPI void U_EXPORT2 ucln_registerCleanup(ECleanupLibraryType type, U_CAPI void U_EXPORT2 ucln_cleanupOne(ECleanupLibraryType type); /* ucln_cmn.c variables shared with uinit.c */ -U_CDECL_BEGIN - -extern UBool gICUInitialized; -extern UMTX gICUInitMutex; - -U_CDECL_END +U_CFUNC UBool ucln_mutexedInit(initFunc *func, UErrorCode *status); #endif diff --git a/icu4c/source/common/ucln_cmn.c b/icu4c/source/common/ucln_cmn.c index 45358736bd..a7776ba4a6 100644 --- a/icu4c/source/common/ucln_cmn.c +++ b/icu4c/source/common/ucln_cmn.c @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 2001-2011, International Business Machines +* Copyright (C) 2001-2012, International Business Machines * Corporation and others. All Rights Reserved. ****************************************************************************** * file name: ucln_cmn.c @@ -25,16 +25,26 @@ #define UCLN_TYPE_IS_COMMON #include "ucln_imp.h" -U_CDECL_BEGIN - -UBool gICUInitialized = FALSE; -UMTX gICUInitMutex = NULL; - -U_CDECL_END +static UBool gICUInitialized = FALSE; +static UMTX gICUInitMutex = NULL; static cleanupFunc *gCommonCleanupFunctions[UCLN_COMMON_COUNT]; static cleanupFunc *gLibCleanupFunctions[UCLN_COMMON]; +U_CFUNC UBool ucln_mutexedInit(initFunc *func, UErrorCode *status) { + UBool initialized = FALSE; + umtx_lock(&gICUInitMutex); + if (!gICUInitialized && U_SUCCESS(*status)) { + if (func != NULL) { + func(status); + } + gICUInitialized = TRUE; /* TODO: don't set if U_FAILURE? */ + initialized = TRUE; + } + umtx_unlock(&gICUInitMutex); + return initialized; +} + /************************************************ The cleanup order is important in this function. Please be sure that you have read ucln.h diff --git a/icu4c/source/common/uinit.c b/icu4c/source/common/uinit.c index bdbf9102e3..44d496acbd 100644 --- a/icu4c/source/common/uinit.c +++ b/icu4c/source/common/uinit.c @@ -1,7 +1,7 @@ /* ****************************************************************************** * * -* Copyright (C) 2001-2011, International Business Machines * +* Copyright (C) 2001-2012, International Business Machines * * Corporation and others. All Rights Reserved. * * * ****************************************************************************** @@ -24,22 +24,9 @@ #include "umutex.h" #include "utracimp.h" -/* - * ICU Initialization Function. Need not be called. - */ -U_CAPI void U_EXPORT2 -u_init(UErrorCode *status) { - UTRACE_ENTRY_OC(UTRACE_U_INIT); - /* initialize plugins */ - uplug_init(status); - - umtx_lock(&gICUInitMutex); - if (gICUInitialized || U_FAILURE(*status)) { - umtx_unlock(&gICUInitMutex); - UTRACE_EXIT_STATUS(*status); - return; - } - +static void U_CALLCONV +initData(UErrorCode *status) +{ /* * 2005-may-02 * @@ -55,8 +42,18 @@ u_init(UErrorCode *status) { #if !UCONFIG_NO_CONVERSION ucnv_io_countKnownConverters(status); #endif +} + +/* + * ICU Initialization Function. Need not be called. + */ +U_CAPI void U_EXPORT2 +u_init(UErrorCode *status) { + UTRACE_ENTRY_OC(UTRACE_U_INIT); + + /* initialize plugins */ + uplug_init(status); + ucln_mutexedInit(initData, status); - gICUInitialized = TRUE; /* TODO: don't set if U_FAILURE? */ - umtx_unlock(&gICUInitMutex); UTRACE_EXIT_STATUS(*status); } diff --git a/icu4c/source/common/unicode/urename.h b/icu4c/source/common/unicode/urename.h index 04c14880d5..a66b47d679 100644 --- a/icu4c/source/common/unicode/urename.h +++ b/icu4c/source/common/unicode/urename.h @@ -23,7 +23,7 @@ /* U_DISABLE_RENAMING can be defined in the following ways: * - when running configure, e.g. - * runConfigureICU Linux CPPFLAGS="-DU_DISABLE_RENAMING" + * runConfigureICU Linux --disable-renaming * - by changing the default setting of U_DISABLE_RENAMING in uconfig.h */ @@ -53,8 +53,6 @@ /* C exports renaming data */ -#define DECPOWERS U_ICU_ENTRY_POINT_RENAME(DECPOWERS) -#define DECSTICKYTAB U_ICU_ENTRY_POINT_RENAME(DECSTICKYTAB) #define T_CString_int64ToString U_ICU_ENTRY_POINT_RENAME(T_CString_int64ToString) #define T_CString_integerToString U_ICU_ENTRY_POINT_RENAME(T_CString_integerToString) #define T_CString_stringToInteger U_ICU_ENTRY_POINT_RENAME(T_CString_stringToInteger) @@ -113,14 +111,6 @@ #define bms_setTargetString U_ICU_ENTRY_POINT_RENAME(bms_setTargetString) #define cmemory_cleanup U_ICU_ENTRY_POINT_RENAME(cmemory_cleanup) #define cmemory_inUse U_ICU_ENTRY_POINT_RENAME(cmemory_inUse) -#define d2utable U_ICU_ENTRY_POINT_RENAME(d2utable) -#define deleteCEList U_ICU_ENTRY_POINT_RENAME(deleteCEList) -#define deleteChars U_ICU_ENTRY_POINT_RENAME(deleteChars) -#define deleteCollDataCacheEntry U_ICU_ENTRY_POINT_RENAME(deleteCollDataCacheEntry) -#define deleteStringList U_ICU_ENTRY_POINT_RENAME(deleteStringList) -#define deleteUnicodeStringKey U_ICU_ENTRY_POINT_RENAME(deleteUnicodeStringKey) -#define gICUInitMutex U_ICU_ENTRY_POINT_RENAME(gICUInitMutex) -#define gICUInitialized U_ICU_ENTRY_POINT_RENAME(gICUInitialized) #define izrule_clone U_ICU_ENTRY_POINT_RENAME(izrule_clone) #define izrule_close U_ICU_ENTRY_POINT_RENAME(izrule_close) #define izrule_equals U_ICU_ENTRY_POINT_RENAME(izrule_equals) @@ -592,6 +582,7 @@ #define ucln_i18n_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_i18n_registerCleanup) #define ucln_io_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_io_registerCleanup) #define ucln_lib_cleanup U_ICU_ENTRY_POINT_RENAME(ucln_lib_cleanup) +#define ucln_mutexedInit U_ICU_ENTRY_POINT_RENAME(ucln_mutexedInit) #define ucln_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_registerCleanup) #define ucnv_MBCSFromUChar32 U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSFromUChar32) #define ucnv_MBCSFromUnicodeWithOffsets U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSFromUnicodeWithOffsets) @@ -720,7 +711,6 @@ #define ucol_findReorderingEntry U_ICU_ENTRY_POINT_RENAME(ucol_findReorderingEntry) #define ucol_forceHanImplicit U_ICU_ENTRY_POINT_RENAME(ucol_forceHanImplicit) #define ucol_forgetUCA U_ICU_ENTRY_POINT_RENAME(ucol_forgetUCA) -#define ucol_freeOffsetBuffer U_ICU_ENTRY_POINT_RENAME(ucol_freeOffsetBuffer) #define ucol_getAttribute U_ICU_ENTRY_POINT_RENAME(ucol_getAttribute) #define ucol_getAttributeOrDefault U_ICU_ENTRY_POINT_RENAME(ucol_getAttributeOrDefault) #define ucol_getAvailable U_ICU_ENTRY_POINT_RENAME(ucol_getAvailable) @@ -807,7 +797,6 @@ #define ucol_tok_assembleTokenList U_ICU_ENTRY_POINT_RENAME(ucol_tok_assembleTokenList) #define ucol_tok_closeTokenList U_ICU_ENTRY_POINT_RENAME(ucol_tok_closeTokenList) #define ucol_tok_getNextArgument U_ICU_ENTRY_POINT_RENAME(ucol_tok_getNextArgument) -#define ucol_tok_getRulesFromBundle U_ICU_ENTRY_POINT_RENAME(ucol_tok_getRulesFromBundle) #define ucol_tok_initTokenList U_ICU_ENTRY_POINT_RENAME(ucol_tok_initTokenList) #define ucol_tok_parseNextToken U_ICU_ENTRY_POINT_RENAME(ucol_tok_parseNextToken) #define ucol_updateInternalState U_ICU_ENTRY_POINT_RENAME(ucol_updateInternalState) @@ -919,6 +908,7 @@ #define uenum_nextDefault U_ICU_ENTRY_POINT_RENAME(uenum_nextDefault) #define uenum_openCharStringsEnumeration U_ICU_ENTRY_POINT_RENAME(uenum_openCharStringsEnumeration) #define uenum_openFromStringEnumeration U_ICU_ENTRY_POINT_RENAME(uenum_openFromStringEnumeration) +#define uenum_openUCharStringsEnumeration U_ICU_ENTRY_POINT_RENAME(uenum_openUCharStringsEnumeration) #define uenum_reset U_ICU_ENTRY_POINT_RENAME(uenum_reset) #define uenum_unext U_ICU_ENTRY_POINT_RENAME(uenum_unext) #define uenum_unextDefault U_ICU_ENTRY_POINT_RENAME(uenum_unextDefault) @@ -1313,7 +1303,6 @@ #define uprv_fmod U_ICU_ENTRY_POINT_RENAME(uprv_fmod) #define uprv_free U_ICU_ENTRY_POINT_RENAME(uprv_free) #define uprv_getCharNameCharacters U_ICU_ENTRY_POINT_RENAME(uprv_getCharNameCharacters) -#define uprv_getDefaultCodepage U_ICU_ENTRY_POINT_RENAME(uprv_getDefaultCodepage) #define uprv_getDefaultLocaleID U_ICU_ENTRY_POINT_RENAME(uprv_getDefaultLocaleID) #define uprv_getInfinity U_ICU_ENTRY_POINT_RENAME(uprv_getInfinity) #define uprv_getMaxCharNameLength U_ICU_ENTRY_POINT_RENAME(uprv_getMaxCharNameLength) diff --git a/icu4c/source/i18n/colldata.cpp b/icu4c/source/i18n/colldata.cpp index 946568b1e1..a488ea0772 100644 --- a/icu4c/source/i18n/colldata.cpp +++ b/icu4c/source/i18n/colldata.cpp @@ -287,7 +287,41 @@ int32_t StringList::size() const } -U_CFUNC void deleteStringList(void *obj); +U_CDECL_BEGIN +static void U_CALLCONV +deleteStringList(void *obj) +{ + StringList *strings = (StringList *) obj; + + delete strings; +} +static void U_CALLCONV +deleteCEList(void *obj) +{ + CEList *list = (CEList *) obj; + + delete list; +} + +static void U_CALLCONV +deleteUnicodeStringKey(void *obj) +{ + UnicodeString *key = (UnicodeString *) obj; + + delete key; +} + +static void U_CALLCONV +deleteChars(void * /*obj*/) +{ + // char *chars = (char *) obj; + // All the key strings are owned by the + // CollData objects and don't need to + // be freed here. + //DELETE_ARRAY(chars); +} + +U_CDECL_END class CEToStringsMap : public UMemory { @@ -356,16 +390,6 @@ void CEToStringsMap::putStringList(uint32_t ce, StringList *stringList, UErrorCo uhash_iput(map, ce, (void *) stringList, &status); } -U_CFUNC void deleteStringList(void *obj) -{ - StringList *strings = (StringList *) obj; - - delete strings; -} - -U_CFUNC void deleteCEList(void *obj); -U_CFUNC void deleteUnicodeStringKey(void *obj); - class StringToCEsMap : public UMemory { public: @@ -417,20 +441,6 @@ const CEList *StringToCEsMap::get(const UnicodeString *string) return (const CEList *) uhash_get(map, string); } -U_CFUNC void deleteCEList(void *obj) -{ - CEList *list = (CEList *) obj; - - delete list; -} - -U_CFUNC void deleteUnicodeStringKey(void *obj) -{ - UnicodeString *key = (UnicodeString *) obj; - - delete key; -} - class CollDataCacheEntry : public UMemory { public: @@ -472,21 +482,15 @@ private: }; static UMTX lock; -U_CFUNC void deleteChars(void * /*obj*/) -{ - // char *chars = (char *) obj; - // All the key strings are owned by the - // CollData objects and don't need to - // be freed here. - //DELETE_ARRAY(chars); -} - -U_CFUNC void deleteCollDataCacheEntry(void *obj) +U_CDECL_BEGIN +static void U_CALLCONV +deleteCollDataCacheEntry(void *obj) { CollDataCacheEntry *entry = (CollDataCacheEntry *) obj; delete entry; } +U_CDECL_END CollDataCache::CollDataCache(UErrorCode &status) : cache(NULL) diff --git a/icu4c/source/i18n/decContext.c b/icu4c/source/i18n/decContext.c index 3b162f2699..440272884a 100644 --- a/icu4c/source/i18n/decContext.c +++ b/icu4c/source/i18n/decContext.c @@ -1,7 +1,7 @@ /* ------------------------------------------------------------------ */ /* Decimal Context module */ /* ------------------------------------------------------------------ */ -/* Copyright (c) IBM Corporation, 2000-2011. All rights reserved. */ +/* Copyright (c) IBM Corporation, 2000-2012. All rights reserved. */ /* */ /* This software is made available under the terms of the */ /* ICU License -- ICU 1.8.1 and later. */ @@ -32,17 +32,6 @@ static const Flag *mfctop=(Flag *)&mfcone; /* -> top byte */ #define LITEND *mfctop /* named flag; 1=little-endian */ #endif -/* ------------------------------------------------------------------ */ -/* round-for-reround digits */ -/* ------------------------------------------------------------------ */ -const uByte DECSTICKYTAB[10]={1,1,2,3,4,6,6,7,8,9}; /* used if sticky */ - -/* ------------------------------------------------------------------ */ -/* Powers of ten (powers[n]==10**n, 0<=n<=9) */ -/* ------------------------------------------------------------------ */ -const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000, - 10000000, 100000000, 1000000000}; - /* ------------------------------------------------------------------ */ /* decContextClearStatus -- clear bits in current status */ /* */ diff --git a/icu4c/source/i18n/decNumber.c b/icu4c/source/i18n/decNumber.c index df3ab52a60..94b079068c 100644 --- a/icu4c/source/i18n/decNumber.c +++ b/icu4c/source/i18n/decNumber.c @@ -185,7 +185,7 @@ /* Constants */ /* Public lookup table used by the D2U macro */ -const uByte d2utable[DECMAXD2U+1]=D2UTABLE; +static const uByte d2utable[DECMAXD2U+1]=D2UTABLE; #define DECVERB 1 /* set to 1 for verbose DECCHECK */ #define powers DECPOWERS /* old internal name */ @@ -212,6 +212,18 @@ const uByte d2utable[DECMAXD2U+1]=D2UTABLE; static const Unit uarrone[1]={1}; /* Unit array of 1, used for incrementing */ +/* ------------------------------------------------------------------ */ +/* round-for-reround digits */ +/* ------------------------------------------------------------------ */ +static const uByte DECSTICKYTAB[10]={1,1,2,3,4,6,6,7,8,9}; /* used if sticky */ + +/* ------------------------------------------------------------------ */ +/* Powers of ten (powers[n]==10**n, 0<=n<=9) */ +/* ------------------------------------------------------------------ */ +static const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000, + 10000000, 100000000, 1000000000}; + + /* Granularity-dependent code */ #if DECDPUN<=4 #define eInt Int /* extended integer */ diff --git a/icu4c/source/i18n/decNumberLocal.h b/icu4c/source/i18n/decNumberLocal.h index 4a36723ea7..bf6d54b8b2 100644 --- a/icu4c/source/i18n/decNumberLocal.h +++ b/icu4c/source/i18n/decNumberLocal.h @@ -1,7 +1,7 @@ /* ------------------------------------------------------------------ */ /* decNumber package local type, tuning, and macro definitions */ /* ------------------------------------------------------------------ */ -/* Copyright (c) IBM Corporation, 2000-2010. All rights reserved. */ +/* Copyright (c) IBM Corporation, 2000-2012. All rights reserved. */ /* */ /* This software is made available under the terms of the */ /* ICU License -- ICU 1.8.1 and later. */ @@ -88,18 +88,6 @@ #define long ?? /* .. or 'long' types are not used */ #endif - /* Shared lookup tables */ - extern const uByte DECSTICKYTAB[10]; /* re-round digits if sticky */ - extern const uInt DECPOWERS[10]; /* powers of ten table */ - /* The following are included from decDPD.h */ - extern const uShort DPD2BIN[1024]; /* DPD -> 0-999 */ - extern const uShort BIN2DPD[1000]; /* 0-999 -> DPD */ - extern const uInt DPD2BINK[1024]; /* DPD -> 0-999000 */ - extern const uInt DPD2BINM[1024]; /* DPD -> 0-999000000 */ - extern const uByte DPD2BCD8[4096]; /* DPD -> ddd + len */ - extern const uByte BIN2BCD8[4000]; /* 0-999 -> ddd + len */ - extern const uShort BCD2DPD[2458]; /* 0-0x999 -> DPD (0x999=2457)*/ - /* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts */ /* (that is, sets w to be the high-order word of the 64-bit result; */ /* the low-order word is simply u*v.) */ @@ -228,7 +216,7 @@ /* ----- Shared data (in decNumber.c) ----- */ /* Public lookup table used by the D2U macro (see below) */ #define DECMAXD2U 49 - extern const uByte d2utable[DECMAXD2U+1]; + /*extern const uByte d2utable[DECMAXD2U+1];*/ /* ----- Macros ----- */ /* ISZERO -- return true if decNumber dn is a zero */ diff --git a/icu4c/source/tools/genren/genren.pl b/icu4c/source/tools/genren/genren.pl index 3afd8c432b..764da946a3 100755 --- a/icu4c/source/tools/genren/genren.pl +++ b/icu4c/source/tools/genren/genren.pl @@ -148,8 +148,9 @@ for(;@ARGV; shift(@ARGV)) { ($_, $address, $type) = split(/\|/); chop $qtype; } elsif ($mode =~ /Mach-O/) { - if(/^(?:[0-9a-fA-F]){8} ([A-Z]) (?:_)?(.*)$/) { - ($_, $type) = ($2, $1); + ($address, $type, $_) = split(/ /); + if(/^_(.*)$/) { + $_ = $1; } else { next; }