--- Guard/Guard.xs 2008/12/14 19:55:59 1.6 +++ Guard/Guard.xs 2009/07/19 04:43:47 1.10 @@ -4,6 +4,14 @@ #include "perl.h" #include "XSUB.h" +#ifndef SvSTASH_set +# define SvSTASH_set(x,a) SvSTASH(x) = (a) +#endif + +#ifndef PERL_MAGIC_ext +# define PERL_MAGIC_ext '~' +#endif + static HV *guard_stash; static SV * @@ -33,14 +41,14 @@ PUSHMARK (SP); PUTBACK; call_sv (cb, G_VOID | G_DISCARD | G_EVAL); - SPAGAIN; if (SvTRUE (ERRSV)) { + SPAGAIN; + PUSHMARK (SP); PUTBACK; call_sv (get_sv ("Guard::DIED", 1), G_VOID | G_DISCARD | G_EVAL | G_KEEPERR); - SPAGAIN; sv_setpvn (ERRSV, "", 0); } @@ -67,6 +75,8 @@ guard_free (pTHX_ SV *cv, MAGIC *mg) { exec_guard_cb (aTHX_ mg->mg_obj); + + return 0; } static MGVTBL guard_vtbl = { @@ -78,6 +88,7 @@ BOOT: guard_stash = gv_stashpv ("Guard", 1); + CvNODEBUG_on (get_cv ("Guard::scope_guard", 0)); /* otherwise calling scope can be the debugger */ void scope_guard (SV *block)