summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-01-17 17:01:00 -0700
committerKarl Williamson <khw@cpan.org>2018-01-30 22:12:46 -0700
commit665873e948cf9825de44d5a63db7770ac561ff8f (patch)
tree464c74485715a35752a28f335aef47a160e58a44 /numeric.c
parentaec39ab9804a09eb0b8c7320980e229fe7bbd986 (diff)
downloadperl-665873e948cf9825de44d5a63db7770ac561ff8f.tar.gz
my_atof(): Lock dot radix
This commit shows some redundant checks. It examines the text and if it finds a dot in the middle of the number, and the locale is expecting something else, it toggles LC_NUMERIC to be the C locale so that the dot is understood. However, during further parsing, grok_numeric_radix() gets called and sees that the locale shouldn't be C, and toggles it back. That ordinarily would cause the dot to not be recognized, but this function always recognizes a dot no matter what the locale. So none of our tests fail. I'm not sure if this is always the case, and I don't understand this area of the code all that well, but there is a simple way to cause grok_numeric_radix to not change the locale back, and that is to call the macro LOCK_LC_NUMERIC_STANDARD() when changing it the first time in my_atof(). The purpose of this macro is precisely this situation, so that recursed calls don't try to override the decisions of the outer calls
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index 7065486497..50c85a406c 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1242,13 +1242,17 @@ Perl_my_atof(pTHX_ const char* s)
const bool use_standard_radix
= standard_pos && (!local_pos || standard_pos < local_pos);
- if (use_standard_radix)
+ if (use_standard_radix) {
SET_NUMERIC_STANDARD();
+ LOCK_LC_NUMERIC_STANDARD();
+ }
Perl_atof2(s, x);
- if (use_standard_radix)
+ if (use_standard_radix) {
+ UNLOCK_LC_NUMERIC_STANDARD();
SET_NUMERIC_UNDERLYING();
+ }
}
else
Perl_atof2(s, x);