zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: fix 4, was Re: unpatch: metafying zle line
Date: Fri, 12 Aug 2005 11:21:00 +0100	[thread overview]
Message-ID: <200508121021.j7CAL18n012569@news01.csr.com> (raw)

Conversion of the cursor position when metafying and unmetafying the
line was broken in both directions when the cursor was at the end of the
line: this is the bug David Gomez noticed.

After this, completion is basically working with ZLE_UNICODE_SUPPORT
defined when you stick to using single-byte characters.  It's almost
time to allow that to be enabled by default, which will help picking up
the remaining problems with multi-byte characters:  those are likely to
be widespread, but probably in most cases fixable by local changes.

In fact the first test that fails is the third from last, and it's not
catastrophic; a stray space appears at the end of the line in
Y03arguments.ztst test "words array in reset arguments".  There ought to
be a prize for anyone who tracks that down.  But there isn't.

Index: Src/Zle/zle_utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v
retrieving revision 1.26
diff -u -r1.26 zle_utils.c
--- Src/Zle/zle_utils.c	10 Aug 2005 10:56:41 -0000	1.26
+++ Src/Zle/zle_utils.c	12 Aug 2005 10:17:48 -0000
@@ -140,16 +140,19 @@
     s = zalloc(inll * MB_CUR_MAX + 1);
 
     outcs = 0;
-    for(i=0; i < inll; i++, incs--) {
+    for (i=0; i < inll; i++, incs--) {
 	if (incs == 0)
 	    outcs = mb_len;
 	j = wctomb(s + mb_len, instr[i]);
 	if (j == -1) {
 	    /* invalid char; what to do? */
+	    s[mb_len++] = ZWC('?');
 	} else {
 	    mb_len += j;
 	}
     }
+    if (incs == 0)
+	outcs = mb_len;
     s[mb_len] = '\0';
 
     outll = mb_len;
@@ -279,7 +282,7 @@
 	/* Reset shift state to input complete string */
 	memset(&ps, '\0', sizeof(ps));
 
-	while (ll) {
+	while (ll > 0) {
 	    size_t ret = mbrtowc(outptr, inptr, ll, &ps);
 
 	    /*
@@ -311,6 +314,8 @@
 	    outptr++;
 	    ll -= ret;
 	}
+	if (outcs && inptr <= (char *)instr + incs)
+	    *outcs = outptr - outstr;
 	*outll = outptr - outstr;
     } else {
 	*outll = 0;

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, 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.

**********************************************************************


             reply	other threads:[~2005-08-12 10:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-12 10:21 Peter Stephenson [this message]
2005-08-12 19:50 ` David Gómez
2005-08-14 15:55 ` Andrey Borzenkov
2005-08-15 17:22   ` [PATCH] fix zrefresh recursive completion call Andrey Borzenkov
2005-08-15  9:57 ` PATCH: fix 4, was Re: unpatch: metafying zle line Peter Stephenson
2005-08-15 15:06   ` some unicode issues [was Re: PATCH: fix 4, was Re: unpatch: metafying zle line] Clint Adams
2005-08-15 15:13     ` Peter Stephenson
2005-08-15 15:17       ` Peter Stephenson
2005-08-15 17:15       ` Clint Adams
2005-08-15 17:20         ` Peter Stephenson
2005-08-15 17:44           ` Clint Adams
2005-08-16  0:45     ` Clint Adams
2005-08-16  2:02       ` Wayne Davison
2005-08-18  9:56       ` Peter Stephenson

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=200508121021.j7CAL18n012569@news01.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).