SV: END {} blocks run in perl_run
Arthur Bergman [Sun, 12 Aug 2001 00:34:28 +0000 (02:34 +0200)]
Message-ID: <03fd01c122b5$c803c600$052aa8c0@foo>

p4raw-id: //depot/perl@11647

miniperlmain.c
perl.c

index 2c924eb..ee09fbe 100644 (file)
@@ -74,9 +74,12 @@ main(int argc, char **argv, char **env)
     exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
     if (!exitstatus) {
        exitstatus = perl_run(my_perl);
+       perl_destruct(my_perl);
+       exitstatus = STATUS_NATIVE_EXPORT;
+    } else {
+      perl_destruct(my_perl);
     }
 
-    perl_destruct(my_perl);
     perl_free(my_perl);
 
     PERL_SYS_TERM();
diff --git a/perl.c b/perl.c
index 17fbac4..7a59772 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -398,9 +398,16 @@ perl_destruct(pTHXx)
 #endif
 
     LEAVE;
+    {
+      dJMPENV;
+      int x = 0;
+      JMPENV_PUSH(x);
+      if (PL_endav && !PL_minus_c)
+       call_list(PL_scopestack_ix, PL_endav);
+      JMPENV_POP;
+    }
     FREETMPS;
 
-
     /* We must account for everything.  */
 
     /* Destroy the main CV and syntax tree */
@@ -1499,8 +1506,6 @@ perl_run(pTHXx)
            LEAVE;
        FREETMPS;
        PL_curstash = PL_defstash;
-       if (PL_endav && !PL_minus_c)
-           call_list(oldscope, PL_endav);
 #ifdef MYMALLOC
        if (PerlEnv_getenv("PERL_DEBUG_MSTATS"))
            dump_mstats("after execution:  ");