summaryrefslogtreecommitdiff
path: root/ext/XS-APItest
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2021-08-15 15:34:12 +0100
committerKarl Williamson <khw@cpan.org>2022-03-04 10:31:41 -0700
commit7294e9f9f09f98d7bff4bfdae266a8f8121f907c (patch)
treeefe6f789a51e63bb20ec5529a4567fb167d1bcd2 /ext/XS-APItest
parent98656496a12e0020bb1e4b971adc847ab7698c9d (diff)
downloadperl-7294e9f9f09f98d7bff4bfdae266a8f8121f907c.tar.gz
gh19010: fix returns for Perl_grok_infnan
Consistently honour what the docs have always promised: If an infinity or a not-a-number is recognized, C<*sp> will point to one byte past the end of the recognized string. If the recognition fails, zero is returned, and C<*sp> will not move. Additionally, restore Perl_grok_number_flags to allowing inf/nan with trailing garbage only when called with PERL_SCAN_TRAILING; add notes to the other two core callers to clarify that they always accept such trailing garbage. A small number of XS-APItest tests were modified to reflect the stricter behaviour: "Infin" and "nanx" are now invalid without PERL_SCAN_TRAILING.
Diffstat (limited to 'ext/XS-APItest')
-rw-r--r--ext/XS-APItest/t/grok.t17
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/XS-APItest/t/grok.t b/ext/XS-APItest/t/grok.t
index b6ad905b60..7347e4f1fe 100644
--- a/ext/XS-APItest/t/grok.t
+++ b/ext/XS-APItest/t/grok.t
@@ -86,14 +86,17 @@ my @groks =
[ "Inf", 0, undef,
IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT ],
[ "In", 0, undef, 0 ],
- [ "Infin",0, undef, IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT | IS_NUMBER_TRAILING ],
- # this doesn't work and hasn't been needed yet
- #[ "Infin",PERL_SCAN_TRAILING, undef,
- # IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT | IS_NUMBER_TRAILING ],
+ [ "Infin",0, undef, 0 ],
+ [ "Infin",PERL_SCAN_TRAILING, undef,
+ IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT | IS_NUMBER_TRAILING ],
[ "nan", 0, undef, IS_NUMBER_NAN | IS_NUMBER_NOT_INT ],
- # even without PERL_SCAN_TRAILING nan can have weird stuff trailing
- [ "nanx", 0, undef, IS_NUMBER_NAN | IS_NUMBER_NOT_INT | IS_NUMBER_TRAILING ],
- [ "nanx", PERL_SCAN_TRAILING, undef, IS_NUMBER_NAN | IS_NUMBER_NOT_INT | IS_NUMBER_TRAILING ],
+ # even without PERL_SCAN_TRAILING nan can have specific weird stuff trailing
+ [ "nanq", 0, undef, IS_NUMBER_NAN | IS_NUMBER_NOT_INT ],
+ [ "nan(123)", 0, undef, IS_NUMBER_NAN | IS_NUMBER_NOT_INT ],
+ # but not just anything
+ [ "nanx", 0, undef, 0 ],
+ [ "nanx", PERL_SCAN_TRAILING, undef,
+ IS_NUMBER_NAN | IS_NUMBER_NOT_INT | IS_NUMBER_TRAILING ],
);
my $non_ieee_fp = ($Config{doublekind} == 9 ||