summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-05-07 19:47:07 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-05-07 19:47:07 +0000
commite84ff256a2982e8c96a05c380a48c0d1a6cb3af9 (patch)
tree565cc125982c986c2c93e9eb6abd8d5d5bd39909 /pp_hot.c
parent7494063982d7975076fa26eea0959791b05a536a (diff)
downloadperl-e84ff256a2982e8c96a05c380a48c0d1a6cb3af9.tar.gz
concat doesn't preserve utf8-ness, and doesn't invalidate
[NI]OK; added tests for both p4raw-id: //depot/perl@6090
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 5db5eab6f7..2a8aa9b0c5 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -146,22 +146,36 @@ PP(pp_concat)
dPOPTOPssrl;
STRLEN len;
char *s;
+ bool left_utf = DO_UTF8(left);
+ bool right_utf = DO_UTF8(right);
if (TARG != left) {
+ if (right_utf && !left_utf)
+ sv_utf8_upgrade(left);
s = SvPV(left,len);
+ SvUTF8_off(TARG);
if (TARG == right) {
+ if (left_utf && !right_utf)
+ sv_utf8_upgrade(right);
sv_insert(TARG, 0, 0, s, len);
+ if (left_utf || right_utf)
+ SvUTF8_on(TARG);
SETs(TARG);
RETURN;
}
sv_setpvn(TARG,s,len);
}
- else if (SvGMAGICAL(TARG))
+ else if (SvGMAGICAL(TARG)) {
mg_get(TARG);
+ if (right_utf && !left_utf)
+ sv_utf8_upgrade(left);
+ }
else if (!SvOK(TARG) && SvTYPE(TARG) <= SVt_PVMG) {
sv_setpv(TARG, ""); /* Suppress warning. */
s = SvPV_force(TARG, len);
}
+ if (left_utf && !right_utf)
+ sv_utf8_upgrade(right);
s = SvPV(right,len);
if (SvOK(TARG)) {
#if defined(PERL_Y2KWARN)
@@ -176,19 +190,12 @@ PP(pp_concat)
}
}
#endif
- if (DO_UTF8(right))
- sv_utf8_upgrade(TARG);
sv_catpvn(TARG,s,len);
- if (!IN_BYTE) {
- if (SvUTF8(right))
- SvUTF8_on(TARG);
- }
- else if (!SvUTF8(right)) {
- SvUTF8_off(TARG);
- }
}
else
sv_setpvn(TARG,s,len); /* suppress warning */
+ if (left_utf || right_utf)
+ SvUTF8_on(TARG);
SETTARG;
RETURN;
}