summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-26 06:34:10 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-26 06:34:10 +0000
commit67fd3b73cad16982b754aa4289516819775932b7 (patch)
tree50fb5ee8ddd69328e7d5b5a2edb91cc9a9c054d3 /Src/Zle
parent18c11b0758196dc98c4ddbeb48caa4a1b9d4af8b (diff)
downloadzsh-67fd3b73cad16982b754aa4289516819775932b7.tar.gz
zsh-67fd3b73cad16982b754aa4289516819775932b7.tar.xz
zsh-67fd3b73cad16982b754aa4289516819775932b7.zip
fix for matching control; improve merging cline lists (10924)
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compmatch.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 778f67dff..a4aea2963 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1018,7 +1018,7 @@ bld_parts(char *str, int len, int plen, Cline *lp)
 		 * is set if the characters before the anchor were not
 		 * on the line. */
 		*q = n = get_cline(NULL, mp->ralen, str, mp->ralen, NULL, 0,
-				   ((plen < 0) ? CLF_NEW : 0));
+				   ((plen <= 0) ? CLF_NEW : 0));
 
 		/* If there were any characters before the anchor, add
 		 * them as a cline struct. */
@@ -1046,7 +1046,7 @@ bld_parts(char *str, int len, int plen, Cline *lp)
     }
     /* This is the cline struct for the remaining string at the end. */
 
-    *q = n = get_cline(NULL, 0, NULL, 0, NULL, 0, (plen < 0 ? CLF_NEW : 0));
+    *q = n = get_cline(NULL, 0, NULL, 0, NULL, 0, (plen <= 0 ? CLF_NEW : 0));
     if (p != str) {
 	int olen = str - p, llen = (op < 0 ? 0 : op);
 
@@ -1843,9 +1843,25 @@ join_clines(Cline o, Cline n)
 	    }
 	    /* Now see if they have matching anchors. If not, cut the list. */
 	    if (!(o->flags & CLF_MID) && !cmp_anchors(o, n, 1)) {
-		Cline t, tn;
+		Cline t, tn, tt, to = NULL;
 
-		for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn);
+		for (t = n; (tn = t->next); t = tn)
+		    if (!(tn->flags & CLF_NEW)) {
+			for (tt = o; (to = tt->next); tt = to)
+			    if (!(to->flags & CLF_NEW) &&
+				cmp_anchors(tn, to, 1))
+				break;
+			if (to)
+			    break;
+		    }
+		if (tn) {
+		    if (po)
+			po->next = to;
+		    else
+			oo = to;
+		    o = to;
+		} else
+		    for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn);
 
 		if (tn) {
 		    diff = sub_join(o, n, tn, 0);
@@ -1864,8 +1880,6 @@ join_clines(Cline o, Cline n)
 		    n = n->next;
 		    continue;
 		} else {
-		    Cline to;
-
 		    for (t = o; (to = t->next) && !cmp_anchors(n, to, 1);
 			 t = to);
 
@@ -1887,9 +1901,7 @@ join_clines(Cline o, Cline n)
 			}
 			continue;
 		    } else {
-			Cline tt = NULL;
-
-			for (t = n; (tn = t->next); t = tn) {
+			for (tt = NULL, t = n; (tn = t->next); t = tn) {
 			    for (tt = o;
 				 (to = tt->next) &&
 				     !cmp_anchors(tn, to, 1); tt = to);