diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-21 22:56:53 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-21 22:56:53 +0000 |
commit | b1ce53c583204a3da6a480edb6579b98fe3fc077 (patch) | |
tree | 3bb123055a125294ea6986263ca9efd708a59826 /regexec.c | |
parent | 16ac3975a67d58c2f3ad7448ff2401f16ee7b1b1 (diff) | |
download | perl-b1ce53c583204a3da6a480edb6579b98fe3fc077.tar.gz |
Document the regex content pushing/popping a bit better.
p4raw-id: //depot/perl@8510
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -130,21 +130,25 @@ STATIC CHECKPOINT S_regcppush(pTHX_ I32 parenfloor) { int retval = PL_savestack_ix; - int i = (PL_regsize - parenfloor) * 4; +#define REGCP_PAREN_ELEMS 4 + int paren_elems_to_push = (PL_regsize - parenfloor) * REGCP_PAREN_ELEMS; int p; - SSCHECK(i + 5); +#define REGCP_OTHER_ELEMS 5 + SSCHECK(paren_elems_to_push + REGCP_OTHER_ELEMS); for (p = PL_regsize; p > parenfloor; p--) { +/* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */ SSPUSHINT(PL_regendp[p]); SSPUSHINT(PL_regstartp[p]); SSPUSHPTR(PL_reg_start_tmp[p]); SSPUSHINT(p); } +/* REGCP_OTHER_ELEMS are pushed in any case, parentheses or no. */ SSPUSHINT(PL_regsize); SSPUSHINT(*PL_reglastparen); SSPUSHPTR(PL_reginput); - SSPUSHINT(i + 3); - SSPUSHINT(SAVEt_REGCONTEXT); + SSPUSHINT(paren_elems_to_push + (REGCP_PAREN_ELEMS - 1)); + SSPUSHINT(SAVEt_REGCONTEXT); /* Magic cookie. */ return retval; } @@ -161,16 +165,21 @@ S_regcppush(pTHX_ I32 parenfloor) STATIC char * S_regcppop(pTHX) { - I32 i = SSPOPINT; + I32 i; U32 paren = 0; char *input; I32 tmps; - assert(i == SAVEt_REGCONTEXT); + + /* Pop REGCP_OTHER_ELEMS before the parentheses loop starts. */ i = SSPOPINT; + assert(i == SAVEt_REGCONTEXT); /* Check that the magic cookie is there. */ + i = SSPOPINT; /* Parentheses elements to pop. */ input = (char *) SSPOPPTR; *PL_reglastparen = SSPOPINT; PL_regsize = SSPOPINT; - for (i -= 3; i > 0; i -= 4) { + + /* Now restore the parentheses context. */ + for (i -= (REGCP_PAREN_ELEMS - 1); i > 0; i -= REGCP_PAREN_ELEMS) { paren = (U32)SSPOPINT; PL_reg_start_tmp[paren] = (char *) SSPOPPTR; PL_regstartp[paren] = SSPOPINT; |