]> granicus.if.org Git - python/commitdiff
Made MAX_UNTIL/MIN_UNTIL code more coherent about mark protection,
authorGustavo Niemeyer <gustavo@niemeyer.net>
Tue, 22 Apr 2003 15:39:09 +0000 (15:39 +0000)
committerGustavo Niemeyer <gustavo@niemeyer.net>
Tue, 22 Apr 2003 15:39:09 +0000 (15:39 +0000)
accordingly to further discussions with Greg Chapman in patch #712900.

Modules/_sre.c

index 3183a6eeef1fd992fd28e7f7c747c708081489db..be6920df6875f9a526d128ecbe57124e55845a29 100644 (file)
@@ -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: