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