From: Vincent Pit Date: Tue, 31 Aug 2010 09:59:10 +0000 (+0200) Subject: Don't mix declarations and code X-Git-Tag: v0.09~14 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=3c3a1e66719e56a416a9cfa4ee8d35c7e86514ca;p=perl%2Fmodules%2Fre-engine-Plugin.git Don't mix declarations and code --- diff --git a/Plugin.xs b/Plugin.xs index 07a5d25..10562b2 100644 --- a/Plugin.xs +++ b/Plugin.xs @@ -251,20 +251,24 @@ Plugin_comp(pTHX_ SV * const pattern, U32 flags) dSP; struct regexp * rx; REGEXP *RX; - I32 buffers; + re__engine__Plugin re; const rep_hint_t *h; + STRLEN plen; + char *pbuf; + + SV *obj; + h = rep_hint(); if (!h) /* This looks like a pragma leak. Apply the default behaviour */ return re_compile(pattern, flags); /* exp/xend version of the pattern & length */ - STRLEN plen; - char* exp = SvPV((SV*)pattern, plen); + pbuf = SvPV((SV*)pattern, plen); /* Our blessed object */ - SV *obj = newSV(0); + obj = newSV(0); SvREFCNT_inc(obj); Newxz(re, 1, struct replug); sv_setref_pv(obj, "re::engine::Plugin", (void*)re); @@ -282,7 +286,7 @@ Plugin_comp(pTHX_ SV * const pattern, U32 flags) /* Precompiled pattern for pp_regcomp to use */ rx->prelen = plen; - rx->precomp = savepvn(exp, rx->prelen); + rx->precomp = savepvn(pbuf, rx->prelen); /* Set up qr// stringification to be equivalent to the supplied * pattern, this should be done via overload eventually. @@ -332,9 +336,7 @@ Plugin_comp(pTHX_ SV * const pattern, U32 flags) * update the regexp struct with the new info. */ - buffers = rx->nparens; - - Newxz(rx->offs, buffers + 1, regexp_paren_pair); + Newxz(rx->offs, rx->nparens + 1, regexp_paren_pair); return RX; } @@ -349,6 +351,8 @@ Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend, GET_SELF_FROM_PPRIVATE(rx->pprivate); if (self->cb_exec) { + SV *ret; + /* Store the current str for ->str */ self->str = (SV*)sv; SvREFCNT_inc(self->str); @@ -365,8 +369,7 @@ Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend, SPAGAIN; - SV * ret = POPs; - + ret = POPs; if (SvTRUE(ret)) matched = 1; else @@ -477,9 +480,10 @@ Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const RX, const I32 paren, items = call_sv(callback, G_SCALAR); if (items == 1) { - SPAGAIN; + SV *ret; - SV * ret = POPs; + SPAGAIN; + ret = POPs; sv_setsv(sv, ret); } else { sv_setsv(sv, &PL_sv_undef); @@ -534,6 +538,8 @@ Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv, callback = self->cb_num_capture_buff_LENGTH; if (callback) { + IV ret; + ENTER; SAVETMPS; @@ -546,7 +552,7 @@ Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv, SPAGAIN; - IV ret = POPi; + ret = POPi; PUTBACK; FREETMPS;