This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Introduce Perl_strtod (macro) to call strtold if long doubles.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 21 Aug 2014 17:03:53 +0000 (13:03 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 22 Aug 2014 14:29:59 +0000 (10:29 -0400)
Not that much effect since strtod is now only used to parse inf/nan
and then only if NV_INF + NV_NAN are missing.  (Earlier strtod()
returned always the double inf/nan, not the long double inf/nan.)

numeric.c
perl.h

index f178662..b137ad9 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -1188,7 +1188,7 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value)
             /* The native strtod() may not get all the possible
              * inf/nan strings PEEK_INFNAN() recognizes. */
             char* endp;
-            NV nv = strtod(p, &endp);
+            NV nv = Perl_strtod(p, &endp);
             if (p != endp) {
                 *value = nv;
                 return endp;
diff --git a/perl.h b/perl.h
index bc4209f..dd2c37a 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5563,6 +5563,16 @@ typedef struct am_table_short AMTS;
 
 #endif /* !USE_LOCALE_NUMERIC */
 
+#if defined(HAS_LONG_DOUBLE) && defined(USE_LONG_DOUBLE)
+#  if defined(HAS_STRTOLD)
+#    define Perl_strtod(s, e) strtold(s, e)
+#  elif defined(HAS_STRTOD)
+#    define Perl_strtod(s, e) (NV)strtod(s, e) /* Unavoidable loss. */
+#  endif
+#elif defined(HAS_STRTOD)
+#  define Perl_strtod(s, e) strtod(s, e)
+#endif
+
 #if !defined(Strtol) && defined(USE_64_BIT_INT) && defined(IV_IS_QUAD) && \
        (QUADKIND == QUAD_IS_LONG_LONG || QUADKIND == QUAD_IS___INT64)
 #    ifdef __hpux