diff options
author | Karl Williamson <khw@cpan.org> | 2018-01-17 17:01:00 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-01-30 22:12:46 -0700 |
commit | 665873e948cf9825de44d5a63db7770ac561ff8f (patch) | |
tree | 464c74485715a35752a28f335aef47a160e58a44 /numeric.c | |
parent | aec39ab9804a09eb0b8c7320980e229fe7bbd986 (diff) | |
download | perl-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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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); |