From 6fd883c7372ceb4a5f71fd8fe11528ca5b522dc1 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 9 Feb 2004 05:49:52 +0000 Subject: Optimized the check for a widowed Meta character. --- Src/Zle/compmatch.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Src') 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; -- cgit 1.4.1