|
|
a9fc36 |
From 16f2ddb794883529d5a3ad8326974a07aae7e567 Mon Sep 17 00:00:00 2001
|
|
|
a9fc36 |
From: Tony Cook <tony@develop-help.com>
|
|
|
a9fc36 |
Date: Mon, 10 Jun 2019 10:17:20 +1000
|
|
|
a9fc36 |
Subject: [PATCH] (perl #134179) include regexps in the seen objects table on
|
|
|
a9fc36 |
retrieve
|
|
|
a9fc36 |
MIME-Version: 1.0
|
|
|
a9fc36 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a9fc36 |
Content-Transfer-Encoding: 8bit
|
|
|
a9fc36 |
|
|
|
a9fc36 |
Also, bless the regexp object, so freezing/thawing bless qr//, "Foo"
|
|
|
a9fc36 |
returns a "Foo" blesses regexp.
|
|
|
a9fc36 |
|
|
|
a9fc36 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
a9fc36 |
---
|
|
|
a9fc36 |
dist/Storable/Storable.xs | 5 +++--
|
|
|
a9fc36 |
dist/Storable/t/regexp.t | 4 +++-
|
|
|
a9fc36 |
dist/Storable/t/weak.t | 10 +++++++++-
|
|
|
a9fc36 |
3 files changed, 15 insertions(+), 4 deletions(-)
|
|
|
a9fc36 |
|
|
|
a9fc36 |
diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs
|
|
|
a9fc36 |
index ed729c94a6..6a45d8adf2 100644
|
|
|
a9fc36 |
--- a/dist/Storable/Storable.xs
|
|
|
a9fc36 |
+++ b/dist/Storable/Storable.xs
|
|
|
a9fc36 |
@@ -6808,8 +6808,7 @@ static SV *retrieve_regexp(pTHX_ stcxt_t *cxt, const char *cname) {
|
|
|
a9fc36 |
SV *sv;
|
|
|
a9fc36 |
dSP;
|
|
|
a9fc36 |
I32 count;
|
|
|
a9fc36 |
-
|
|
|
a9fc36 |
- PERL_UNUSED_ARG(cname);
|
|
|
a9fc36 |
+ HV *stash;
|
|
|
a9fc36 |
|
|
|
a9fc36 |
ENTER;
|
|
|
a9fc36 |
SAVETMPS;
|
|
|
a9fc36 |
@@ -6857,6 +6856,8 @@ static SV *retrieve_regexp(pTHX_ stcxt_t *cxt, const char *cname) {
|
|
|
a9fc36 |
|
|
|
a9fc36 |
sv = SvRV(re_ref);
|
|
|
a9fc36 |
SvREFCNT_inc(sv);
|
|
|
a9fc36 |
+ stash = cname ? gv_stashpv(cname, GV_ADD) : 0;
|
|
|
a9fc36 |
+ SEEN_NN(sv, stash, 0);
|
|
|
a9fc36 |
|
|
|
a9fc36 |
FREETMPS;
|
|
|
a9fc36 |
LEAVE;
|
|
|
a9fc36 |
diff --git a/dist/Storable/t/regexp.t b/dist/Storable/t/regexp.t
|
|
|
a9fc36 |
index acf28cfec6..e7c6c7e94a 100644
|
|
|
a9fc36 |
--- a/dist/Storable/t/regexp.t
|
|
|
a9fc36 |
+++ b/dist/Storable/t/regexp.t
|
|
|
a9fc36 |
@@ -37,7 +37,7 @@ while (<DATA>) {
|
|
|
a9fc36 |
}
|
|
|
a9fc36 |
}
|
|
|
a9fc36 |
|
|
|
a9fc36 |
-plan tests => 9 + 3*scalar(@tests);
|
|
|
a9fc36 |
+plan tests => 10 + 3*scalar(@tests);
|
|
|
a9fc36 |
|
|
|
a9fc36 |
SKIP:
|
|
|
a9fc36 |
{
|
|
|
a9fc36 |
@@ -75,6 +75,8 @@ SKIP:
|
|
|
a9fc36 |
ok(!eval { dclone($re) }, "should fail to clone, even with use re 'eval'");
|
|
|
a9fc36 |
}
|
|
|
a9fc36 |
|
|
|
a9fc36 |
+is(ref(dclone(bless qr//, "Foo")), "Foo", "check reblessed regexps");
|
|
|
a9fc36 |
+
|
|
|
a9fc36 |
for my $test (@tests) {
|
|
|
a9fc36 |
my ($code, $not, $match, $matchc, $name) = @$test;
|
|
|
a9fc36 |
my $qr = eval $code;
|
|
|
a9fc36 |
diff --git a/dist/Storable/t/weak.t b/dist/Storable/t/weak.t
|
|
|
a9fc36 |
index 220c70160f..48752fbec4 100644
|
|
|
a9fc36 |
--- a/dist/Storable/t/weak.t
|
|
|
a9fc36 |
+++ b/dist/Storable/t/weak.t
|
|
|
a9fc36 |
@@ -29,7 +29,7 @@ sub BEGIN {
|
|
|
a9fc36 |
}
|
|
|
a9fc36 |
|
|
|
a9fc36 |
use Test::More 'no_plan';
|
|
|
a9fc36 |
-use Storable qw (store retrieve freeze thaw nstore nfreeze);
|
|
|
a9fc36 |
+use Storable qw (store retrieve freeze thaw nstore nfreeze dclone);
|
|
|
a9fc36 |
require 'testlib.pl';
|
|
|
a9fc36 |
our $file;
|
|
|
a9fc36 |
use strict;
|
|
|
a9fc36 |
@@ -143,3 +143,11 @@ foreach (@tests) {
|
|
|
a9fc36 |
$stored = nfreeze $input;
|
|
|
a9fc36 |
tester($stored, \&freeze_and_thaw, $testsub, 'network string');
|
|
|
a9fc36 |
}
|
|
|
a9fc36 |
+
|
|
|
a9fc36 |
+{
|
|
|
a9fc36 |
+ # [perl #134179] sv_upgrade from type 7 down to type 1
|
|
|
a9fc36 |
+ my $foo = [qr//,[]];
|
|
|
a9fc36 |
+ weaken($foo->[1][0][0] = $foo->[1]);
|
|
|
a9fc36 |
+ my $out = dclone($foo); # croaked here
|
|
|
a9fc36 |
+ is_deeply($out, $foo, "check they match");
|
|
|
a9fc36 |
+}
|
|
|
a9fc36 |
--
|
|
|
a9fc36 |
2.20.1
|
|
|
a9fc36 |
|