This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
infnan: Allow 1.#INF00 and 1.#IND00
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 25 Jan 2015 14:42:19 +0000 (09:42 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 28 Jan 2015 11:52:31 +0000 (06:52 -0500)
Windowese for inf and nan.  The exact number of trailing zeros seems
to vary, maybe controlled by printf precision?  Or RTL dependent?

numeric.c
t/op/infnan.t

index 9e05d55..ddb6111 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -650,13 +650,21 @@ Perl_grok_infnan(const char** sp, const char* send)
                          !(isALPHA_FOLD_EQ(*s, 'Y') ||
                            isALPHA_FOLD_EQ(*s, 'E'))) return 0;
                 s++; if (s < send) return 0;
-            } else if (*s)
-                return 0;
+            } else {
+                while (*s == '0') { /* 1.#INF00 */
+                    s++;
+                }
+                if (*s)
+                    return 0;
+            }
             flags |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
         }
         else if (isALPHA_FOLD_EQ(*s, 'D') && odh) { /* 1.#IND */
             s++;
             flags |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
+            while (*s == '0') { /* 1.#IND00 */
+                s++;
+            }
         } else
             return 0;
     }
index ef8ee4b..97054cd 100644 (file)
@@ -28,11 +28,11 @@ my $NaN;
 
 my @PInf = ("Inf", "inf", "INF", "+Inf",
             "Infinity", "INFINITE",
-            "1.#INF", "1#INF");
+            "1.#INF", "1#INF", "1.#INF00");
 my @NInf = map { "-$_" } grep { ! /^\+/ } @PInf;
 
 my @NaN = ("NAN", "nan", "qnan", "SNAN", "NanQ", "NANS",
-           "1.#QNAN", "+1#SNAN", "-1.#NAN", "1#IND",
+           "1.#QNAN", "+1#SNAN", "-1.#NAN", "1#IND", "1.#IND00",
            "NaN123", "NAN(123)", "nan%",
            "nanonano"); # RIP, Robin Williams.