ICU-21053 Fix compile problems with UCONFIG_NO_FORMATTING = 1
See #1115
diff --git a/icu4c/source/i18n/listformatter.cpp b/icu4c/source/i18n/listformatter.cpp
index b9065e8..da99c92 100644
--- a/icu4c/source/i18n/listformatter.cpp
+++ b/icu4c/source/i18n/listformatter.cpp
@@ -348,6 +348,7 @@
return result;
}
+#if !UCONFIG_NO_FORMATTING
static const char* typeWidthToStyleString(UListFormatterType type, UListFormatterWidth width) {
switch (type) {
case ULISTFMT_TYPE_AND:
@@ -391,6 +392,7 @@
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(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 @@
}
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 35736a0..dd99d58 100644
--- a/icu4c/source/i18n/unicode/dtptngen.h
+++ b/icu4c/source/i18n/unicode/dtptngen.h
@@ -483,6 +483,8 @@
*/
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 @@
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 26b42c2..211055d 100644
--- a/icu4c/source/i18n/unicode/listformatter.h
+++ b/icu4c/source/i18n/unicode/listformatter.h
@@ -186,6 +186,7 @@
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 @@
*/
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 74c812f..5abe147 100644
--- a/icu4c/source/i18n/unicode/udatpg.h
+++ b/icu4c/source/i18n/unicode/udatpg.h
@@ -652,6 +652,8 @@
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 @@
udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode* pErrorCode);
#endif /* U_HIDE_DRAFT_API */
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
#endif