summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-02-24 18:44:41 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-02-24 18:44:41 +0000
commitdb79b45b3c913399aef4d2f3647453e63c4772a8 (patch)
tree8f017949a97d258ab9bf69382ed306017ae5d7f4 /pp_ctl.c
parent8fde6460a7cb90e344d87e1652b5fa8d61c68699 (diff)
downloadperl-db79b45b3c913399aef4d2f3647453e63c4772a8.tar.gz
Patching magic from Inaba-san's keyboard: fix for [perl #8769]:
"scalar upgraded to UTF-8 as a side effect of quote-interpolation when 'use encoding' is engaged"-- wasn't actually encoding's fault. p4raw-id: //depot/perl@18764
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 9a807a5ec6..cdcbb30f51 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -156,6 +156,7 @@ PP(pp_substcont)
register char *m = cx->sb_m;
char *orig = cx->sb_orig;
register REGEXP *rx = cx->sb_rx;
+ SV *nsv = Nullsv;
rxres_restore(&cx->sb_rxres, rx);
RX_MATCH_UTF8_set(rx, SvUTF8(cx->sb_targ));
@@ -178,7 +179,10 @@ PP(pp_substcont)
{
SV *targ = cx->sb_targ;
- sv_catpvn(dstr, s, cx->sb_strend - s);
+ if (DO_UTF8(dstr) && !SvUTF8(targ))
+ sv_catpvn_utf8_upgrade(dstr, s, cx->sb_strend - s, nsv);
+ else
+ sv_catpvn(dstr, s, cx->sb_strend - s);
cx->sb_rxtainted |= RX_MATCH_TAINTED(rx);
#ifdef PERL_COPY_ON_WRITE
@@ -221,8 +225,12 @@ PP(pp_substcont)
cx->sb_strend = s + (cx->sb_strend - m);
}
cx->sb_m = m = rx->startp[0] + orig;
- if (m > s)
- sv_catpvn(dstr, s, m-s);
+ if (m > s) {
+ if (DO_UTF8(dstr) && !SvUTF8(cx->sb_targ))
+ sv_catpvn_utf8_upgrade(dstr, s, m - s, nsv);
+ else
+ sv_catpvn(dstr, s, m-s);
+ }
cx->sb_s = rx->endp[0] + orig;
{ /* Update the pos() information. */
SV *sv = cx->sb_targ;