From 89765009b4796a73bada929293b933a33873656c Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 21 Sep 2017 19:43:28 +0000 Subject: [PATCH] ICU-13001 warning cleanup - remove some dead code - fix some warnings that show up when services, regex are turned off - change some macros into inline functions to quell parenthesis complaints (ucnv_u16.cpp) X-SVN-Rev: 40442 --- icu4c/source/common/ucnv_u16.cpp | 14 +++++++++++--- icu4c/source/i18n/calendar.cpp | 7 +++++-- icu4c/source/i18n/coll.cpp | 2 ++ icu4c/source/i18n/rbnf.cpp | 1 - icu4c/source/tools/genrb/wrtxml.cpp | 5 +++++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/icu4c/source/common/ucnv_u16.cpp b/icu4c/source/common/ucnv_u16.cpp index 91291c003b8..28f2727ecdf 100644 --- a/icu4c/source/common/ucnv_u16.cpp +++ b/icu4c/source/common/ucnv_u16.cpp @@ -1323,9 +1323,17 @@ _UTF16GetName(const UConverter *cnv) { U_CDECL_END extern const UConverterSharedData _UTF16Data; -#define IS_UTF16BE(cnv) ((cnv)->sharedData==&_UTF16BEData) -#define IS_UTF16LE(cnv) ((cnv)->sharedData==&_UTF16LEData) -#define IS_UTF16(cnv) ((cnv)->sharedData==&_UTF16Data || (cnv)->sharedData==&_UTF16v2Data) +static inline bool IS_UTF16BE(const UConverter *cnv) { + return ((cnv)->sharedData == &_UTF16BEData); +} + +static inline bool IS_UTF16LE(const UConverter *cnv) { + return ((cnv)->sharedData == &_UTF16LEData); +} + +static inline bool IS_UTF16(const UConverter *cnv) { + return ((cnv)->sharedData==&_UTF16Data) || ((cnv)->sharedData == &_UTF16v2Data); +} U_CDECL_BEGIN static void U_CALLCONV diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index 10fc1ed2774..12966a739a3 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -66,10 +66,8 @@ #if !UCONFIG_NO_SERVICE static icu::ICULocaleService* gService = NULL; static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER; -#endif // INTERNAL - for cleanup - U_CDECL_BEGIN static UBool calendar_cleanup(void) { #if !UCONFIG_NO_SERVICE @@ -82,6 +80,7 @@ static UBool calendar_cleanup(void) { return TRUE; } U_CDECL_END +#endif // ------------------------------------------ // @@ -234,6 +233,8 @@ static ECalType getCalendarType(const char *s) { return CALTYPE_UNKNOWN; } +#if !UCONFIG_NO_SERVICE +// Only used with service registration. static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) { if(U_FAILURE(status)) { return FALSE; @@ -242,6 +243,7 @@ static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) return (calType != CALTYPE_UNKNOWN); } +// only used with service registration. static void getCalendarKeyword(const UnicodeString &id, char *targetBuffer, int32_t targetBufferSize) { UnicodeString calendarKeyword = UNICODE_STRING_SIMPLE("calendar="); int32_t calKeyLen = calendarKeyword.length(); @@ -255,6 +257,7 @@ static void getCalendarKeyword(const UnicodeString &id, char *targetBuffer, int3 } targetBuffer[keyLen] = 0; } +#endif static ECalType getCalendarTypeForLocale(const char *locid) { UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/i18n/coll.cpp b/icu4c/source/i18n/coll.cpp index be4b6b88640..25c8745cbf2 100644 --- a/icu4c/source/i18n/coll.cpp +++ b/icu4c/source/i18n/coll.cpp @@ -63,8 +63,10 @@ static icu::Locale* availableLocaleList = NULL; static int32_t availableLocaleListCount; +#if !UCONFIG_NO_SERVICE static icu::ICULocaleService* gService = NULL; static icu::UInitOnce gServiceInitOnce = U_INITONCE_INITIALIZER; +#endif static icu::UInitOnce gAvailableLocaleListInitOnce; /** diff --git a/icu4c/source/i18n/rbnf.cpp b/icu4c/source/i18n/rbnf.cpp index 6539217ac2b..66f532e79aa 100644 --- a/icu4c/source/i18n/rbnf.cpp +++ b/icu4c/source/i18n/rbnf.cpp @@ -1200,7 +1200,6 @@ RuleBasedNumberFormat::format(double number, UnicodeString& toAppendTo, FieldPosition& /* pos */) const { - int32_t startPos = toAppendTo.length(); UErrorCode status = U_ZERO_ERROR; if (defaultRuleSet) { format(number, *defaultRuleSet, toAppendTo, status); diff --git a/icu4c/source/tools/genrb/wrtxml.cpp b/icu4c/source/tools/genrb/wrtxml.cpp index 2bfcfebf9ef..b4d21b87db3 100644 --- a/icu4c/source/tools/genrb/wrtxml.cpp +++ b/icu4c/source/tools/genrb/wrtxml.cpp @@ -395,6 +395,7 @@ trim(char **src, int32_t *len){ *len = i+1; } +#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */ static void print(UChar* src, int32_t srcLen,const char *tagStart,const char *tagEnd, UErrorCode *status){ int32_t bufCapacity = srcLen*4; @@ -420,6 +421,8 @@ print(UChar* src, int32_t srcLen,const char *tagStart,const char *tagEnd, UErro } } +#endif + static void printNoteElements(const UString *src, UErrorCode *status){ @@ -471,6 +474,7 @@ static void printAttribute(const char *name, const char *value, int32_t /*len*/) write_utf8_file(out, UnicodeString("\"")); } +#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */ static void printAttribute(const char *name, const UnicodeString value, int32_t /*len*/) { write_utf8_file(out, UnicodeString(" ")); @@ -479,6 +483,7 @@ static void printAttribute(const char *name, const UnicodeString value, int32_t write_utf8_file(out, value); write_utf8_file(out, UnicodeString("\"")); } +#endif static void printComments(struct UString *src, const char *resName, UBool printTranslate, UErrorCode *status){