summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-09-10 14:39:14 -0600
committerKarl Williamson <khw@cpan.org>2022-09-12 12:01:15 -0600
commit289e5f30b0311cb951f9d52c0e4ff6d1b9892f39 (patch)
tree4e7dce8f220802da32cd0c9caed64ae63c1cba73
parent6b32b503be79c65dad8e40d6c22eb559555fbb1d (diff)
downloadperl-289e5f30b0311cb951f9d52c0e4ff6d1b9892f39.tar.gz
locale.c: Use LC_ALL only if available on platform
These are the final (unless I missed something) cases where LC_ALL could be referred to even if undefined on the system.
-rw-r--r--locale.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/locale.c b/locale.c
index 51957d22c5..8a2ee4f068 100644
--- a/locale.c
+++ b/locale.c
@@ -6526,21 +6526,29 @@ Perl_thread_locale_init()
dTHX_DEBUGGING;
-
DEBUG_L(PerlIO_printf(Perl_debug_log,
- "new thread, initial locale is %s; calling setlocale\n",
- setlocale(LC_ALL, NULL)));
-
+ "new thread, initial locale is %s;"
+ " calling setlocale(LC_ALL, \"C\")\n",
+ get_LC_ALL_display()));
# ifdef WIN32
/* On Windows, make sure new thread has per-thread locales enabled */
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
# endif
+# if defined(LC_ALL)
- /* This thread starts off in the C locale */
+ /* This thread starts off in the C locale. Use the full Perl_setlocale()
+ * to make sure no ill-advised shortcuts get taken on this new thread, */
Perl_setlocale(LC_ALL, "C");
+# else
+
+ for (unsigned i = 0; i < NOMINAL_LC_ALL_INDEX; i++) {
+ Perl_setlocale(categories[i], "C");
+ }
+
+# endif
#endif
}