summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2000-07-14 05:16:20 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2000-07-14 05:20:33 +0000
commit29d1e993db685c67acc489087a44f0e4137e296c (patch)
treea603498d5262da00da56d03c55cc02e4c939dae4 /regexec.c
parent78ae23f54fc4e301b66d2a32897cb42fa2633fe7 (diff)
downloadperl-29d1e993db685c67acc489087a44f0e4137e296c.tar.gz
Replace change #6337 with a better one.
Subject: Re: [PATCH] [ID 20000701.002] Regular Expressions Not Unsetting $1 Vars When Backtracking Message-Id: <200007140316.EAA15857@crypt.compulink.co.uk> p4raw-link: @6337 on //depot/cfgperl: f06a1d4e6ae96bf8af49f0ef1c79f500d8de0143 p4raw-id: //depot/cfgperl@6395
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/regexec.c b/regexec.c
index 6bddf2dc32..7472d09735 100644
--- a/regexec.c
+++ b/regexec.c
@@ -221,6 +221,22 @@ typedef struct re_cc_state
#define regcpblow(cp) LEAVE_SCOPE(cp)
+#define TRYPAREN(paren, n, input) { \
+ if (paren) { \
+ if (n) { \
+ PL_regstartp[paren] = HOPc(input, -1) - PL_bostr; \
+ PL_regendp[paren] = input - PL_bostr; \
+ } \
+ else \
+ PL_regendp[paren] = -1; \
+ } \
+ if (regmatch(next)) \
+ sayYES; \
+ if (paren && n) \
+ PL_regendp[paren] = -1; \
+}
+
+
/*
* pregexec and friends
*/
@@ -3001,8 +3017,6 @@ S_regmatch(pTHX_ regnode *prog)
else
c1 = c2 = -1000;
PL_reginput = locinput;
- if (paren)
- PL_regendp[paren] = -1;
if (minmod) {
CHECKPOINT lastcp;
minmod = 0;
@@ -3037,16 +3051,7 @@ S_regmatch(pTHX_ regnode *prog)
sayNO;
}
/* PL_reginput == locinput now */
- if (paren) {
- if (ln) {
- PL_regstartp[paren] = HOPc(locinput, -1) - PL_bostr;
- PL_regendp[paren] = locinput - PL_bostr;
- }
- else
- PL_regendp[paren] = -1;
- }
- if (regmatch(next))
- sayYES;
+ TRYPAREN(paren, ln, locinput);
PL_reginput = locinput; /* Could be reset... */
REGCP_UNWIND;
/* Couldn't or didn't -- move forward. */
@@ -3060,16 +3065,7 @@ S_regmatch(pTHX_ regnode *prog)
UCHARAT(PL_reginput) == c1 ||
UCHARAT(PL_reginput) == c2)
{
- if (paren) {
- if (n) {
- PL_regstartp[paren] = HOPc(PL_reginput, -1) - PL_bostr;
- PL_regendp[paren] = PL_reginput - PL_bostr;
- }
- else
- PL_regendp[paren] = -1;
- }
- if (regmatch(next))
- sayYES;
+ TRYPAREN(paren, n, PL_reginput);
REGCP_UNWIND;
}
/* Couldn't or didn't -- move forward. */
@@ -3103,16 +3099,7 @@ S_regmatch(pTHX_ regnode *prog)
UCHARAT(PL_reginput) == c1 ||
UCHARAT(PL_reginput) == c2)
{
- if (paren && n) {
- if (n) {
- PL_regstartp[paren] = HOPc(PL_reginput, -1) - PL_bostr;
- PL_regendp[paren] = PL_reginput - PL_bostr;
- }
- else
- PL_regendp[paren] = -1;
- }
- if (regmatch(next))
- sayYES;
+ TRYPAREN(paren, n, PL_reginput);
REGCP_UNWIND;
}
/* Couldn't or didn't -- back up. */
@@ -3127,8 +3114,7 @@ S_regmatch(pTHX_ regnode *prog)
UCHARAT(PL_reginput) == c1 ||
UCHARAT(PL_reginput) == c2)
{
- if (regmatch(next))
- sayYES;
+ TRYPAREN(paren, n, PL_reginput);
REGCP_UNWIND;
}
/* Couldn't or didn't -- back up. */