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

[perl #108952] [PATCH] 97df921 fix PerlIO-scalar test when unpack J fails

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
January 24, 2012 13:01
Subject:
[perl #108952] [PATCH] 97df921 fix PerlIO-scalar test when unpack J fails
Message ID:
rt-3.6.HEAD-14510-1327438892-1906.108952-15-0@perl.org
On Tue Jan 24 10:35:00 2012, ikegami@adaelis.com wrote:
> On Tue, Jan 24, 2012 at 12:26 PM, Father Chrysostomos via RT <
> perlbug-followup@perl.org> wrote:
> 
> > On Tue Jan 24 09:14:08 2012, rurban wrote:
> > > The reason of the failure is Config::Config{ptrsize} ==
> > > $Config::Config{intsize}.
> > > On the failing platform it is 4 vs 8.
> > >
> > > So use unpack "I" instead.
> >
> > Eric Brine’s patch has already been applied as 6fa2c250307, but yours
> > looks more robust to me, er, I *think*.
> >
> > Is it guaranteed that unpack "J" will return undef in those cases where
> > it fails?
> >
> 
> Assuming we take it for granted that these unpack return undef when the
> string is too short (even though that's not documented).
> 
> If sizeof(void*) == sizeof(UV): No problem
> If sizeof(void*) < sizeof(UV) && sizeof(void*) == sizeof(int): Ok
> If sizeof(void*) < sizeof(UV) && sizeof(void*) > sizeof(int): Won't work,
> but not currently possible.
> If sizeof(void*) < sizeof(UV) && sizeof(void*) < sizeof(int): Won't work,
> but not currently possible.
> If sizeof(void*) > sizeof(UV): Impossible
> 
> UV are guaranteed to be large enough to hold a pointer,
> 
> If you want more robust, I'd recommend:
> 
> my $ptrlen = length(pack("P", "abc"));
> my $ptrfmt = $ptrlen == length(pack("J", 0)) ? "J"
>            : $ptrlen == length(pack("I", 0)) ? "I"
>            : die;

OK, then I’ll leave it to you whether we should change it. :-)


-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=108952

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