Suppress unused-variable warnings when building with ICU 4.2.

Tidy-up for commit eccead9ed.
This commit is contained in:
Tom Lane 2017-08-05 11:48:32 -04:00
parent f4f41baf29
commit e9f4ac1389
1 changed files with 20 additions and 13 deletions

View File

@ -678,14 +678,30 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
*/
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;
char *langtag;
char *icucomment;
const char *collcollate;
Oid collid;
#ifdef LOAD_ICU_KEYWORD_VARIANTS
UEnumeration *en;
UErrorCode status;
const char *val;
Oid collid;
#endif
if (i == -1)
name = ""; /* ICU root locale */
@ -721,18 +737,9 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
}
/*
* Add keyword variants
*
* 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.
* Add keyword variants, if enabled.
*/
#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;
en = ucol_getKeywordValuesForLocale("collation", name, TRUE, &status);
if (U_FAILURE(status))
@ -779,7 +786,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
(errmsg("could not get keyword values for locale \"%s\": %s",
name, u_errorName(status))));
uenum_close(en);
#endif /* ICU >4.2 */
#endif /* LOAD_ICU_KEYWORD_VARIANTS */
}
}
#endif /* USE_ICU */