perl.h: Revise another locale setting macro
authorKarl Williamson <public@khwilliamson.com>
Thu, 12 Dec 2013 05:55:43 +0000 (22:55 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 4 Jan 2014 20:33:05 +0000 (13:33 -0700)
We generally don't want to switch to the default underlying locale
unless we are in the scope of some form of 'use locale'.  Prior to this
commit, this code did not allow the switch for
'use locale ":not_characters"'.

perl.h
t/run/locale.t

diff --git a/perl.h b/perl.h
index 328c969..bf6c129 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5240,8 +5240,10 @@ typedef struct am_table_short AMTS;
        bool was_local = PL_numeric_local; \
        if (was_local) SET_NUMERIC_STANDARD();
 
+/* Doesn't change to underlying locale unless within the scope of some form of
+ * 'use locale'.  This is the usual desired behavior. */
 #define STORE_NUMERIC_STANDARD_SET_LOCAL() \
-       bool was_standard = PL_numeric_standard && IN_LOCALE; \
+       bool was_standard = PL_numeric_standard && IN_SOME_LOCALE_FORM; \
        if (was_standard) SET_NUMERIC_LOCAL();
 
 #define RESTORE_NUMERIC_LOCAL() \
index 0ecf9a9..d4419ca 100644 (file)
@@ -113,6 +113,18 @@ EOF
         }
 
         {
+           fresh_perl_is(<<'EOF', $difference, {},
+use locale ":not_characters";
+format STDOUT =
+@.#
+4.179
+.
+write;
+EOF
+           "format() looks at LC_NUMERIC with 'use locale \":not_characters\"'");
+        }
+
+        {
            fresh_perl_is(<<'EOF', "4.2", {},
 format STDOUT =
 @.#
@@ -213,4 +225,4 @@ EOF
 
 } # SKIP
 
-sub last { 11 }
+sub last { 12 }