about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2004-02-09 05:49:52 +0000
committerWayne Davison <wayned@users.sourceforge.net>2004-02-09 05:49:52 +0000
commit6fd883c7372ceb4a5f71fd8fe11528ca5b522dc1 (patch)
treef7d380419739d30734312b1c64d1a8231f22081d /Src/Zle
parentd84942a9b46903de5a8738dc701894fa59283524 (diff)
downloadzsh-6fd883c7372ceb4a5f71fd8fe11528ca5b522dc1.tar.gz
zsh-6fd883c7372ceb4a5f71fd8fe11528ca5b522dc1.tar.xz
zsh-6fd883c7372ceb4a5f71fd8fe11528ca5b522dc1.zip
Optimized the check for a widowed Meta character.
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compmatch.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index b99db2e6e..410078a7b 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1585,16 +1585,18 @@ sub_match(Cmdata md, char *str, int len, int sfx)
 	    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;