This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Attempt at making IO::Handle backwards compatible again
[perl5.git] / doop.c
diff --git a/doop.c b/doop.c
index ec8fab2..c23093c 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -311,7 +311,6 @@ S_do_trans_simple_utf8(pTHX_ SV *sv)
     const UV none = svp ? SvUV(*svp) : 0x7fffffff;
     const UV extra = none + 1;
     UV final = 0;
-    UV uv;
     I32 isutf8;
     U8 hibit = 0;
 
@@ -347,7 +346,8 @@ S_do_trans_simple_utf8(pTHX_ SV *sv)
     }
 
     while (s < send) {
-       if ((uv = swash_fetch(rv, s, TRUE)) < none) {
+       const UV uv = swash_fetch(rv, s, TRUE);
+       if (uv < none) {
            s += UTF8SKIP(s);
            matches++;
            d = uvuni_to_utf8(d, uv);
@@ -973,7 +973,7 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
     if (DO_UTF8(sv)) {
        if (s && len) {
            char * const send = s + len;
-           char *start = s;
+           char * const start = s;
            s = send - 1;
            while (s > start && UTF8_IS_CONTINUATION(*s))
                s--;
@@ -1174,7 +1174,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 +1303,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--)