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

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



Peter Stephenson wrote:
> "Zvi Har'El" wrote:
> > I know that zsh-4.1.1 still doesn't support utf-8, but as realeased it coul
> d
> > do completion on utf-8 file names. However, I recently updated from the cvs
> > and now zsh crashes on completions of names, when I have two candidates of 
> th
> > e
> > form RA and RB, and I hit R<TAB>. This happens when R=U+05E8 (0xd7 0xa8) or
> > U+05E9 (0xd7 0xa9) and A and B are U+05D0 and U+05D1.
> 
> I managed to reproduce this with zsh -f on a directory containing only
> the files
> 
> touch $'\xd7\xa8\xd7\x90'
> touch $'\xd7\xa8\xd7\x91'

Phew.  I hope this really is the fix because I don't want to have to
trawl around down there again...

Deep inside the completion code, it works out whether two matches have a
common prefix.  It was treating Meta characters as ordinary characters.
So the unambiguous part of the string to insert got truncated at the
Meta.

This would have shown up any time the only possible matches differed by
a metafied character.  Unless you have a lot of strings with 8-bit
characters, that's probably not very common.

This seems to fix it here.

(By the way, every time I send a message saying I think setting lastval
= 0 in bin_eval is the correct fix for the eval "" bug, it disappears.
So let's see if tacking it on here confuses the system sufficiently.)

Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.37
diff -u -r1.37 compmatch.c
--- Src/Zle/compmatch.c	8 Aug 2001 07:41:01 -0000	1.37
+++ Src/Zle/compmatch.c	5 Jan 2004 16:04:39 -0000
@@ -1584,8 +1584,15 @@
 	if (check_cmdata(md, sfx))
 	    return ret;
 
+	/*
+	 * Look for a common prefix.  Be careful not to include
+	 * a widowed Meta in the 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];
+	     l < len && l < md->len && p[ind] == q[ind]
+		 && (p[ind] != Meta || p[ind+1] == q[ind+1]);
 	     l++, p += add, q += add);
 
 	if (l) {

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



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