In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/3fd158eacc9126db15ab0358a65d4c6ba00d15e8?hp=031c3a38999d6e1e63aef26d19b11392d8fee4f4>

- Log -----------------------------------------------------------------
commit 3fd158eacc9126db15ab0358a65d4c6ba00d15e8
Author: Jarkko Hietaniemi <j...@iki.fi>
Date:   Sat Sep 20 13:45:20 2014 -0400

    On VC6 (broken NaN compare) redefine Perl_isinf.
    
    So that it works with NaN, by not using the comparison version of
    Perl_isinf.  A little messy but since win32/win32.h is included so
    late in perl.h, cannot be done earlier with the other Perl_isinf
    logic.  Partially reverts 128eeacb.
-----------------------------------------------------------------------

Summary of changes:
 perl.h        |  7 +++++++
 sv.c          | 24 ++++++++++--------------
 win32/win32.h |  3 ++-
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/perl.h b/perl.h
index 5615b96..0b8e1db 100644
--- a/perl.h
+++ b/perl.h
@@ -3029,6 +3029,13 @@ typedef pthread_key_t    perl_key;
 
 #if defined(WIN32)
 #  include "win32.h"
+#  ifdef NAN_COMPARE_BROKEN /* VC6 */
+/* We need to redefine Perl_isinf() because we most likely defined it
+ * using the <DBL_MIN || >DBL_MAX way, which is broken if the NaN
+ * compare is broken. */
+#    undef Perl_isinf
+#    define Perl_isinf(x) Perl_fp_class_inf(x)
+#  endif
 #endif
 
 #ifdef NETWARE
diff --git a/sv.c b/sv.c
index b22f770..2ff999f 100644
--- a/sv.c
+++ b/sv.c
@@ -2821,20 +2821,7 @@ S_infnan_2pv(NV nv, char* buffer, size_t maxlen) {
         return 0;
     else {
         char* s = buffer;
-        /* isnan must be first due to NAN_COMPARE_BROKEN builds, since NAN 
might
-           use the broken for NAN >/< ops in the inf check, and then the inf
-           check returns true for NAN on NAN_COMPARE_BROKEN compilers */
-        if (Perl_isnan(nv)) {
-            *s++ = 'N';
-            *s++ = 'a';
-            *s++ = 'N';
-            /* XXX optionally output the payload mantissa bits as
-             * "(unsigned)" (to match the nan("...") C99 function,
-             * or maybe as "(0xhhh...)"  would make more sense...
-             * provide a format string so that the user can decide?
-             * NOTE: would affect the maxlen and assert() logic.*/
-        }
-        else if (Perl_isinf(nv)) {
+        if (Perl_isinf(nv)) {
             if (nv < 0) {
                 if (maxlen < 5) /* "-Inf\0"  */
                     return 0;
@@ -2843,6 +2830,15 @@ S_infnan_2pv(NV nv, char* buffer, size_t maxlen) {
             *s++ = 'I';
             *s++ = 'n';
             *s++ = 'f';
+        } else if (Perl_isnan(nv)) {
+            *s++ = 'N';
+            *s++ = 'a';
+            *s++ = 'N';
+            /* XXX optionally output the payload mantissa bits as
+             * "(unsigned)" (to match the nan("...") C99 function,
+             * or maybe as "(0xhhh...)"  would make more sense...
+             * provide a format string so that the user can decide?
+             * NOTE: would affect the maxlen and assert() logic.*/
         }
 
         else
diff --git a/win32/win32.h b/win32/win32.h
index 8db0303..8587ac8 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -255,7 +255,8 @@ typedef unsigned short      mode_t;
 #define vsnprintf      _vsnprintf
 
 #ifdef USING_MSVC6
-/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */
+/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false,
+ * and for example NaN < IV_MIN. */
 #define NAN_COMPARE_BROKEN 1
 #endif
 

--
Perl5 Master Repository

Reply via email to