In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/6f94e846cb666949e6a593495d6de3144276a3d6?hp=fb0c7c3c47fb17bb0b685b957af9a0cc581c8996>

- Log -----------------------------------------------------------------
commit 6f94e846cb666949e6a593495d6de3144276a3d6
Author: Karl Williamson <[email protected]>
Date:   Fri Feb 6 10:34:19 2015 -0700

    t/run/locale.t: Remove obsolete comments
    
    STDERR is now completely turned off.

M       t/run/locale.t

commit 175c4cf98f8ca99cd4f626369ef0beb1d69f8ce5
Author: Karl Williamson <[email protected]>
Date:   Fri Feb 6 10:21:01 2015 -0700

    locale.c: savepv() of getenv()
    
    See https://rt.perl.org/Public/Bug/Display.html?id=123748.
    
    This also changes a '0' into a FALSE when initializing a boolean, which
    I consider clearer.

M       locale.c

commit dfd77d7a1935ab78f2a7f1490ca419bcf7a2036b
Author: Karl Williamson <[email protected]>
Date:   Fri Feb 6 10:18:39 2015 -0700

    locale.c: Fix comment

M       locale.c
-----------------------------------------------------------------------

Summary of changes:
 locale.c       | 29 ++++++++++++++++++++---------
 t/run/locale.t |  2 --
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/locale.c b/locale.c
index 625ece7..6c62c1f 100644
--- a/locale.c
+++ b/locale.c
@@ -508,7 +508,7 @@ Perl_my_setlocale(pTHX_ int category, const char* locale)
      * otherwise to use the particular category's variable if set; otherwise to
      * use the LANG variable. */
 
-    bool override_LC_ALL = 0;
+    bool override_LC_ALL = FALSE;
     char * result;
 
     if (locale && strEQ(locale, "")) {
@@ -574,7 +574,7 @@ Perl_my_setlocale(pTHX_ int category, const char* locale)
         return result;
     }
 
-    /* Here the input locale was LC_ALL, and we have set it to what is in the
+    /* Here the input category was LC_ALL, and we have set it to what is in the
      * LANG variable or the system default if there is no LANG.  But these have
      * lower priority than the other LC_foo variables, so override it for each
      * one that is set.  (If they are set to "", it means to use the same thing
@@ -654,7 +654,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
     char *curnum     = NULL;
 #endif /* USE_LOCALE_NUMERIC */
 #ifdef __GLIBC__
-    char * const language   = PerlEnv_getenv("LANGUAGE");
+    const char * const language   = savepv(PerlEnv_getenv("LANGUAGE"));
 #endif
 
     /* NULL uses the existing already set up locale */
@@ -663,15 +663,19 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
                                         : "";
     const char* trial_locales[5];   /* 5 = 1 each for "", LC_ALL, LANG, "", C 
*/
     unsigned int trial_locales_count;
-    char * const lc_all     = PerlEnv_getenv("LC_ALL");
-    char * const lang       = PerlEnv_getenv("LANG");
+    const char * const lc_all     = savepv(PerlEnv_getenv("LC_ALL"));
+    const char * const lang       = savepv(PerlEnv_getenv("LANG"));
     bool setlocale_failure = FALSE;
     unsigned int i;
     char *p;
-    const bool locwarn = (printwarn > 1 ||
-                    (printwarn &&
-                     (!(p = PerlEnv_getenv("PERL_BADLANG")) ||
-                      grok_atou(p, NULL))));
+
+    /* A later getenv() could zap this, so only use here */
+    const char * const bad_lang_use_once = PerlEnv_getenv("PERL_BADLANG");
+
+    const bool locwarn = (printwarn > 1
+                          || (printwarn
+                              && (! bad_lang_use_once
+                                  || grok_atou(bad_lang_use_once, NULL))));
     bool done = FALSE;
 #ifdef WIN32
     /* In some systems you can find out the system default locale
@@ -1080,6 +1084,13 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
     PERL_UNUSED_ARG(printwarn);
 #endif /* USE_LOCALE */
 
+#ifdef __GLIBC__
+    Safefree(language);
+#endif
+
+    Safefree(lc_all);
+    Safefree(lang);
+
     return ok;
 }
 
diff --git a/t/run/locale.t b/t/run/locale.t
index 828142b..528cf8a 100644
--- a/t/run/locale.t
+++ b/t/run/locale.t
@@ -298,7 +298,6 @@ EOF
             local $ENV{LANG} = $different;
             local $ENV{PERL_BADLANG} = 0;
 
-            # Can't turn off the warnings, so send them to /dev/null
             if (! fresh_perl_is(<<"EOF", "$difference", { },
                 if (\$ENV{LC_ALL} ne "invalid") {
                     # Make the test pass if the sh didn't accept the ENV set
@@ -327,7 +326,6 @@ EOF
                 local $ENV{LANG} = "invalid";
                 local $ENV{PERL_BADLANG} = 0;
 
-                # Can't turn off the warnings, so send them to /dev/null
                 if (! fresh_perl_is(<<"EOF", 4.2, { },
                     if (\$ENV{LC_ALL} ne "invalid") {
                         print "$difference\n";

--
Perl5 Master Repository

Reply via email to