This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
re_eval and closures: add lots of TODO tests
[perl5.git] / doop.c
diff --git a/doop.c b/doop.c
index c11555f..dd6add2 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -642,7 +642,7 @@ Perl_do_trans(pTHX_ SV *sv)
        return 0;
     if (!(PL_op->op_private & OPpTRANS_IDENTICAL)) {
        if (!SvPOKp(sv))
-           (void)SvPV_force(sv, len);
+           (void)SvPV_force_nomg(sv, len);
        (void)SvPOK_only_UTF8(sv);
     }
 
@@ -720,7 +720,7 @@ Perl_do_join(pTHX_ register SV *sv, SV *delim, register SV **mark, register SV *
 
     if (delimlen) {
        for (; items > 0; items--,mark++) {
-           sv_catsv(sv,delim);
+           sv_catsv_nomg(sv,delim);
            sv_catsv(sv,*mark);
        }
     }
@@ -760,13 +760,19 @@ Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
 
 /* currently converts input to bytes if possible, but doesn't sweat failure */
 UV
-Perl_do_vecget(pTHX_ SV *sv, I32 offset, I32 size)
+Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
 {
     dVAR;
     STRLEN srclen, len, uoffset, bitoffs = 0;
-    const unsigned char *s = (const unsigned char *) SvPV_const(sv, srclen);
+    const unsigned char *s = (const unsigned char *) SvPV_flags_const(sv, srclen,
+                             SV_GMAGIC | ((PL_op->op_flags & OPf_MOD || LVRET)
+                                          ? SV_UNDEF_RETURNS_NULL : 0));
     UV retnum = 0;
 
+    if (!s) {
+      s = (const unsigned char *)"";
+    }
+    
     PERL_ARGS_ASSERT_DO_VECGET;
 
     if (offset < 0)
@@ -908,8 +914,8 @@ void
 Perl_do_vecset(pTHX_ SV *sv)
 {
     dVAR;
-    register I32 offset, bitoffs = 0;
-    register I32 size;
+    register SSize_t offset, bitoffs = 0;
+    register int size;
     register unsigned char *s;
     register UV lval;
     I32 mask;
@@ -921,7 +927,8 @@ Perl_do_vecset(pTHX_ SV *sv)
 
     if (!targ)
        return;
-    s = (unsigned char*)SvPV_force(targ, targlen);
+    s = (unsigned char*)SvPV_force_flags(targ, targlen,
+                                         SV_GMAGIC | SV_UNDEF_RETURNS_NULL);
     if (SvUTF8(targ)) {
        /* This is handled by the SvPOK_only below...
        if (!Perl_sv_utf8_downgrade(aTHX_ targ, TRUE))
@@ -1014,7 +1021,7 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
 
     PERL_ARGS_ASSERT_DO_VOP;
 
-    if (sv != left || (optype != OP_BIT_AND && !SvOK(sv) && !SvGMAGICAL(sv)))
+    if (sv != left || (optype != OP_BIT_AND && !SvOK(sv)))
        sv_setpvs(sv, "");      /* avoid undef warning on |= and ^= */
     if (sv == left) {
        lsave = lc = SvPV_force_nomg(left, leftlen);
@@ -1224,8 +1231,7 @@ Perl_do_kv(pTHX)
 {
     dVAR;
     dSP;
-    HV * const hv = MUTABLE_HV(POPs);
-    HV *keys;
+    HV * const keys = MUTABLE_HV(POPs);
     register HE *entry;
     const I32 gimme = GIMME_V;
     const I32 dokv =     (PL_op->op_type == OP_RV2HV || PL_op->op_type == OP_PADHV);
@@ -1233,17 +1239,6 @@ Perl_do_kv(pTHX)
     const I32 dokeys =   dokv || (PL_op->op_type == OP_KEYS || PL_op->op_type == OP_RKEYS);
     const I32 dovalues = dokv || (PL_op->op_type == OP_VALUES || PL_op->op_type == OP_RVALUES);
 
-    if (!hv) {
-       if (PL_op->op_flags & OPf_MOD || LVRET) {       /* lvalue */
-           dTARGET;            /* make sure to clear its target here */
-           if (SvTYPE(TARG) == SVt_PVLV)
-               LvTARG(TARG) = NULL;
-           PUSHs(TARG);
-       }
-       RETURN;
-    }
-
-    keys = hv;
     (void)hv_iterinit(keys);   /* always reset iterator regardless */
 
     if (gimme == G_VOID)
@@ -1285,7 +1280,7 @@ Perl_do_kv(pTHX)
        if (dovalues) {
            SV *tmpstr;
            PUTBACK;
-           tmpstr = hv_iterval(hv,entry);
+           tmpstr = hv_iterval(keys,entry);
            DEBUG_H(Perl_sv_setpvf(aTHX_ tmpstr, "%lu%%%d=%lu",
                            (unsigned long)HeHASH(entry),
                            (int)HvMAX(keys)+1,
@@ -1302,8 +1297,8 @@ Perl_do_kv(pTHX)
  * Local variables:
  * c-indentation-style: bsd
  * c-basic-offset: 4
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
  * End:
  *
- * ex: set ts=8 sts=4 sw=4 noet:
+ * ex: set ts=8 sts=4 sw=4 et:
  */