X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Upper.xs;h=231acccc4dbf105c942243cdb2502a5cf28f4ea9;hb=f0bcaf18260322fd0bc7ebe1bcae0cff45681a4d;hp=53dd22f41af57ed9c7aa1c6734eb27532a1c9e21;hpb=71a89669479d74c1615a2e92c93884fa39a5b251;p=perl%2Fmodules%2FScope-Upper.git diff --git a/Upper.xs b/Upper.xs index 53dd22f..231accc 100644 --- a/Upper.xs +++ b/Upper.xs @@ -533,7 +533,8 @@ STATIC void su_unwind(pTHX_ void *ud_) { dounwind(cxix); /* Hide the level */ - PL_stack_sp--; + if (items >= 0) + PL_stack_sp--; mark = PL_markstack[cxstack[cxix].blk_oldmarksp]; @@ -597,20 +598,19 @@ XS(XS_Scope__Upper_unwind) { #else dXSARGS; #endif - I32 cxix; + I32 from = 0, cxix = cxstack_ix; su_ud_unwind *ud; SV *level; - if (!items) - Perl_croak(aTHX_ "Usage: Scope::Upper::unwind(..., level)"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ - level = ST(items - 1); - cxix = SvOK(level) ? SvIV(level) : 0; - if (cxix < 0) - cxix = 0; - else if (cxix > cxstack_ix) - cxix = cxstack_ix; - cxix = cxstack_ix - cxix; + if (items) { + from = SvIV(ST(items - 1)); + if (from < 0) + from = 0; + else if (from > cxix) + from = cxix; + } + cxix -= from; do { PERL_CONTEXT *cx = cxstack + cxix; switch (CxTYPE(cx)) {