develooper Front page | perl.perl5.porters | Postings from January 2015

[perl #123676] [blead] looks_like_number XSub currently handles inf wrongly.

Thread Next
From:
Sisyphus
Date:
January 26, 2015 05:21
Subject:
[perl #123676] [blead] looks_like_number XSub currently handles inf wrongly.
Message ID:
rt-4.0.18-25054-1422249692-886.123676-75-0@perl.org
# New Ticket Created by  "Sisyphus" 
# Please include the string:  [perl #123676]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123676 >


Hi,

The problem seems only to apply to 'inf' strings. I haven't detected any 
errors regarding other strings (including nan strings).

Here's the demo:

##########################
use warnings;
use strict;

use Inline C  => Config =>
  BUILD_NOISY => 1;

use Inline C => <<'EOC';

int foo(SV * in) {
  if(looks_like_number(in)) return 1;
  return 0;
}

EOC

print foo("inf\t" ), "\n"; # 0
print foo("inf\f" ), "\n"; # 0
print foo("inf\n" ), "\n"; # 0
print foo('inf '  ), "\n"; # 0
print foo(' inf'  ), "\n"; # 1
print foo(' inf ' ), "\n"; # 0
print foo('+inf ' ), "\n"; # 0
print foo(' +inf' ), "\n"; # 1
print foo(' +inf '), "\n"; # 0
print foo('-inf ' ), "\n"; # 0
print foo(' -inf' ), "\n"; # 1
print foo(' -inf '), "\n"; # 0
print foo(' -47  '), "\n"; # 1
print "\n";
##########################

The comments at the end of the print() statements show the value that gets 
printed using current blead (5.21.9 as of 2 days ago).
UIM, the problem occurs whenn there's some trailing whitespace.
With perl-5.20.0 (and earlier) all return values are "1".

There's mention in perl5215delta.pod of a fix that was applied to 
looks_like_number(). Perhaps that's where the change in behaviour crept in - 
I haven't checked.
Or perhaps it has been fixed in the last couple of days - though I can't 
find any recent mention of 'looks_like_number' in 'git log'.

Cheers,
Rob 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About