diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-06-26 00:13:54 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-06-26 00:37:09 -0500 |
commit | 78787052b6a68c0f54cfa983a69c44276de9daa4 (patch) | |
tree | a3bda9e9d2d3a9b3613c45305e17802a041ac9e5 /numeric.c | |
parent | df8a53a3dd89e38abbe84d468df77ae060003e25 (diff) | |
download | perl-78787052b6a68c0f54cfa983a69c44276de9daa4.tar.gz |
use a less broken test for locale radix in atof [perl #109318]
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -847,17 +847,22 @@ Perl_my_atof(pTHX_ const char* s) PERL_ARGS_ASSERT_MY_ATOF; - if (PL_numeric_local && IN_SOME_LOCALE_FORM) { - NV y; + if (PL_numeric_local && PL_numeric_radix_sv && IN_SOME_LOCALE_FORM) { + char *standard = NULL, *local = NULL; + bool use_standard_radix; - /* Scan the number twice; once using locale and once without; - * choose the larger result (in absolute value). */ - Perl_atof2(s, x); - SET_NUMERIC_STANDARD(); - Perl_atof2(s, y); - SET_NUMERIC_LOCAL(); - if ((y < 0.0 && y < x) || (y > 0.0 && y > x)) - return y; + standard = strchr(s, '.'); + local = strstr(s, SvPV_nolen(PL_numeric_radix_sv)); + + use_standard_radix = standard && (!local || standard < local); + + if (use_standard_radix) + SET_NUMERIC_STANDARD(); + + Perl_atof2(s, x); + + if (use_standard_radix) + SET_NUMERIC_LOCAL(); } else Perl_atof2(s, x); |