summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-08 09:25:24 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-08 09:25:24 +0000
commita95d0518267c37905f7cbab651429147a3dcd85a (patch)
tree3a74b5f92fe08ff8da81a35e5a91861af6b9fb0a
parent0526e9b5c7212706efdc0c0ff18485f1561c7cf7 (diff)
downloadzsh-a95d0518267c37905f7cbab651429147a3dcd85a.tar.gz
zsh-a95d0518267c37905f7cbab651429147a3dcd85a.tar.xz
zsh-a95d0518267c37905f7cbab651429147a3dcd85a.zip
more anchor matching fixes (11817)
-rw-r--r--ChangeLog2
-rw-r--r--Src/Zle/compmatch.c21
2 files changed, 13 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 050655dc5..b8addbf7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2000-06-08  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 11817: Src/Zle/compmatch.c: more anchor matching fixes
+	
 	* 11815: Completion/Core/_expand, Doc/Zsh/compsys.yo: trying to
  	improve _expand; new keep-prefix style, add-space gives more control
 	
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 6e7ded42c..4671b9583 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -535,8 +535,7 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
 		    }
 		    /* Give up if we don't have enough characters for the
 		     * line-string and the anchor. */
-		    if (ll < llen + alen ||
-			(sfx ? (lw < alen + aol) : (lw < alen || iw < aol)))
+		    if (ll < llen + alen || lw < alen)
 			continue;
 
 		    if (mp->flags & CMF_LEFT) {
@@ -561,8 +560,9 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
 			if (!pattern_match(ap, l + aoff, NULL, NULL) ||
 			    (both &&
 			     (!pattern_match(ap, w + aoff, NULL, NULL) ||
-			      (aol && !pattern_match(aop, w + aoff - aol,
-						     NULL, NULL)) ||
+			      (aol && aol <= aoff + iw &&
+			       !pattern_match(aop, w + aoff - aol,
+					      NULL, NULL)) ||
 			      !match_parts(l + aoff, w + aoff, alen, part))))
 				continue;
 		    } else if (!both || il || iw)
@@ -572,19 +572,20 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
 		     * string matched by the `*'. */
 		    if (sfx && (savl = l[-(llen + zoff)]))
 			l[-(llen + zoff)] = '\0';
-		    for (t = 0, tp = w, ct = 0,
-			     ict = lw - alen + 1 - (sfx ? aol : 0);
+		    for (t = 0, tp = w, ct = 0, ict = lw - alen + 1;
 			 ict;
 			 tp += add, ct++, ict--) {
 			if ((both &&
 			     (!ap || !test ||
 			      !pattern_match(ap, tp + aoff, NULL, NULL) ||
-			      (aol && !pattern_match(aop, tp + aoff - aol,
-						     NULL, NULL)))) ||
+			      (aol && aol <= aoff + ct + iw &&
+			       !pattern_match(aop, tp + aoff - aol,
+					      NULL, NULL)))) ||
 			    (!both &&
 			     pattern_match(ap, tp - moff, NULL, NULL) &&
-			     (!aol || pattern_match(aop, tp - moff - aol,
-						    NULL, NULL)) &&
+			     (!aol || (aol <= iw + ct - moff &&
+				       pattern_match(aop, tp - moff - aol,
+						     NULL, NULL))) &&
 			     (mp->wlen == -1 ||
 			      match_parts(l + aoff , tp - moff,
 						      alen, part)))) {