summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorsisyphus <sisyphus1@optusnet.com.au>2018-08-01 22:33:38 +1000
committerKarl Williamson <khw@cpan.org>2018-08-09 11:27:35 -0600
commitce6f496d720f6206455628425320badd95b07372 (patch)
tree5e75aeff30de41a8f6ec48d02af97410dae86157 /numeric.c
parentc7ea9f039c0e7c2333adfcb3b9f1e3f2b25693a1 (diff)
downloadperl-ce6f496d720f6206455628425320badd95b07372.tar.gz
PATCH: [perl #41202] text->float gives wrong answer
This changes to use Perl_strtod() when available, and that turns out to be the key to fixing this bug. S_mulexp10() is removed from embed.fnc to avoid repeating the complicated prerequisites for defining Perl_strtod(). This works because this static function already was defined before use in numeric.c, and always called in full form without using a macro. James Keenan fixed a file permissions problem originally introduced by this commit, but the fix has been squashed into it.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/numeric.c b/numeric.c
index 486aa1c6b7..00f41fce7f 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1145,7 +1145,7 @@ Perl_grok_atoUV(const char *pv, UV *valptr, const char** endptr)
return TRUE;
}
-#ifndef USE_QUADMATH
+#ifndef Perl_strtod
STATIC NV
S_mulexp10(NV value, I32 exponent)
{
@@ -1241,9 +1241,9 @@ S_mulexp10(NV value, I32 exponent)
}
return negative ? value / result : value * result;
}
-#endif /* #ifndef USE_QUADMATH */
+#endif /* #ifndef Perl_strtod */
-#ifdef USE_QUADMATH
+#ifdef Perl_strtod
# define ATOF(s, x) my_atof2(s, &x)
# else
# define ATOF(s, x) Perl_atof2(s, x)
@@ -1406,13 +1406,13 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, STRLEN len)
{
const char* s = orig;
NV result[3] = {0.0, 0.0, 0.0};
-#if defined(USE_PERL_ATOF) || defined(USE_QUADMATH)
+#if defined(USE_PERL_ATOF) || defined(Perl_strtod)
const char* send = s + ((len != 0)
? len
: strlen(orig)); /* one past the last */
bool negative = 0;
#endif
-#if defined(USE_PERL_ATOF) && !defined(USE_QUADMATH)
+#if defined(USE_PERL_ATOF) && !defined(Perl_strtod)
UV accumulator[2] = {0,0}; /* before/after dp */
bool seen_digit = 0;
I32 exp_adjust[2] = {0,0};
@@ -1425,7 +1425,7 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, STRLEN len)
I32 sig_digits = 0; /* noof significant digits seen so far */
#endif
-#if defined(USE_PERL_ATOF) || defined(USE_QUADMATH)
+#if defined(USE_PERL_ATOF) || defined(Perl_strtod)
PERL_ARGS_ASSERT_MY_ATOF3;
/* leading whitespace */
@@ -1442,7 +1442,7 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, STRLEN len)
}
#endif
-#ifdef USE_QUADMATH
+#ifdef Perl_strtod
{
char* endp;
char* copy = NULL;
@@ -1460,7 +1460,7 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, STRLEN len)
s = copy + (s - orig);
}
- result[2] = strtoflt128(s, &endp);
+ result[2] = Perl_strtod(s, &endp);
/* If we created a copy, 'endp' is in terms of that. Convert back to
* the original */