From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2844 invoked from network); 6 Feb 2004 16:57:18 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 6 Feb 2004 16:57:18 -0000 Received: (qmail 8513 invoked by alias); 6 Feb 2004 16:57:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19406 Received: (qmail 8480 invoked from network); 6 Feb 2004 16:57:11 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 6 Feb 2004 16:57:11 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [63.249.88.2] by sunsite.dk (MessageWall 1.0.8) with SMTP; 6 Feb 2004 16:57:11 -0000 Received: by binome.blorf.net (Postfix, from userid 1000) id C841C2CB0; Fri, 6 Feb 2004 08:57:09 -0800 (PST) Date: Fri, 6 Feb 2004 08:57:09 -0800 From: Wayne Davison To: Peter Stephenson Cc: Zsh hackers list Subject: Re: zsh crashes on completeion of utf-8 file-names. Message-ID: <20040206165709.GB6749@blorf.net> References: <7460.1073312227@csr.com> <11091.1073318874@csr.com> <20040105170850.GB4482@blorf.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline In-Reply-To: <20040105170850.GB4482@blorf.net> User-Agent: Mutt/1.5.5.1+cvs20040105i --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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.. --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="meta.patch" --- 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; --ZPt4rx8FFjLCG7dd--