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

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



On Mon, Jan 05, 2004 at 09:08:50AM -0800, Wayne Davison wrote:
> I think it would be more optimal to sanity-check the last value after
> the loop finishes, like this (untested):

Attached is a patch that should actually work (unlike the previous one).
See if you like it.

..wayne..
--- Src/Zle/compmatch.c	20 Jan 2004 10:55:28 -0000	1.39
+++ Src/Zle/compmatch.c	6 Feb 2004 16:46:42 -0000
@@ -1585,16 +1585,18 @@ sub_match(Cmdata md, char *str, int len,
 	    return ret;
 
 	/*
-	 * Look for a common prefix.  Be careful not to include
-	 * a widowed Meta in the prefix.  If we do include metafied
+	 * Look for a common prefix.  If we do include metafied
 	 * characters, at this stage we still need the overall length
 	 * including Meta's as separate characters.
 	 */
 	for (l = 0, p = str, q = md->str;
-	     l < len && l < md->len && p[ind] == q[ind]
-		 && (p[ind] != Meta || p[ind+1] == q[ind+1]);
-	     l++, p += add, q += add);
+	     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--;
 	if (l) {
 	    /* There was a common prefix, use it. */
 	    md->len -= l; len -= l;


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