zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: fix 4, was Re: unpatch: metafying zle line
@ 2005-08-12 10:21 Peter Stephenson
  2005-08-12 19:50 ` David Gómez
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Peter Stephenson @ 2005-08-12 10:21 UTC (permalink / raw)
  To: Zsh hackers list

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.

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-08-18  9:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-12 10:21 PATCH: fix 4, was Re: unpatch: metafying zle line Peter Stephenson
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

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).