This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX.xs: Fix localeconv_l()
authorKarl Williamson <khw@cpan.org>
Thu, 15 Feb 2018 11:22:19 +0000 (04:22 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 18 Feb 2018 16:02:08 +0000 (09:02 -0700)
Commit 7d5966ae3c3b8f0e43fa09554a46cb8de9c98f5f added use of
localeconv_l().  But this commit is buggy in some locales.  It needs to
find the current locale AFTER any changes have been made due to the
LC_NUMERIC locale toggling.

ext/POSIX/POSIX.xs

index 1dbcd07..2d3e69f 100644 (file)
@@ -2128,7 +2128,7 @@ localeconv()
    && defined(HAS_POSIX_2008_LOCALE)                                    \
    && defined(HAS_LOCALECONV_L) /* Prefer this thread-safe version */
         bool do_free = FALSE;
-        locale_t cur = uselocale((locale_t) 0);
+        locale_t cur;
 #  endif
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
 
@@ -2153,6 +2153,7 @@ localeconv()
    && defined(HAS_POSIX_2008_LOCALE)                \
    && defined(HAS_LOCALECONV_L)
 
+        cur = uselocale((locale_t) 0);
         if (cur == LC_GLOBAL_LOCALE) {
             cur = duplocale(LC_GLOBAL_LOCALE);
             do_free = TRUE;