about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-04-25 17:40:26 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-04-25 17:40:26 +0000
commit87b0f1c8592087cc008847ad4db3963a8adbf135 (patch)
treed23abe48a98a750b68e024af7f8363ae18f466b9 /Src
parentefe92714c6c2e8f777e0649590b7d5eaea769adc (diff)
downloadzsh-87b0f1c8592087cc008847ad4db3963a8adbf135.tar.gz
zsh-87b0f1c8592087cc008847ad4db3963a8adbf135.tar.xz
zsh-87b0f1c8592087cc008847ad4db3963a8adbf135.zip
22432: bug with backtracking over repeated single parameterhs
Diffstat (limited to 'Src')
-rw-r--r--Src/pattern.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index b547bdc14..872816d9b 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2751,22 +2751,26 @@ patmatch(Upat prog)
 		savglobflags = patglobflags;
 		saverrsfound = errsfound;
 		lastcharstart = charstart + (patinput - start);
-		while (no >= min) {
-		    int charmatch_cache;
-		    if (nextch < 0 ||
-			(patinput < patinend &&
-			 CHARMATCH_EXPR(CHARREF(patinput, patinend),
-					nextch))) {
-			if (patmatch(next))
-			    return 1;
+		if (no >= min) {
+		    for (;;) {
+			int charmatch_cache;
+			if (nextch < 0 ||
+			    (patinput < patinend &&
+			     CHARMATCH_EXPR(CHARREF(patinput, patinend),
+					    nextch))) {
+			    if (patmatch(next))
+				return 1;
+			}
+			if (--no < min)
+			    break;
+			/* find start of previous full character */
+			while (!*--lastcharstart)
+			    DPUTS(lastcharstart < charstart,
+				  "lastcharstart invalid");
+			patinput = start + (lastcharstart-charstart);
+			patglobflags = savglobflags;
+			errsfound = saverrsfound;
 		    }
-		    no--;
-		    /* find start of previous full character */
-		    while (!*--lastcharstart)
-			;
-		    patinput = start + (lastcharstart-charstart);
-		    patglobflags = savglobflags;
-		    errsfound = saverrsfound;
 		}
 	    }
 	    /*