diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-05-07 19:47:07 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-05-07 19:47:07 +0000 |
commit | e84ff256a2982e8c96a05c380a48c0d1a6cb3af9 (patch) | |
tree | 565cc125982c986c2c93e9eb6abd8d5d5bd39909 /pp_hot.c | |
parent | 7494063982d7975076fa26eea0959791b05a536a (diff) | |
download | perl-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.c | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -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; } |