about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-29 12:42:59 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-29 12:42:59 +0000
commitcd38cd40f7f81bee21c14157fc45540d538965bd (patch)
tree4bbc9d4d36187365d498ee632d9715cc0316a110
parentd22ee9a5ba4fcedc63b63a0ab904b86471fcad56 (diff)
downloadzsh-cd38cd40f7f81bee21c14157fc45540d538965bd.tar.gz
zsh-cd38cd40f7f81bee21c14157fc45540d538965bd.tar.xz
zsh-cd38cd40f7f81bee21c14157fc45540d538965bd.zip
matching bugs with patterns with two anchors (11634)
-rw-r--r--ChangeLog3
-rw-r--r--Src/Zle/compcore.c15
-rw-r--r--Src/Zle/compmatch.c8
-rw-r--r--Src/Zle/compresult.c3
4 files changed, 25 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 17de62c48..d86045f0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2000-05-29  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 11634: Src/Zle/compcore.c, Src/Zle/compmatch.c, Src/Zle/compresult.c:
+ 	matching bugs with patterns with two anchors
+	
 	* 11631: Completion/Base/_arguments: keep information about things
  	to complete in _arguments
 	
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 38cbe03a2..4fdfaa159 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -49,6 +49,11 @@ mod_export int dolastprompt;
 /**/
 mod_export int oldlist, oldins;
 
+/* Original prefix/suffix lengths. Flag saying if they changed. */
+
+/**/
+int origlpre, origlsuf, lenchanged;
+
 /* This is used to decide when the cursor should be moved to the end of    *
  * the inserted word: 0 - never, 1 - only when a single match is inserted, *
  * 2 - when a full match is inserted (single or menu), 3 - always.         */
@@ -691,6 +696,11 @@ callcompfunc(char *s, char *fn)
 	compqiprefix = ztrdup(qipre ? qipre : "");
 	zsfree(compqisuffix);
 	compqisuffix = ztrdup(qisuf ? qisuf : "");
+	origlpre = (strlen(compqiprefix) + strlen(compiprefix) +
+		    strlen(compprefix));
+	origlsuf = (strlen(compqisuffix) + strlen(compisuffix) +
+		    strlen(compsuffix));
+	lenchanged = 0;
 	compcurrent = (usea ? (clwpos + 1 - aadd) : 0);
 
 	zsfree(complist);
@@ -1700,6 +1710,11 @@ addmatches(Cadata dat, char **argv)
 	    lsuf = dupstring(compsuffix);
 	    llpl = strlen(lpre);
 	    llsl = strlen(lsuf);
+
+	    if (llpl + strlen(compqiprefix) + strlen(lipre) != origlpre ||
+		llsl + strlen(compqisuffix) + strlen(lisuf) != origlsuf)
+		lenchanged = 1;
+
 	    /* Test if there is an existing -P prefix. */
 	    if (dat->pre && *dat->pre) {
 		pl = pfxlen(dat->pre, lpre);
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 33b5b8a40..60a2fe7b9 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -473,7 +473,7 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp,
 	bp = bp->next;
     }
     /*** This once was: `while (ll && lw)', but then ignored characters at
-     *   the end or not, well, ignored. */
+     *   the end were not, well, ignored. */
     while (ll) {
 
 	/* Hm, we unconditionally first tried the matchers for the cases
@@ -1859,8 +1859,10 @@ join_clines(Cline o, Cline n)
 	    if (!(o->flags & CLF_NEW) && (n->flags & CLF_NEW)) {
 		Cline t, tn;
 
-		for (t = n; (tn = t->next) && (tn->flags & CLF_NEW); t = tn);
-		if (tn && cmp_anchors(o, tn, 0)) {
+		for (t = n; (tn = t->next) &&
+			 ((tn->flags & CLF_NEW) || !cmp_anchors(o, tn, 0));
+		     t = tn);
+		if (tn) {
 		    diff = sub_join(o, n, tn, 0);
 
 #if 0
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 531017afb..c55b65b0a 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -656,7 +656,8 @@ do_ambiguous(void)
 	/* Sometimes the different match specs used may result in a cline
 	 * that gives an empty string. If that happened, we re-insert the
          * old string. Unless there were matches added with -U, that is. */
-	if (!(lastend - wb) && !hasunmatched) {
+
+	if (lastend < we && !lenchanged && !hasunmatched) {
 	    cs = wb;
 	    foredel(lastend - wb);
 	    inststrlen(old, 0, we - wb);