From 2f4e2e43ce37d2308cf1ef5cec1a601994abf1a5 Mon Sep 17 00:00:00 2001 From: Craig Cornelius Date: Mon, 20 Apr 2020 16:26:58 +0000 Subject: [PATCH] ICU-21053 Fix compile problems with UCONFIG_NO_FORMATTING = 1 See #1115 --- icu4c/source/i18n/listformatter.cpp | 8 ++++++++ icu4c/source/i18n/unicode/dtptngen.h | 4 ++++ icu4c/source/i18n/unicode/listformatter.h | 4 +++- icu4c/source/i18n/unicode/udatpg.h | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/listformatter.cpp b/icu4c/source/i18n/listformatter.cpp index b9065e8796d..da99c9291d1 100644 --- a/icu4c/source/i18n/listformatter.cpp +++ b/icu4c/source/i18n/listformatter.cpp @@ -348,6 +348,7 @@ const ListFormatInternal* ListFormatter::getListFormatInternal( return result; } +#if !UCONFIG_NO_FORMATTING static const char* typeWidthToStyleString(UListFormatterType type, UListFormatterWidth width) { switch (type) { case ULISTFMT_TYPE_AND: @@ -391,6 +392,7 @@ static const char* typeWidthToStyleString(UListFormatterType type, UListFormatte return nullptr; } +#endif static const UChar solidus = 0x2F; static const UChar aliasPrefix[] = { 0x6C,0x69,0x73,0x74,0x50,0x61,0x74,0x74,0x65,0x72,0x6E,0x2F }; // "listPattern/" @@ -511,9 +513,14 @@ ListFormatter* ListFormatter::createInstance(UErrorCode& errorCode) { } ListFormatter* ListFormatter::createInstance(const Locale& locale, UErrorCode& errorCode) { +#if !UCONFIG_NO_FORMATTING return createInstance(locale, ULISTFMT_TYPE_AND, ULISTFMT_WIDTH_WIDE, errorCode); +#else + return createInstance(locale, "standard", errorCode); +#endif } +#if !UCONFIG_NO_FORMATTING ListFormatter* ListFormatter::createInstance( const Locale& locale, UListFormatterType type, UListFormatterWidth width, UErrorCode& errorCode) { const char* style = typeWidthToStyleString(type, width); @@ -523,6 +530,7 @@ ListFormatter* ListFormatter::createInstance( } return createInstance(locale, style, errorCode); } +#endif ListFormatter* ListFormatter::createInstance(const Locale& locale, const char *style, UErrorCode& errorCode) { const ListFormatInternal* listFormatInternal = getListFormatInternal(locale, style, errorCode); diff --git a/icu4c/source/i18n/unicode/dtptngen.h b/icu4c/source/i18n/unicode/dtptngen.h index 35736a0ea3f..dd99d58e65e 100644 --- a/icu4c/source/i18n/unicode/dtptngen.h +++ b/icu4c/source/i18n/unicode/dtptngen.h @@ -483,6 +483,8 @@ public: */ const UnicodeString& getDecimal() const; +#if !UCONFIG_NO_FORMATTING + #ifndef U_HIDE_DRAFT_API /** * Get the default hour cycle for a locale. Uses the locale that the @@ -499,6 +501,8 @@ public: UDateFormatHourCycle getDefaultHourCycle(UErrorCode& status) const; #endif /* U_HIDE_DRAFT_API */ +#endif /* #if !UCONFIG_NO_FORMATTING */ + /** * ICU "poor man's RTTI", returns a UClassID for the actual class. * diff --git a/icu4c/source/i18n/unicode/listformatter.h b/icu4c/source/i18n/unicode/listformatter.h index 26b42c28bbc..211055d9d1c 100644 --- a/icu4c/source/i18n/unicode/listformatter.h +++ b/icu4c/source/i18n/unicode/listformatter.h @@ -186,6 +186,7 @@ class U_I18N_API ListFormatter : public UObject{ static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode); #ifndef U_HIDE_DRAFT_API +#if !UCONFIG_NO_FORMATTING /** * Creates a ListFormatter for the given locale, list type, and style. * @@ -198,8 +199,9 @@ class U_I18N_API ListFormatter : public UObject{ */ static ListFormatter* createInstance( const Locale& locale, UListFormatterType type, UListFormatterWidth width, UErrorCode& errorCode); +#endif /* !UCONFIG_NO_FORMATTING */ #endif /* U_HIDE_DRAFT_API */ - + #ifndef U_HIDE_INTERNAL_API /** * Creates a ListFormatter appropriate for a locale and style. diff --git a/icu4c/source/i18n/unicode/udatpg.h b/icu4c/source/i18n/unicode/udatpg.h index 74c812ff85b..5abe1472a65 100644 --- a/icu4c/source/i18n/unicode/udatpg.h +++ b/icu4c/source/i18n/unicode/udatpg.h @@ -652,6 +652,8 @@ udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t skeletonLength, int32_t *pLength); +#if !UCONFIG_NO_FORMATTING + #ifndef U_HIDE_DRAFT_API /** * Return the default hour cycle for a locale. Uses the locale that the @@ -670,4 +672,6 @@ U_DRAFT UDateFormatHourCycle U_EXPORT2 udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode* pErrorCode); #endif /* U_HIDE_DRAFT_API */ +#endif /* #if !UCONFIG_NO_FORMATTING */ + #endif