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.
}
#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) {