diff options
author | Jeff Davis <jdavis@postgresql.org> | 2023-05-26 11:26:11 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2023-05-26 11:26:11 -0700 |
commit | ec1264f01e374c48707cc7dc18928b4ace0530fb (patch) | |
tree | 4781f5105cf521b8bf01816a79fe81ca67fff748 /src | |
parent | 7a844c77ece1bda3b076034bc20142d4bd66db7a (diff) | |
download | postgresql-ec1264f01e374c48707cc7dc18928b4ace0530fb.tar.gz postgresql-ec1264f01e374c48707cc7dc18928b4ace0530fb.zip |
ICU: use uloc_getDefault() for initdb.
Simpler, and better preserves the locale name as read from the
environment.
Author: Daniel Verite
Discussion: https://postgr.es/m/a6204a46-c077-451b-8f9d-8965d95bb57c@manitou-mail.org
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/initdb/initdb.c | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 31156e863ba..09a5c98cc04 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -2354,42 +2354,13 @@ icu_validate_locale(const char *loc_str) } /* - * Determine default ICU locale by opening the default collator and reading - * its locale. - * - * NB: The default collator (opened using NULL) is different from the collator - * for the root locale (opened with "", "und", or "root"). The former depends - * on the environment (useful at initdb time) and the latter does not. + * Determine the default ICU locale */ static char * default_icu_locale(void) { #ifdef USE_ICU - UCollator *collator; - UErrorCode status; - const char *valid_locale; - char *default_locale; - - status = U_ZERO_ERROR; - collator = ucol_open(NULL, &status); - if (U_FAILURE(status)) - pg_fatal("could not open collator for default locale: %s", - u_errorName(status)); - - status = U_ZERO_ERROR; - valid_locale = ucol_getLocaleByType(collator, ULOC_VALID_LOCALE, - &status); - if (U_FAILURE(status)) - { - ucol_close(collator); - pg_fatal("could not determine default ICU locale"); - } - - default_locale = pg_strdup(valid_locale); - - ucol_close(collator); - - return default_locale; + return pg_strdup(uloc_getDefault()); #else pg_fatal("ICU is not supported in this build"); #endif |