This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make sure locale set right for radix parsing
authorKarl Williamson <khw@cpan.org>
Sun, 1 Jun 2014 22:02:24 +0000 (16:02 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 5 Jun 2014 17:23:00 +0000 (11:23 -0600)
I haven't found a test case this fails for in v5.20, but I'm sure there
is one.  But two commits from now would fail if this wasn't done.

numeric.c

index 3463f2d..c1da39e 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -528,13 +528,18 @@ Perl_grok_numeric_radix(pTHX_ const char **sp, const char *send)
 
     PERL_ARGS_ASSERT_GROK_NUMERIC_RADIX;
 
-    if (PL_numeric_radix_sv && IN_SOME_LOCALE_FORM) {
+    if (IN_SOME_LOCALE_FORM) {
+        DECLARE_STORE_LC_NUMERIC_SET_TO_NEEDED();
+        if (PL_numeric_radix_sv) {
         STRLEN len;
         const char * const radix = SvPV(PL_numeric_radix_sv, len);
         if (*sp + len <= send && memEQ(*sp, radix, len)) {
             *sp += len;
+            RESTORE_LC_NUMERIC();
             return TRUE; 
         }
+        }
+        RESTORE_LC_NUMERIC();
     }
     /* always try "." if numeric radix didn't match because
      * we may have data from different locales mixed */