S_my_nl_langinfo(const int item, bool toggle)
#endif
{
+ const char * retval;
dTHX;
/* We only need to toggle into the underlying LC_NUMERIC locale for these
}
#if defined(HAS_NL_LANGINFO) /* nl_langinfo() is available. */
-#if ! defined(HAS_POSIX_2008_LOCALE)
+# if ! defined(HAS_THREAD_SAFE_NL_LANGINFO_L) \
+ || ! defined(HAS_POSIX_2008_LOCALE)
/* Here, use plain nl_langinfo(), switching to the underlying LC_NUMERIC
* for those items dependent on it. This must be copied to a buffer before
this code section (the only call to nl_langinfo in
the core) */
- save_to_buffer(nl_langinfo(item), &PL_langinfo_buf,
- &PL_langinfo_bufsize, 0);
+ retval = nl_langinfo(item);
+
+# ifdef USE_ITHREADS
+
+ /* Copy to a per-thread buffer */
+ save_to_buffer(retval, &PL_langinfo_buf, &PL_langinfo_bufsize, 0);
+ retval = PL_langinfo_buf;
+
+# endif
LOCALE_UNLOCK;
}
}
- save_to_buffer(nl_langinfo_l(item, cur),
- &PL_langinfo_buf, &PL_langinfo_bufsize, 0);
+ /* We don't have to copy it to a buffer, as this is a thread-safe
+ * function which Configure has made sure of */
+ retval = nl_langinfo_l(item, cur);
+
if (do_free) {
freelocale(cur);
}
# endif
- if (strEQ(PL_langinfo_buf, "")) {
+ if (strEQ(retval, "")) {
if (item == PERL_YESSTR) {
return "yes";
}
}
}
- return PL_langinfo_buf;
+ return retval;
#else /* Below, emulate nl_langinfo as best we can */
switch (item) {
Size_t len;
- const char * retval;
/* These 2 are unimplemented */
case PERL_CODESET: