opmask_addlocal(pTHX_ SV *opset, char *op_mask_buf) /* Localise PL_op_mask then opmask_add() */
{
char *orig_op_mask = PL_op_mask;
- SAVEPPTR(PL_op_mask);
+ SAVEVPTR(PL_op_mask);
#if !defined(PERL_OBJECT)
/* XXX casting to an ordinary function ptr from a member function ptr
* is disallowed by Borland
warn("opset_len %ld\n", (long)opset_len);
op_names_init(aTHX);
+void
+_safe_pkg_prep(Package)
+ char * Package
+PPCODE:
+ HV *hv;
+ ENTER;
+
+ hv = gv_stashpv(Package, GV_ADDWARN); /* should exist already */
+
+ if (strNE(HvNAME(hv),"main")) {
+ Safefree(HvNAME(hv));
+ HvNAME(hv) = savepv("main"); /* make it think it's in main:: */
+ hv_store(hv,"_",1,(SV *)PL_defgv,0); /* connect _ to global */
+ SvREFCNT_inc((SV *)PL_defgv); /* want to keep _ around! */
+ }
+ LEAVE;
+
+
+
+
void
_safe_call_sv(Package, mask, codesv)
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);
+ PL_curstash = PL_defstash;
+
/* defstash must itself contain a main:: so we'll add that now */
/* take care with the ref counts (was cause of long standing bug) */
/* XXX I'm still not sure if this is right, GV_ADDWARN should warn! */
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);
+ sv_free((SV*)GvHV(PL_incgv)); /* get rid of what save_hash gave us*/
+ 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 */