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