zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: zsh crashes on completeion of utf-8 file-names.
Date: Mon, 05 Jan 2004 16:07:54 +0000	[thread overview]
Message-ID: <11091.1073318874@csr.com> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Mon, 05 Jan 2004 14:17:07 GMT." <7460.1073312227@csr.com>

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@csr.com>                  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
**********************************************************************


  reply	other threads:[~2004-01-05 16:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-21 14:44 Zvi Har'El
2004-01-05 14:17 ` Peter Stephenson
2004-01-05 16:07   ` Peter Stephenson [this message]
2004-01-05 17:08     ` Wayne Davison
2004-02-06 16:57       ` Wayne Davison
2004-02-06 19:03         ` Bart Schaefer
2004-02-09 22:34         ` Wayne Davison
2004-02-09 22:36           ` Wayne Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11091.1073318874@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).