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

Re: zsh crashes on completeion of utf-8 file-names.



I was thinking about the case of the reverse scan, and it occurred to me
that if the character that followed the Meta matched a normal character
in the other string, a reverse scan could end up in the middle of a meta
sequence.  This patch fixes this.  Note that this code depends on the
(apparent) fact that a meta char cannot be followed by the same value
(e.g. we must be sure that when we see a meta value, it is the start of
a meta sequence and not the end).

..wayne..
--- compmatch.c	9 Feb 2004 05:49:52 -0000	1.40
+++ compmatch.c	9 Feb 2004 22:03:27 -0000
@@ -1593,10 +1593,15 @@ sub_match(Cmdata md, char *str, int len,
 	     l < len && l < md->len && p[ind] == q[ind];
 	     l++, p += add, q += add) {}
 
-	/* Make sure we don't end with a widowed Meta (which can only
-	 * happen in a forward scan). */
-	if (l && add == 1 && p[-1] == Meta)
-	    l--;
+	/* Make sure we don't end in the middle of a Meta sequence. */
+	if (add = 1) {
+	    if (l && p[-1] == Meta)
+		l--;
+	} else {
+	    if (l && ((l < len && p[-1] == Meta)
+		   || (l < md->len && q[-1] == Meta)))
+		l--;
+	}
 	if (l) {
 	    /* There was a common prefix, use it. */
 	    md->len -= l; len -= l;


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