Integrate with Sarathy.
[p5sagit/p5-mst-13.2.git] / ext / Opcode / Opcode.xs
index 581cbc9..e191ec7 100644 (file)
@@ -250,7 +250,7 @@ PPCODE:
     save_aptr(&PL_endav);
     PL_endav = (AV*)sv_2mortal((SV*)newAV()); /* ignore END blocks for now     */
 
-    save_hptr(&PL_defstash);           /* save current default stack   */
+    save_hptr(&PL_defstash);           /* save current default stash   */
     /* the assignment to global defstash changes our sense of 'main'   */
     PL_defstash = gv_stashpv(Package, GV_ADDWARN); /* should exist already     */
     save_hptr(&PL_curstash);
@@ -263,6 +263,10 @@ PPCODE:
     sv_free((SV*)GvHV(gv));
     GvHV(gv) = (HV*)SvREFCNT_inc(PL_defstash);
 
+    /* %INC must be clean for use/require in compartment */
+    save_hash(PL_incgv);
+    GvHV(PL_incgv) = (HV*)SvREFCNT_inc(GvHV(gv_HVadd(gv_fetchpv("INC",TRUE,SVt_PVHV))));
+
     PUSHMARK(SP);
     perl_call_sv(codesv, GIMME|G_EVAL|G_KEEPERR); /* use callers context */
     SPAGAIN; /* for the PUTBACK added by xsubpp */