develooper Front page | perl.perl5.porters | Postings from December 2011

[perl #29070] Deparsing v-string operands to ~ loses the ~

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
December 23, 2011 14:47
Subject:
[perl #29070] Deparsing v-string operands to ~ loses the ~
Message ID:
rt-3.6.HEAD-14510-1324680417-1451.29070-15-0@perl.org
On Fri Dec 23 09:58:54 2011, sprout wrote:
> On Thu Jul 26 05:08:19 2007, jpeacock@rowman.com wrote:
> > Better to patch
> > B::Deparse to make an effort to see whether the original string
> > representation
> > is still valid (though I have this vague memory that code in toke.c is
> > not part
> > of the public API, and hence is not available to use here).
> 
> It’s not just B::Deparse, but the version module, too, that is affected:
> 
> $ ./perl -Ilib -le 'print version->new(~v165);
> v165
> 
> And constant folding is not where the problem lies:
> 
> $ ./perl -Ilib -le 'print new version ~$_ for "\xce", v2, "\xcc"'
> 1
> v2
> 3

I tried adding a simple set callback that frees the magic, but that, of
course, stops $x=v0 from having vstring magic set on $x afterwards.

pp_complement does sv_setsv, forces it to a string, modifies it, and
then calls set-magic.

That should be perfectly acceptable.  pp_complement shouldn’t have to
know about vstring magic.

So I have added a set callback that checks whether the string is still
the same.  (This doesn’t belong in Deparse, as it applies to core
operators, too.)  It is in commit 1e6bda93.

-- 

Father Chrysostomos


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

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