X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=doop.c;h=09cb6f531024552280947ad376eb01be824e20f1;hb=4df4e287246babaf287cf6336ca862ceeead8e46;hp=87338168904da2dd5de04db24dcd32a041081910;hpb=0bcc34c2b0b0cb62c0df3d5e562b779fb96595ba;p=p5sagit%2Fp5-mst-13.2.git diff --git a/doop.c b/doop.c index 8733816..09cb6f5 100644 --- a/doop.c +++ b/doop.c @@ -967,6 +967,13 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv) if (SvREADONLY(sv)) Perl_croak(aTHX_ PL_no_modify); } + + if (PL_encoding && !SvUTF8(sv)) { + /* like in do_chomp(), utf8-ize the sv as a side-effect + * if we're using encoding. */ + sv_recode_to_utf8(sv, PL_encoding); + } + s = SvPV(sv, len); if (len && !SvPOK(sv)) s = SvPV_force(sv, len); @@ -1174,7 +1181,7 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right) } else if (SvOK(sv) || SvTYPE(sv) > SVt_PVMG) { dc = SvPV_force_nomg_nolen(sv); - if (SvCUR(sv) < (STRLEN)len) { + if (SvLEN(sv) < (STRLEN)(len + 1)) { dc = SvGROW(sv, (STRLEN)(len + 1)); (void)memzero(dc + SvCUR(sv), len - SvCUR(sv) + 1); } @@ -1303,6 +1310,7 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right) case OP_BIT_AND: while (len--) *dc++ = *lc++ & *rc++; + *dc = '\0'; break; case OP_BIT_XOR: while (len--)