This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX.xs: Keep locale change to minimum span
authorKarl Williamson <khw@cpan.org>
Wed, 17 Jan 2018 00:38:45 +0000 (17:38 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 31 Jan 2018 05:49:03 +0000 (22:49 -0700)
Move the restore to as close to the save as possible so that the locale
is in an unstable state for as short a time as possible.

ext/POSIX/POSIX.xs

index d3bbfd8..3908f43 100644 (file)
@@ -3295,6 +3295,7 @@ strtod(str)
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
         STORE_LC_NUMERIC_FORCE_TO_UNDERLYING();
        num = strtod(str, &unparsed);
+        RESTORE_LC_NUMERIC();
        PUSHs(sv_2mortal(newSVnv(num)));
        if (GIMME_V == G_ARRAY) {
            EXTEND(SP, 1);
@@ -3303,7 +3304,6 @@ strtod(str)
            else
                PUSHs(&PL_sv_undef);
        }
-        RESTORE_LC_NUMERIC();
 
 #ifdef HAS_STRTOLD
 
@@ -3317,6 +3317,7 @@ strtold(str)
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
         STORE_LC_NUMERIC_FORCE_TO_UNDERLYING();
        num = strtold(str, &unparsed);
+        RESTORE_LC_NUMERIC();
        PUSHs(sv_2mortal(newSVnv(num)));
        if (GIMME_V == G_ARRAY) {
            EXTEND(SP, 1);
@@ -3325,7 +3326,6 @@ strtold(str)
            else
                PUSHs(&PL_sv_undef);
        }
-        RESTORE_LC_NUMERIC();
 
 #endif