In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/e855f543ec46829b7b6b39e126dc510df2e3f5b5?hp=fa367bcbf78381959666f443b5f1d9da7870f943>

- Log -----------------------------------------------------------------
commit e855f543ec46829b7b6b39e126dc510df2e3f5b5
Author: Jarkko Hietaniemi <[email protected]>
Date:   Mon Oct 20 18:33:41 2014 -0400

    Fix misparse of "Ind" as NaN (long story...) [perl #122843]
    
    While at it, add more "false nan" parse tests.
-----------------------------------------------------------------------

Summary of changes:
 numeric.c     | 4 +++-
 t/op/infnan.t | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/numeric.c b/numeric.c
index 171f593..5398d72 100644
--- a/numeric.c
+++ b/numeric.c
@@ -610,6 +610,7 @@ Perl_grok_infnan(const char** sp, const char* send)
 {
     const char* s = *sp;
     int flags = 0;
+    bool odh = FALSE; /* one dot hash: 1.#INF */
 
     PERL_ARGS_ASSERT_GROK_INFNAN;
 
@@ -631,6 +632,7 @@ Perl_grok_infnan(const char** sp, const char* send)
             s++; if (s == send) return 0;
         } else
             return 0;
+        odh = TRUE;
     }
 
     if (isALPHA_FOLD_EQ(*s, 'I')) {
@@ -652,7 +654,7 @@ Perl_grok_infnan(const char** sp, const char* send)
                 return 0;
             flags |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
         }
-        else if (isALPHA_FOLD_EQ(*s, 'D')) {
+        else if (isALPHA_FOLD_EQ(*s, 'D') && odh) { /* 1.#IND */
             s++;
             flags |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
         } else
diff --git a/t/op/infnan.t b/t/op/infnan.t
index 48703d0..ea05d01 100644
--- a/t/op/infnan.t
+++ b/t/op/infnan.t
@@ -337,6 +337,15 @@ SKIP: {
     is(sin(9**9**9), $NaN, "sin(9**9**9) is NaN");
 }
 
+SKIP: {
+    my @FNaN = qw(NaX XNAN Ind Inx);
+    # Silence "isn't numeric in addition", that's kind of the point.
+    local $^W = 0;
+    for my $i (@FNaN) {
+        cmp_ok("$i" + 0, '==', 0, "false nan $i");
+    }
+}
+
 # === Tests combining Inf and NaN ===
 
 # is() okay with $NaN because it uses eq.

--
Perl5 Master Repository

Reply via email to