summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2014-02-16 22:06:03 -0700
committerKarl Williamson <public@khwilliamson.com>2014-02-16 22:47:10 -0700
commit7cd8b56846670e577e1f62479eab8f38fb11da14 (patch)
tree68ec944a5112738dee4441c3c01b37fb41e6d334 /locale.c
parent0334097d5ecdb8506c1fc85a54a43b1fa5b84bf4 (diff)
downloadperl-7cd8b56846670e577e1f62479eab8f38fb11da14.tar.gz
locale.c: Handle case where LC_ALL isn't "all"
Setting the LC_ALL locale category on NetBSD does not necessarily change all the categories to the requested locale. Sometimes the LC_COLLATE category is set to POSIX. I presume that is because collation has not been defined for the given locale, so it uses a basic locale instead. The code in locale.c that does locale initialization for the Perl program at start-up, depended on LC_ALL setting all categories to the same locale.
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/locale.c b/locale.c
index bf55d04441..d22d2abc48 100644
--- a/locale.c
+++ b/locale.c
@@ -578,8 +578,19 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
}
#ifdef LC_ALL
- if (! my_setlocale(LC_ALL, trial_locale))
+ if (! my_setlocale(LC_ALL, trial_locale)) {
setlocale_failure = TRUE;
+ }
+ else {
+ /* Since LC_ALL succeeded, it should have changed all the other
+ * categories it can to its value; so we massage things so that the
+ * setlocales below just return their category's current values.
+ * This adequately handles the case in NetBSD where LC_COLLATE may
+ * not be defined for a locale, and setting it individually will
+ * fail, whereas setting LC_ALL suceeds, leaving LC_COLLATE set to
+ * the POSIX locale. */
+ trial_locale = NULL;
+ }
#endif /* LC_ALL */
if (!setlocale_failure) {