summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-19 23:17:17 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-19 23:17:17 +0000
commitf7928d6c98a55cfb1aa37088308b1e8ca18c526b (patch)
tree9729602e8b35f928442501a398cbce5f19bc7183 /pp.c
parent5fe84fd29acaf55c3d2b93f4d6ba263d0ef2be35 (diff)
downloadperl-f7928d6c98a55cfb1aa37088308b1e8ca18c526b.tar.gz
substr($bytestr, i, n, $charstr)
TODO: we are still broken if $bytestr needs UTF-8 upgrading. p4raw-id: //depot/perl@9255
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 37ada8ba0c..4e4c557694 100644
--- a/pp.c
+++ b/pp.c
@@ -2701,6 +2701,7 @@ PP(pp_substr)
char *repl = 0;
STRLEN repl_len;
int num_args = PL_op->op_private & 7;
+ bool utfrepllen = FALSE;
SvTAINTED_off(TARG); /* decontaminate */
SvUTF8_off(TARG); /* decontaminate */
@@ -2708,6 +2709,7 @@ PP(pp_substr)
if (num_args > 3) {
sv = POPs;
repl = SvPV(sv, repl_len);
+ utfrepllen = DO_UTF8(sv) && SvCUR(sv);
}
len = POPi;
}
@@ -2774,8 +2776,11 @@ PP(pp_substr)
sv_setpvn(TARG, tmps, rem);
if (utfcurlen)
SvUTF8_on(TARG);
- if (repl)
+ if (repl) {
sv_insert(sv, pos, rem, repl, repl_len);
+ if (utfrepllen)
+ SvUTF8_on(sv);
+ }
else if (lvalue) { /* it's an lvalue! */
if (!SvGMAGICAL(sv)) {
if (SvROK(sv)) {