summary refs log tree commit diff
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
parentefe92714c6c2e8f777e0649590b7d5eaea769adc (diff)
downloadzsh-87b0f1c8592087cc008847ad4db3963a8adbf135.tar.gz
zsh-87b0f1c8592087cc008847ad4db3963a8adbf135.tar.xz
zsh-87b0f1c8592087cc008847ad4db3963a8adbf135.zip
22432: bug with backtracking over repeated single parameterhs
-rw-r--r--ChangeLog3
-rw-r--r--Src/pattern.c34
2 files changed, 22 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index ef1dc7b02..165a84199 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-04-25  Peter Stephenson  <pws@csr.com>
 
+	* 22432: Src/pattern.c: bug with backtracking over repeated
+	single parameters.
+
 	* 22431: Src/Zle/zle_main.c, Src/Zle/zle_thingy.c,
 	Src/Zle/zle_vi.c: expand 22427 to set WIDGET etc. more
 	consistently when executing functions.
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;
 		}
 	    }
 	    /*