Commit e9f4ac13 authored by Tom Lane's avatar Tom Lane

Suppress unused-variable warnings when building with ICU 4.2.

Tidy-up for commit eccead9e.
parent f4f41baf
...@@ -678,14 +678,30 @@ pg_import_system_collations(PG_FUNCTION_ARGS) ...@@ -678,14 +678,30 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
*/ */
for (i = -1; i < ucol_countAvailable(); i++) for (i = -1; i < ucol_countAvailable(); i++)
{ {
/*
* In ICU 4.2, ucol_getKeywordsForLocale() sometimes returns
* values that will not be accepted by uloc_toLanguageTag(). Skip
* loading keyword variants in that version. (Both
* ucol_getKeywordValuesForLocale() and uloc_toLanguageTag() are
* new in ICU 4.2, so older versions are not supported at all.)
*
* XXX We have no information about ICU 4.3 through 4.7, but we
* know the code below works with 4.8.
*/
#if U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM > 2)
#define LOAD_ICU_KEYWORD_VARIANTS
#endif
const char *name; const char *name;
char *langtag; char *langtag;
char *icucomment; char *icucomment;
const char *collcollate; const char *collcollate;
Oid collid;
#ifdef LOAD_ICU_KEYWORD_VARIANTS
UEnumeration *en; UEnumeration *en;
UErrorCode status; UErrorCode status;
const char *val; const char *val;
Oid collid; #endif
if (i == -1) if (i == -1)
name = ""; /* ICU root locale */ name = ""; /* ICU root locale */
...@@ -721,18 +737,9 @@ pg_import_system_collations(PG_FUNCTION_ARGS) ...@@ -721,18 +737,9 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
} }
/* /*
* Add keyword variants * Add keyword variants, if enabled.
*
* In ICU 4.2, ucol_getKeywordsForLocale() sometimes returns
* values that will not be accepted by uloc_toLanguageTag(). Skip
* loading keyword variants in that version. (Both
* ucol_getKeywordValuesForLocale() and uloc_toLanguageTag() are
* new in ICU 4.2, so older versions are not supported at all.)
*
* XXX We have no information about ICU 4.3 through 4.7, but we
* know the below works with 4.8.
*/ */
#if U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM > 2) #ifdef LOAD_ICU_KEYWORD_VARIANTS
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
en = ucol_getKeywordValuesForLocale("collation", name, TRUE, &status); en = ucol_getKeywordValuesForLocale("collation", name, TRUE, &status);
if (U_FAILURE(status)) if (U_FAILURE(status))
...@@ -779,7 +786,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS) ...@@ -779,7 +786,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
(errmsg("could not get keyword values for locale \"%s\": %s", (errmsg("could not get keyword values for locale \"%s\": %s",
name, u_errorName(status)))); name, u_errorName(status))));
uenum_close(en); uenum_close(en);
#endif /* ICU >4.2 */ #endif /* LOAD_ICU_KEYWORD_VARIANTS */
} }
} }
#endif /* USE_ICU */ #endif /* USE_ICU */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment