add missing file from change#1943
[p5sagit/p5-mst-13.2.git] / mg.c
diff --git a/mg.c b/mg.c
index e4ddcd6..42e3a59 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -94,10 +94,13 @@ restore_magic(void *p)
      */
     if (PL_savestack_ix == mgs->mgs_ss_ix)
     {
-        assert(SSPOPINT == SAVEt_DESTRUCTOR);
+       I32 popval = SSPOPINT;
+        assert(popval == SAVEt_DESTRUCTOR);
         PL_savestack_ix -= 2;
-        assert(SSPOPINT == SAVEt_ALLOC);
-        PL_savestack_ix -= SSPOPINT;
+       popval = SSPOPINT;
+        assert(popval == SAVEt_ALLOC);
+       popval = SSPOPINT;
+        PL_savestack_ix -= popval;
     }
 
 }
@@ -461,15 +464,15 @@ magic_get(SV *sv, MAGIC *mg)
        break;
     case '\002':               /* ^B */
        /* printf("magic_get $^B: ") ; */
-       if (curcop->cop_warnings == WARN_NONE)
+       if (PL_curcop->cop_warnings == WARN_NONE)
            /* printf("WARN_NONE\n"), */
            sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
-        else if (curcop->cop_warnings == WARN_ALL)
+        else if (PL_curcop->cop_warnings == WARN_ALL)
            /* printf("WARN_ALL\n"), */
            sv_setpvn(sv, WARN_ALLstring, WARNsize) ;
         else 
-           /* printf("some %s\n", printW(curcop->cop_warnings)), */
-           sv_setsv(sv, curcop->cop_warnings);
+           /* printf("some %s\n", printW(PL_curcop->cop_warnings)), */
+           sv_setsv(sv, PL_curcop->cop_warnings);
        break;
     case '\004':               /* ^D */
        sv_setiv(sv, (IV)(PL_debug & 32767));
@@ -493,8 +496,11 @@ magic_get(SV *sv, MAGIC *mg)
            sv_setnv(sv, (double)errno);
            sv_setpv(sv, errno ? Strerror(errno) : "");
        } else {
-           if (errno != errno_isOS2)
-               Perl_rc = _syserrno();
+           if (errno != errno_isOS2) {
+               int tmp = _syserrno();
+               if (tmp)        /* 2nd call to _syserrno() makes it 0 */
+                   Perl_rc = tmp;
+           }
            sv_setnv(sv, (double)Perl_rc);
            sv_setpv(sv, os2error(Perl_rc));
        }
@@ -1633,15 +1639,15 @@ magic_set(SV *sv, MAGIC *mg)
     case '\002':       /* ^B */
        if ( ! (PL_dowarn & G_WARN_ALL_MASK)) {
             if (memEQ(SvPVX(sv), WARN_ALLstring, WARNsize))
-               compiling.cop_warnings = WARN_ALL;
+               PL_compiling.cop_warnings = WARN_ALL;
            else if (memEQ(SvPVX(sv), WARN_NONEstring, WARNsize))
-               compiling.cop_warnings = WARN_NONE;
+               PL_compiling.cop_warnings = WARN_NONE;
             else {
-               if (compiling.cop_warnings != WARN_NONE && 
-                   compiling.cop_warnings != WARN_ALL)
-                   sv_setsv(compiling.cop_warnings, sv);
+               if (PL_compiling.cop_warnings != WARN_NONE && 
+                   PL_compiling.cop_warnings != WARN_ALL)
+                   sv_setsv(PL_compiling.cop_warnings, sv);
                else
-                   compiling.cop_warnings = newSVsv(sv) ;
+                   PL_compiling.cop_warnings = newSVsv(sv) ;
            }
        }
        break;