IS_NUMBER_NAN | IS_NUMBER_NEG
0
+possibly with IS_NUMBER_TRAILING.
+
If an infinity or not-a-number is recognized, the *sp will point to
one past the end of the recognized string. If the recognition fails,
zero is returned, and the *sp will not move.
while (*s == '0') { /* 1.#INF00 */
s++;
}
- if (*s) {
+ while (s < send && isSPACE(*s))
+ s++;
+ if (s < send && *s) {
flags |= IS_NUMBER_TRAILING;
}
flags |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
/* Looked like nan(...), but no close paren. */
flags |= IS_NUMBER_TRAILING;
}
- } else if (*s) {
- /* Note that we here implicitly accept (parse as
- * "nan", but with warnings) also any other weird
- * trailing stuff for "nan". In the above we just
- * check that if we got the C99-style "nan(...)",
- * the "..." looks sane.
- * If in future we accept more ways of specifying
- * the nan payload, the accepting would happen around
- * here. */
- flags |= IS_NUMBER_TRAILING;
+ } else {
+ while (s < send && isSPACE(*s))
+ s++;
+ if (s < send && *s) {
+ /* Note that we here implicitly accept (parse as
+ * "nan", but with warnings) also any other weird
+ * trailing stuff for "nan". In the above we just
+ * check that if we got the C99-style "nan(...)",
+ * the "..." looks sane.
+ * If in future we accept more ways of specifying
+ * the nan payload, the accepting would happen around
+ * here. */
+ flags |= IS_NUMBER_TRAILING;
+ }
}
s = send;
}
return 0;
}
+ while (s < send && isSPACE(*s))
+ s++;
+
*sp = s;
return flags;
}
[ "1.#INFx", 1, $PInf ],
[ "1.#INF00", 0, $PInf ],
[ "1.#INFxy", 1, $PInf ],
+ [ " inf", 0, $PInf ],
+ [ "inf ", 0, $PInf ],
+ [ " inf ", 0, $PInf ],
[ "nan", 0, $NaN ],
[ "nanxy", 1, $NaN ],
[ "1.#IND", 0, $NaN ],
[ "1.#IND00", 0, $NaN ],
[ "1.#INDxy", 1, $NaN ],
+ [ " nan", 0, $NaN ],
+ [ "nan ", 0, $NaN ],
+ [ " nan ", 0, $NaN ],
];
for my $t (@$T) {
- print "# $t->[0] compile time\n";
+ print "# '$t->[0]' compile time\n";
my $a;
$w = '';
eval '$a = "'.$t->[0].'" + 1';
} else {
is($w, "", "no warning expected");
}
- print "# $t->[0] runtime\n";
+ print "# '$t->[0]' runtime\n";
my $n = $t->[0];
my $b;
$w = '';