better implementation of change#3326; open(local $foo,...) now
[p5sagit/p5-mst-13.2.git] / pp.c
diff --git a/pp.c b/pp.c
index 443eed0..f999b28 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -241,26 +241,25 @@ PP(pp_rv2gv)
                 * NI-S 1999/05/07
                 */ 
                if (PL_op->op_private & OPpDEREF) {
-                   GV *gv = (GV *) newSV(0);
-                   STRLEN len = 0;
-                   char *name = "";
-                   if (cUNOP->op_first->op_type == OP_PADSV) {
-                       SV **namep = av_fetch(PL_comppad_name, cUNOP->op_first->op_targ, 4);
-                       if (namep && *namep) {
-                           name = SvPV(*namep,len);
-                           if (!name) {
-                               name = "";
-                               len  = 0;
-                           }
-                       }
+                   char *name;
+                   GV *gv;
+                   if (cUNOP->op_targ) {
+                       STRLEN len;
+                       SV *namesv = PL_curpad[cUNOP->op_targ];
+                       name = SvPV(namesv, len);
+                       gv = (GV*)NEWSV(0,len);
+                       gv_init(gv, CopSTASH(PL_curcop), name, len, 0);
+                   }
+                   else {
+                       name = CopSTASHPV(PL_curcop);
+                       gv = newGVgen(name);
                    }
-                   gv_init(gv, CopSTASH(PL_curcop), name, len, 0);
                    sv_upgrade(sv, SVt_RV);
-                   SvRV(sv) = (SV *) gv;
+                   SvRV(sv) = (SV*)gv;
                    SvROK_on(sv);
                    SvSETMAGIC(sv);
                    goto wasref;
-               }  
+               }
                if (PL_op->op_flags & OPf_REF ||
                    PL_op->op_private & HINT_STRICT_REFS)
                    DIE(aTHX_ PL_no_usym, "a symbol");
@@ -1789,7 +1788,7 @@ S_seed(pTHX)
     u = (U32)SEED_C1 * when;
 #  endif
 #endif
-    u += SEED_C3 * (U32)getpid();
+    u += SEED_C3 * (U32)PerlProc_getpid();
     u += SEED_C4 * (U32)PTR2UV(PL_stack_sp);
 #ifndef PLAN9           /* XXX Plan9 assembler chokes on this; fix needed  */
     u += SEED_C5 * (U32)PTR2UV(&when);
@@ -3136,6 +3135,7 @@ PP(pp_reverse)
            *MARK++ = *SP;
            *SP-- = tmp;
        }
+       /* safe as long as stack cannot get extended in the above */
        SP = oldsp;
     }
     else {
@@ -3236,7 +3236,7 @@ PP(pp_unpack)
 {
     djSP;
     dPOPPOPssrl;
-    SV **oldsp = SP;
+    I32 start_sp_offset = SP - PL_stack_base;
     I32 gimme = GIMME_V;
     SV *sv;
     STRLEN llen;
@@ -3254,13 +3254,13 @@ PP(pp_unpack)
     I16 ashort;
     int aint;
     I32 along;
-#ifdef Quad_t
+#ifdef HAS_QUAD
     Quad_t aquad;
 #endif
     U16 aushort;
     unsigned int auint;
     U32 aulong;
-#ifdef Quad_t
+#ifdef HAS_QUAD
     Uquad_t auquad;
 #endif
     char *aptr;
@@ -3364,7 +3364,7 @@ PP(pp_unpack)
            s += len;
            break;
        case '/':
-           if (oldsp >= SP)
+           if (start_sp_offset >= SP - PL_stack_base)
                DIE(aTHX_ "/ must follow a numeric type");
            datumtype = *pat++;
            if (*pat == '*')
@@ -4018,7 +4018,7 @@ PP(pp_unpack)
                sv_setpvn(sv, aptr, len);
            PUSHs(sv_2mortal(sv));
            break;
-#ifdef Quad_t
+#ifdef HAS_QUAD
        case 'q':
            along = (strend - s) / sizeof(Quad_t);
            if (len > along)
@@ -4204,7 +4204,7 @@ PP(pp_unpack)
            checksum = 0;
        }
     }
-    if (SP == oldsp && gimme == G_SCALAR)
+    if (SP - PL_stack_base == start_sp_offset && gimme == G_SCALAR)
        PUSHs(&PL_sv_undef);
     RETURN;
 }
@@ -4336,7 +4336,7 @@ PP(pp_pack)
     unsigned int auint;
     I32 along;
     U32 aulong;
-#ifdef Quad_t
+#ifdef HAS_QUAD
     Quad_t aquad;
     Uquad_t auquad;
 #endif
@@ -4828,7 +4828,7 @@ PP(pp_pack)
                }
            }
            break;
-#ifdef Quad_t
+#ifdef HAS_QUAD
        case 'Q':
            while (len-- > 0) {
                fromstr = NEXTFROM;
@@ -4843,7 +4843,7 @@ PP(pp_pack)
                sv_catpvn(cat, (char*)&aquad, sizeof(Quad_t));
            }
            break;
-#endif /* Quad_t */
+#endif
        case 'P':
            len = 1;            /* assume SV is correct length */
            /* FALL THROUGH */