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

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

Thread Previous | Thread Next
Father Chrysostomos via RT
December 23, 2011 14:47
[perl #29070] Deparsing v-string operands to ~ loses the ~
Message ID:
On Fri Dec 23 09:58:54 2011, sprout wrote:
> On Thu Jul 26 05:08:19 2007, 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

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About