From: Andy Lester Date: Sun, 14 May 2006 23:15:18 +0000 (-0500) Subject: refactoring out S_regoptail X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9674d46a132a274aad55231acfd004cbf1e42f04;p=p5sagit%2Fp5-mst-13.2.git refactoring out S_regoptail Message-ID: <20060515041518.GA15745@petdance.com> p4raw-id: //depot/perl@28205 --- diff --git a/embed.fnc b/embed.fnc index bab0ae5..860f3f4 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1290,7 +1290,6 @@ ERsn |I32 |regcurly |NN const char * Es |regnode*|reg_node |NN struct RExC_state_t *state|U8 op Es |regnode*|regpiece |NN struct RExC_state_t *state|NN I32 *flagp Es |void |reginsert |NN struct RExC_state_t *state|U8 op|NN regnode *opnd -Es |void |regoptail |NN const struct RExC_state_t *state|NN regnode *p|NN const regnode *val Es |void |regtail |NN const struct RExC_state_t *state|NN regnode *p|NN const regnode *val EsRn |char* |regwhite |NN char *p|NN const char *e Es |char* |nextchar |NN struct RExC_state_t *state diff --git a/embed.h b/embed.h index 69a920b..2d1e719 100644 --- a/embed.h +++ b/embed.h @@ -1302,7 +1302,6 @@ #define reg_node S_reg_node #define regpiece S_regpiece #define reginsert S_reginsert -#define regoptail S_regoptail #define regtail S_regtail #define regwhite S_regwhite #define nextchar S_nextchar @@ -3464,7 +3463,6 @@ #define reg_node(a,b) S_reg_node(aTHX_ a,b) #define regpiece(a,b) S_regpiece(aTHX_ a,b) #define reginsert(a,b,c) S_reginsert(aTHX_ a,b,c) -#define regoptail(a,b,c) S_regoptail(aTHX_ a,b,c) #define regtail(a,b,c) S_regtail(aTHX_ a,b,c) #define regwhite S_regwhite #define nextchar(a) S_nextchar(aTHX_ a) diff --git a/proto.h b/proto.h index 80063e1..cfca4d8 100644 --- a/proto.h +++ b/proto.h @@ -3538,11 +3538,6 @@ STATIC void S_reginsert(pTHX_ struct RExC_state_t *state, U8 op, regnode *opnd) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_3); -STATIC void S_regoptail(pTHX_ const struct RExC_state_t *state, regnode *p, const regnode *val) - __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2) - __attribute__nonnull__(pTHX_3); - STATIC void S_regtail(pTHX_ const struct RExC_state_t *state, regnode *p, const regnode *val) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) diff --git a/regcomp.c b/regcomp.c index 9dc5395..8ca5cca 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3543,10 +3543,16 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp) } regtail(pRExC_state, lastbr, ender); - if (have_branch) { + if (have_branch && !SIZE_ONLY) { /* Hook the tails of the branches to the closing node. */ - for (br = ret; br != NULL; br = regnext(br)) { - regoptail(pRExC_state, br, ender); + for (br = ret; br; br = regnext(br)) { + const U8 op = PL_regkind[OP(br)]; + if (op == BRANCH) { + regtail(pRExC_state, NEXTOPER(br), ender); + } + else if (op == BRANCHJ) { + regtail(pRExC_state, NEXTOPER(NEXTOPER(br)), ender); + } } } } @@ -5598,27 +5604,6 @@ S_regtail(pTHX_ const RExC_state_t *pRExC_state, regnode *p, const regnode *val) } /* -- regoptail - regtail on operand of first argument; nop if operandless -*/ -/* TODO: All three parms should be const */ -STATIC void -S_regoptail(pTHX_ const RExC_state_t *pRExC_state, regnode *p, const regnode *val) -{ - dVAR; - /* "Operandless" and "op != BRANCH" are synonymous in practice. */ - if (p == NULL || SIZE_ONLY) - return; - if (PL_regkind[(U8)OP(p)] == BRANCH) { - regtail(pRExC_state, NEXTOPER(p), val); - } - else if ( PL_regkind[(U8)OP(p)] == BRANCHJ) { - regtail(pRExC_state, NEXTOPER(NEXTOPER(p)), val); - } - else - return; -} - -/* - regcurly - a little FSA that accepts {\d+,?\d*} */ STATIC I32