Changes to perlfaq8 "How do I find out if I'm running interactively
[p5sagit/p5-mst-13.2.git] / doop.c
diff --git a/doop.c b/doop.c
index cfc67cb..c4edb60 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -215,7 +215,7 @@ S_do_trans_complex(pTHX_ SV *sv)
 
                if (comp > 0xff) {
                    if (!complement) {
-                       Copy(s, d, len, U8);
+                       Move(s, d, len, U8);
                        d += len;
                    }
                    else {
@@ -243,7 +243,7 @@ S_do_trans_complex(pTHX_ SV *sv)
                    continue;
                }
                else if (ch == -1) {    /* -1 is unmapped character */
-                   Copy(s, d, len, U8);
+                   Move(s, d, len, U8);
                    d += len;
                }
                else if (ch == -2)      /* -2 is delete character */
@@ -278,7 +278,7 @@ S_do_trans_complex(pTHX_ SV *sv)
                    matches++;
                }
                else if (ch == -1) {    /* -1 is unmapped character */
-                   Copy(s, d, len, U8);
+                   Move(s, d, len, U8);
                    d += len;
                }
                else if (ch == -2)      /* -2 is delete character */
@@ -1197,6 +1197,8 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
     rsave = rc = SvPV_nomg_const(right, rightlen);
     len = leftlen < rightlen ? leftlen : rightlen;
     lensave = len;
+    SvCUR_set(sv, len);
+    (void)SvPOK_only(sv);
     if ((left_utf || right_utf) && (sv == left || sv == right)) {
        needlen = optype == OP_BIT_AND ? len : leftlen + rightlen;
        Newxz(dc, needlen + 1, char);
@@ -1214,11 +1216,9 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
        needlen = ((optype == OP_BIT_AND)
                    ? len : (leftlen > rightlen ? leftlen : rightlen));
        Newxz(dc, needlen + 1, char);
-       (void)sv_usepvn(sv, dc, needlen);
+       sv_usepvn_flags(sv, dc, needlen, SV_HAS_TRAILING_NUL);
        dc = SvPVX(sv);         /* sv_usepvn() calls Renew() */
     }
-    SvCUR_set(sv, len);
-    (void)SvPOK_only(sv);
     if (left_utf || right_utf) {
        UV duc, luc, ruc;
        char *dcorig = dc;
@@ -1282,6 +1282,11 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
                *SvEND(sv) = '\0';
            Safefree(dcsave);
            break;
+       default:
+           if (sv == left || sv == right)
+               Safefree(dcorig);
+           Perl_croak(aTHX_ "panic: do_vop called for op %u (%s)", optype,
+                      PL_op_name[optype]);
        }
        SvUTF8_on(sv);
        goto finish;