This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Keep better track of C/non-C locale
authorKarl Williamson <khw@cpan.org>
Mon, 7 Jul 2014 20:30:59 +0000 (14:30 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 9 Jul 2014 14:04:53 +0000 (08:04 -0600)
Perl uses three interpreter-level (but private) variables to keep track
of numeric locales.  PL_numeric name is the current underlying locale.
PL_standard is a boolean to indicate if we are switched to the C (or
POSIX) locale, and PL_local is a boolean to indicate if we are switched
to the underlying one.  The reason there are two booleans is if the
underlying locale is C, both can be true at the same time.  But the code
that is being changed by this commit didn't realize this, and
could unnecessarily set the booleans to FALSE.  This could cause
unnecessary switching of locales.

locale.c

index 332be8a..c305747 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -218,7 +218,7 @@ Perl_set_numeric_standard(pTHX)
     if (_NOT_IN_NUMERIC_STANDARD) {
        setlocale(LC_NUMERIC, "C");
        PL_numeric_standard = TRUE;
-       PL_numeric_local = FALSE;
+       PL_numeric_local = isNAME_C_OR_POSIX(PL_numeric_name);
        set_numeric_radix();
     }
     DEBUG_L(PerlIO_printf(Perl_debug_log,
@@ -237,7 +237,7 @@ Perl_set_numeric_local(pTHX)
 
     if (_NOT_IN_NUMERIC_LOCAL) {
        setlocale(LC_NUMERIC, PL_numeric_name);
-       PL_numeric_standard = FALSE;
+       PL_numeric_standard = isNAME_C_OR_POSIX(PL_numeric_name);
        PL_numeric_local = TRUE;
        set_numeric_radix();
     }