]> granicus.if.org Git - postgresql/commitdiff
Suppress unused-variable warnings when building with ICU 4.2.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 5 Aug 2017 15:48:32 +0000 (11:48 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 5 Aug 2017 15:48:43 +0000 (11:48 -0400)
Tidy-up for commit eccead9ed.

src/backend/commands/collationcmds.c

index ea257a378643a1dfc52ed091ef8bc5f9c9e50b15..ed5ffb6594f4d750b61eb8feebb0c36b4ada0525 100644 (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 */