summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2003-04-22 15:39:09 (GMT)
committerGustavo Niemeyer <gustavo@niemeyer.net>2003-04-22 15:39:09 (GMT)
commit3c9068bbec1f237feec96aaad64a6c73fa95bf8b (patch)
tree81f56d1796cd220d5b93ff1fcfb34f513e1e6dc3 /Modules/_sre.c
parentc8c8b94c59ee0446d81fb67c0cc5474c1dc2250e (diff)
downloadcpython-3c9068bbec1f237feec96aaad64a6c73fa95bf8b.zip
cpython-3c9068bbec1f237feec96aaad64a6c73fa95bf8b.tar.gz
cpython-3c9068bbec1f237feec96aaad64a6c73fa95bf8b.tar.bz2
Made MAX_UNTIL/MIN_UNTIL code more coherent about mark protection,
accordingly to further discussions with Greg Chapman in patch #712900.
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 3183a6e..be6920d 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1161,6 +1161,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
return i;
state->repeat = rp;
state->ptr = ptr;
+ LASTMARK_RESTORE();
return 0;
case SRE_OP_MIN_UNTIL:
@@ -1171,12 +1172,14 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
if (!rp)
return SRE_ERROR_STATE;
+ state->ptr = ptr;
+
count = rp->count + 1;
TRACE(("|%p|%p|MIN_UNTIL %d %p\n", pattern, ptr, count,
rp->pattern));
- state->ptr = ptr;
+ LASTMARK_SAVE();
if (count < rp->pattern[1]) {
/* not enough matches */
@@ -1187,11 +1190,10 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
return i;
rp->count = count-1;
state->ptr = ptr;
+ LASTMARK_RESTORE();
return 0;
}
- LASTMARK_SAVE();
-
/* see if the tail matches */
state->repeat = rp->prev;
i = SRE_MATCH(state, pattern, level + 1);
@@ -1202,7 +1204,6 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
state->repeat = rp;
LASTMARK_RESTORE();
-
if (count >= rp->pattern[2] && rp->pattern[2] != 65535)
return 0;
@@ -1213,6 +1214,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
return i;
rp->count = count - 1;
state->ptr = ptr;
+ LASTMARK_RESTORE();
return 0;
default: