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