else {
if (force_on_match) {
force_on_match = 0;
+ if (rpm->op_pmflags & PMf_NONDESTRUCT) {
+ /* I feel that it should be possible to avoid this mortal copy
+ given that the code below copies into a new destination.
+ However, I suspect it isn't worth the complexity of
+ unravelling the C<goto force_it> for the small number of
+ cases where it would be viable to drop into the copy code. */
+ TARG = sv_2mortal(newSVsv(TARG));
+ }
s = SvPV_force(TARG, len);
goto force_it;
}
}
require './test.pl';
-plan( tests => 176 );
+plan( tests => 188 );
$_ = 'david';
$a = s/david/rules/r;
::is($fc, 1, "tied UTF8 stuff FETCH count");
::is("$s", "\x{101}efgh", "tied UTF8 stuff");
}
+
+# RT #97954
+{
+ my $count;
+
+ sub bam::DESTROY {
+ --$count;
+ }
+
+ my $z_zapp = bless [], 'bam';
+ ++$count;
+
+ is($count, 1, '1 object');
+ is($z_zapp =~ s/.*/R/r, 'R', 'substitution happens');
+ is(ref $z_zapp, 'bam', 'still 1 object');
+ is($count, 1, 'still 1 object');
+ undef $z_zapp;
+ is($count, 0, 'now 0 objects');
+
+ $z_zapp = bless [], 'bam';
+ ++$count;
+
+ is($count, 1, '1 object');
+ like($z_zapp =~ s/./R/rg, qr/\AR{8,}\z/, 'substitution happens');
+ is(ref $z_zapp, 'bam', 'still 1 object');
+ is($count, 1, 'still 1 object');
+ undef $z_zapp;
+ is($count, 0, 'now 0 objects');
+}
+
+is(*bam =~ s/\*//r, 'main::bam', 'Can s///r a tyepglob');
+is(*bam =~ s/\*//rg, 'main::bam', 'Can s///rg a tyepglob');