From 213084e431373aec68f094fabf7c87419d9c7688 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Fri, 13 Jan 2012 09:32:20 -0800 Subject: [PATCH] defined *{"+"} should not stop %+ from working The same applies to %-. This is something I broke when merging is_magical_gv with gv_fetchpvn_flags. gv_fetchpvn_flags must make sure its *+ glob is present in the symbol table when it loads Tie::Hash::NamedCapture. If it adds it afterwards it will clobber another *+ that Tie::Hash::NamedCapture has autovivi- fied and tied in the mean time. --- gv.c | 4 ++++ t/op/magic.t | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gv.c b/gv.c index 9da6c1a..af8f289 100644 --- a/gv.c +++ b/gv.c @@ -1913,7 +1913,11 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, SvREADONLY_on(av); if (sv_type == SVt_PVHV || sv_type == SVt_PVGV) + { + if (addmg) (void)hv_store(stash,name,len,(SV *)gv,0); + addmg = 0; require_tie_mod(gv, name, newSVpvs("Tie::Hash::NamedCapture"), "TIEHASH", 0); + } break; } diff --git a/t/op/magic.t b/t/op/magic.t index 494847f..9b43069 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -5,7 +5,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan (tests => 154); + plan (tests => 156); } # Test that defined() returns true for magic variables created on the fly, @@ -545,6 +545,24 @@ foreach my $sig (qw(__DIE__ _BOGUS_HOOK KILL THIRSTY)) { } +# %+ %- +SKIP: { + skip_if_miniperl("No XS in miniperl", 3); + # Make sure defined(*{"+"}) before %+ does not stop %+ from working + is + runperl( + prog => 'BEGIN { defined *{q-+-} } print qq-ok\n- if tied %+', + ), + "ok\n", + 'defined *{"+"} does not stop %+ from working'; + is + runperl( + prog => 'BEGIN { defined *{q=-=} } print qq-ok\n- if tied %-', + ), + "ok\n", + 'defined *{"-"} does not stop %- from working'; +} + SKIP: { skip_if_miniperl("No XS in miniperl", 3); -- 2.7.4