locale.c: Always set state variables for a new locale
authorKarl Williamson <public@khwilliamson.com>
Wed, 11 Dec 2013 21:30:45 +0000 (14:30 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 4 Jan 2014 20:33:04 +0000 (13:33 -0700)
This function is called when a new underlying LC_NUMERIC locale has been
set.  If that locale is the same as the current underlying one, some
setup is skipped.  However, prior to this commit, more was skipped than
should have been.  The reason is that even if the underlying locale is
the same, it could be that LC_NUMERIC has been toggled to the "C"
locale, and so the information could be inconsistent.  By always setting
the information, we ensure consistency.

This commit ia a portion of the fix for [perl #120723].  Tests will be
added with the final commit for it.

locale.c

index 31aa592..6f8e551 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -134,15 +134,13 @@ Perl_new_numeric(pTHX_ const char *newnum)
     if (! PL_numeric_name || strNE(PL_numeric_name, save_newnum)) {
        Safefree(PL_numeric_name);
        PL_numeric_name = save_newnum;
-       PL_numeric_standard = ((*save_newnum == 'C' && save_newnum[1] == '\0')
-                              || strEQ(save_newnum, "POSIX"));
-       PL_numeric_local = TRUE;
-       set_numeric_radix();
-    }
-    else {
-        Safefree(save_newnum);
     }
 
+        PL_numeric_standard = ((*save_newnum == 'C' && save_newnum[1] == '\0')
+                                || strEQ(save_newnum, "POSIX"));
+        PL_numeric_local = TRUE;
+        set_numeric_radix();
+
 #endif /* USE_LOCALE_NUMERIC */
 }