In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/eb9d0228c41a1528b2864e335094c0c25258789a?hp=96d11ca8c0301ed6fd2f23dec68c455ef2787aa7>

- Log -----------------------------------------------------------------
commit eb9d0228c41a1528b2864e335094c0c25258789a
Author: Karl Williamson <[email protected]>
Date:   Tue Nov 18 21:45:46 2014 -0700

    locale.c: Account for setlocale using static storage
    
    Some systems setlocale()s use static storage for the locale name
    returned by it, so that a subsequent setlocale overwrites it.
    Therefore, you must make a copy of the name if you want it to work after
    the next setlocale.
    
    Thanks to Craig Berry for finding and diagnosing this problem.
-----------------------------------------------------------------------

Summary of changes:
 locale.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/locale.c b/locale.c
index 995c926..c846046 100644
--- a/locale.c
+++ b/locale.c
@@ -351,10 +351,17 @@ Perl_new_ctype(pTHX_ const char *newctype)
 #endif
 
         if (bad_count || multi_byte_locale) {
+
+            /* We have to save 'newctype' because the setlocale() just below
+             * may destroy it.  The next setlocale() further down should
+             * restore it properly so that the intermediate change here is
+             * transparent to this function's caller */
+            const char * const badlocale = savepv(newctype);
+
             setlocale(LC_CTYPE, "C");
             Perl_warner(aTHX_ packWARN(WARN_LOCALE),
                              "Locale '%s' may not work well.%s%s%s\n",
-                             newctype,
+                             badlocale,
                              (multi_byte_locale)
                               ? "  Some characters in it are not recognized by"
                                 " Perl."
@@ -368,7 +375,7 @@ Perl_new_ctype(pTHX_ const char *newctype)
                               ? bad_chars_list
                               : ""
                             );
-            setlocale(LC_CTYPE, newctype);
+            setlocale(LC_CTYPE, badlocale);
         }
     }
 

--
Perl5 Master Repository

Reply via email to