683572
From 22f05786af0b7f963440e47908cd5f35cf074c12 Mon Sep 17 00:00:00 2001
683572
From: Tony Cook <tony@develop-help.com>
683572
Date: Thu, 13 Jun 2019 10:05:15 +1000
683572
Subject: [PATCH] (perl #134193) allow %{^CAPTURE} to work when @{^CAPTURE}
683572
 comes first
683572
MIME-Version: 1.0
683572
Content-Type: text/plain; charset=UTF-8
683572
Content-Transfer-Encoding: 8bit
683572
683572
gv_magicalize() is called when the GV is created, so when the array
683572
was mentioned first, the hash wouldn't reach this code and the magic
683572
wouldn't be added to the hash.
683572
683572
This also fixes a similar problem with (%|@){^CAPTURE_ALL}, though
683572
@{^CAPTURE_ALL} is unused at this point.
683572
683572
Signed-off-by: Petr Písař <ppisar@redhat.com>
683572
---
683572
 ext/Tie-Hash-NamedCapture/t/tiehash.t | 3 +++
683572
 gv.c                                  | 6 ++----
683572
 2 files changed, 5 insertions(+), 4 deletions(-)
683572
683572
diff --git a/ext/Tie-Hash-NamedCapture/t/tiehash.t b/ext/Tie-Hash-NamedCapture/t/tiehash.t
683572
index 962754085f..cca05278f4 100644
683572
--- a/ext/Tie-Hash-NamedCapture/t/tiehash.t
683572
+++ b/ext/Tie-Hash-NamedCapture/t/tiehash.t
683572
@@ -3,6 +3,9 @@ use strict;
683572
 
683572
 use Test::More;
683572
 
683572
+# this would break the hash magic setup [perl #134193]
683572
+my ($ca, $c) = ( \@{^CAPTURE_ALL}, \@{^CAPTURE} );
683572
+
683572
 my %hashes = (
683572
     '+' => \%+,
683572
     '-' => \%-,
683572
diff --git a/gv.c b/gv.c
683572
index 46a32dcc20..2b83680898 100644
683572
--- a/gv.c
683572
+++ b/gv.c
683572
@@ -2032,13 +2032,11 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
683572
                     sv_magic(MUTABLE_SV(av), (SV*)n, PERL_MAGIC_regdata, NULL, 0);
683572
                     SvREADONLY_on(av);
683572
 
683572
-                    if (sv_type == SVt_PVHV || sv_type == SVt_PVGV)
683572
-                        require_tie_mod_s(gv, '-', "Tie::Hash::NamedCapture",0);
683572
+                    require_tie_mod_s(gv, '-', "Tie::Hash::NamedCapture",0);
683572
 
683572
                 } else          /* %{^CAPTURE_ALL} */
683572
                 if (memEQs(name, len, "\003APTURE_ALL")) {
683572
-                    if (sv_type == SVt_PVHV || sv_type == SVt_PVGV)
683572
-                        require_tie_mod_s(gv, '+', "Tie::Hash::NamedCapture",0);
683572
+                    require_tie_mod_s(gv, '+', "Tie::Hash::NamedCapture",0);
683572
                 }
683572
 		break;
683572
 	    case '\005':	/* $^ENCODING */
683572
-- 
683572
2.20.1
683572