Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Bug w/matching control



Felix Rosencrantz wrote:

> I'm seeing a problem with matching control and characters being deleted. I'm
> using the data from workers/13320
> 
> I've attached a patch to 54compmatch.  I think the output should be the same as
> the previous testcase.  Though this time with input of "g-2", we get a
> "glibc-", with the 2 deleted.  This isn't checked in, since it won't pass.

Yes, it should.  There was a place where it still didn't search hard
enough for compatible anchors to merge.

The patch also contains some fixage in cursor positioning and a
corresponding patch in 54compmatch (sorry if that interferes with your 
patch, Felix).

Bye
 Sven

Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.31
diff -u -r1.31 compmatch.c
--- Src/Zle/compmatch.c	2001/01/25 15:16:28	1.31
+++ Src/Zle/compmatch.c	2001/03/05 10:43:30
@@ -2001,8 +2001,7 @@
 		    else
 			oo = to;
 		    o = to;
-		}
-		if (tn) {
+
 		    diff = sub_join(o, n, tn, 0);
 
 		    o->flags |= CLF_MISS;
@@ -2064,6 +2063,29 @@
 			    }
 			    continue;
 			} else {
+			    for (tn = n; tn; tn = tn->next)
+				if ((tn->flags & CLF_NEW) ==
+				    (o->flags & CLF_NEW) &&
+				    cmp_anchors(tn, o, 1)) break;
+
+			    if (tn) {
+				if ((diff = sub_join(o, n, tn, 0))) {
+				    if (po) {
+					po->flags |= CLF_MISS;
+					po->max += diff;
+				    }
+				    else {
+					o->flags |= CLF_MISS;
+					o->max += diff;
+				    }
+				}
+				n = tn;
+				po = o;
+				o = o->next;
+				pn = n;
+				n = n->next;
+				continue;
+			    }
 			    if (o->flags & CLF_SUF)
 				break;
 
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.34
diff -u -r1.34 compresult.c
--- Src/Zle/compresult.c	2001/01/22 12:03:56	1.34
+++ Src/Zle/compresult.c	2001/03/05 10:43:31
@@ -253,7 +253,7 @@
 		opos = npos;
 		addlinknode(posl, (void *) ((long) npos));
 	    }
-	    if (((pmax < (l->max - l->min) || (pma && l->max != l->min)) &&
+	    if (((pmax <= (l->max - l->min) || (pma && l->max != l->min)) &&
 		 (!pmm || (l->flags & CLF_MATCHED))) ||
 		((l->flags & CLF_MATCHED) && !pmm)) {
 		pm = cs; pmax = l->max - l->min; pmm = l->flags & CLF_MATCHED;
@@ -307,7 +307,7 @@
 		    opos = npos;
 		    addlinknode(posl, (void *) ((long) npos));
 		}
-		if (((smax < (l->min - l->max) || (sma && l->max != l->min)) &&
+		if (((smax <= (l->min - l->max) || (sma && l->max != l->min)) &&
 		     (!smm || (l->flags & CLF_MATCHED))) ||
 		    ((l->flags & CLF_MATCHED) && !smm)) {
 		    sm = cs; smax = l->min - l->max; smm = l->flags & CLF_MATCHED;
Index: Test/54compmatch.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/54compmatch.ztst,v
retrieving revision 1.8
diff -u -r1.8 54compmatch.ztst
--- Test/54compmatch.ztst	2001/01/28 19:37:30	1.8
+++ Test/54compmatch.ztst	2001/03/05 10:43:31
@@ -570,7 +570,7 @@
  test_code $workers_11388_matcher workers_11388_list
  comptest $'tst :\t'
 0:Non-bug from workers 11388
->line: {tst }{.:}
+>line: {tst .:}{}
 >COMPADD:{}
 >INSERT_POSITIONS:{4:5:6}
 

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author