summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-21 22:56:53 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-21 22:56:53 +0000
commitb1ce53c583204a3da6a480edb6579b98fe3fc077 (patch)
tree3bb123055a125294ea6986263ca9efd708a59826 /regexec.c
parent16ac3975a67d58c2f3ad7448ff2401f16ee7b1b1 (diff)
downloadperl-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.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/regexec.c b/regexec.c
index e85f45f4ed..eef5f598dd 100644
--- a/regexec.c
+++ b/regexec.c
@@ -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;