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

Re: New release ?

Thread Previous | Thread Next
From:
SADAHIRO Tomoyuki
Date:
January 8, 2007 04:39
Subject:
Re: New release ?
Message ID:
20070108213820.06C6.BQW10602@nifty.com

On Mon, 8 Jan 2007 09:43:52 +0000, Nicholas Clark wrote

> > The test failures that were caused by setting NV_PRESERVES_UV_BITS
> > to zero should have been fixed by Sadahiro's patch, which has just
> > been applied (change #29693).
> 
> I couldn't work out why I couldn't replicate the failures.
> In turn, I wasn't sure how Data::Dumper could be assuming too much.

This is the behavior of perl-current:

If NV_PRESERVES_UV is undef and the bits is short,
1. S_sv_2iuv_common() called from Perl_sv_2iv_flags won't make
   IOK for a float set on.
2. sv_2nv() make IOK for a string standing for an integer set on.

But the D::D's assumptions that perl-current behaves differently are
1. sprintf("%d", $float) should IV-ize the float whose NV equals to IV.
2. sprintf("%e", $string) shouldn't IV-ize the string.
# Note. D::D XS dumps SV unquoted if DD_is_integer, that is SvIOK.

A brief from the problematic part of the test, with some comments left:

#!perl
use Data::Dumper;
$Data::Dumper::Pad = "#";
$Data::Dumper::Useperl = 1;

# The XS code differs.
# These are the numbers as seen by the tokeniser. Constants aren't folded
# (which makes IVs where possible) so values the tokeniser thought were
# floating point are stored as NVs. The XS code outputs these as strings,
# but as it has converted them from NVs, leading + signs will not be there.
my @num = (3.0);
print 'XS Numbers       ', Data::Dumper->new(\@num)->Dumpxs;
# These are the numbers as IV-ized by &
# These will differ from WANT_XS_N because now IV flags will be set on all
# values that were actually integer, and the XS code will then output these
# as numbers not strings.
$b = sprintf "%d", $_ for @num;
print 'XS Numbers IV    ', Data::Dumper->new(\@num)->Dumpxs;
$b = sprintf "%s", $_ for @num;
print 'XS Numbers IV,PV ', Data::Dumper->new(\@num)->Dumpxs;

# These are the strings as seen by the tokeniser. The XS code will output
# these for all cases except where the scalar has been used in integer context
my @str = ("-2");
print 'XS Strings       ', Data::Dumper->new(\@str)->Dumpxs;
$b = sprintf "%e", $_ for @str;
print 'XS Strings NV    ', Data::Dumper->new(\@str)->Dumpxs;
$b = sprintf "%s", $_ for @str;
print 'XS Strings NV,PV ', Data::Dumper->new(\@str)->Dumpxs;
__END__

--Expected (defined NV_PRESERVES_UV)
XS Numbers       #$VAR1 = '3';
XS Numbers IV    #$VAR1 = 3;
XS Numbers IV,PV #$VAR1 = 3;
XS Strings       #$VAR1 = '-2';
XS Strings NV    #$VAR1 = '-2';
XS Strings NV,PV #$VAR1 = '-2';
--Got (undef NV_PRESERVES_UV and too small NV_PRESERVES_UV_BITS)
XS Numbers       #$VAR1 = '3';
XS Numbers IV    #$VAR1 = '3';
XS Numbers IV,PV #$VAR1 = '3';
XS Strings       #$VAR1 = '-2';
XS Strings NV    #$VAR1 = -2;
XS Strings NV,PV #$VAR1 = -2;

Regards,
SADAHIRO Tomoyuki



Thread Previous | 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