summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-21 21:59:20 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-21 22:15:37 -0700
commit1555b325296e46f7b95bee03fe856cec348b0d57 (patch)
tree2db4ad26522017f09145ae14ef5bf42e1701b656 /pp_hot.c
parentab9bd41aefd0cbe65798553f90440a85d227c64b (diff)
downloadperl-1555b325296e46f7b95bee03fe856cec348b0d57.tar.gz
[perl #118747] Allow in-place s///g when !!PL_sawampersand
In pp_subst, there is an initial pattern match against the target string, followed by logic to determine which of several code paths will handle the rest of the substitution, depending on which shortcuts can be taken. There is one path specifically for doing a global sort (/g) and modi- fying the target in place. This code was skipped if the target was a copy-on-write scalar or if the pre-match copy was enabled. The pre- match copy is always enabled now, so this code is unreachable. There does not appear to be any reason why this path must be skipped in the presence of the pre-match copy. The string gets copied by the initial regexp match and $& and friends point there afterwards. This skip was added in commit 5d5aaa5e7 (a jumbo patch, so good luck figuring it out). This commit removes the skip, and all tests pass. This, of course, only affects those cases where copy-on-write does not kick in; for instance, when the string’s length is one less than its buffer: $ ./perl -Ilib -e 'use Devel::Peek; $x = " "; $x .= " "x22; Dump $x; $x =~ s/ /b/g; Dump $x' SV = PV(0x7ffb0b807098) at 0x7ffb0b82eed8 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x7ffb0b4066b8 " "\0 CUR = 23 LEN = 24 SV = PV(0x7ffb0b807098) at 0x7ffb0b82eed8 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x7ffb0b4066b8 "bbbbbbbbbbbbbbbbbbbbbbb"\0 CUR = 23 LEN = 24
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 571cd63b0a..82b2508b0a 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2159,7 +2159,6 @@ PP(pp_subst)
&& !is_cow
#endif
&& (I32)clen <= RX_MINLENRET(rx)
- && (once || !(r_flags & REXEC_COPY_STR))
&& !(RX_EXTFLAGS(rx) & RXf_NO_INPLACE_SUBST)
&& (!doutf8 || SvUTF8(TARG))
&& !(rpm->op_pmflags & PMf_NONDESTRUCT))