WinCE more implemented functions
[p5sagit/p5-mst-13.2.git] / pad.c
diff --git a/pad.c b/pad.c
index e8296a3..9673c0a 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -537,9 +537,32 @@ Perl_pad_findmy(pTHX_ char *name)
 {
     SV *out_sv;
     int out_flags;
+    I32 offset;
+    AV *nameav;
+    SV **name_svp;
 
-    return pad_findlex(name, PL_compcv, PL_cop_seqmax, 1,
+    offset =  pad_findlex(name, PL_compcv, PL_cop_seqmax, 1,
                Null(SV**), &out_sv, &out_flags);
+    if (offset != NOT_IN_PAD) 
+       return offset;
+
+    /* look for an our that's being introduced; this allows
+     *    our $foo = 0 unless defined $foo;
+     * to not give a warning. (Yes, this is a hack) */
+
+    nameav = (AV*)AvARRAY(CvPADLIST(PL_compcv))[0];
+    name_svp = AvARRAY(nameav);
+    for (offset = AvFILLp(nameav); offset > 0; offset--) {
+       SV *namesv = name_svp[offset];
+       if (namesv && namesv != &PL_sv_undef
+           && !SvFAKE(namesv)
+           && (SvFLAGS(namesv) & SVpad_OUR)
+           && strEQ(SvPVX(namesv), name)
+           && (U32)I_32(SvNVX(namesv)) == PAD_MAX /* min */
+       )
+           return offset;
+    }
+    return NOT_IN_PAD;
 }
 
 
@@ -641,7 +664,7 @@ S_pad_findlex(pTHX_ char *name, CV* cv, U32 seq, int warn,
                *out_name_sv = name_svp[offset]; /* return the namesv */
                *out_flags = SvIVX(*out_name_sv);
                DEBUG_Xv(PerlIO_printf(Perl_debug_log,
-                   "Pad findlex cv=0x%"UVxf" matched: offset=%ld flags=0x%x index=%lu\n",
+                   "Pad findlex cv=0x%"UVxf" matched: offset=%ld flags=0x%lx index=%lu\n",
                    PTR2UV(cv), (long)offset, (unsigned long)*out_flags,
                        (unsigned long)SvNVX(*out_name_sv) 
                ));
@@ -697,7 +720,7 @@ S_pad_findlex(pTHX_ char *name, CV* cv, U32 seq, int warn,
                                    CvDEPTH(cv) ? CvDEPTH(cv) : 1])[offset];
                    DEBUG_Xv(PerlIO_printf(Perl_debug_log,
                        "Pad findlex cv=0x%"UVxf" found lex=0x%"UVxf"\n",
-                       PTR2UV(cv), *out_capture));
+                       PTR2UV(cv), PTR2UV(*out_capture)));
 
                    if (SvPADSTALE(*out_capture)) {
                        if (ckWARN(WARN_CLOSURE))