Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix 4, was Re: unpatch: metafying zle line
- X-seq: zsh-workers 21603
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: fix 4, was Re: unpatch: metafying zle line
- Date: Fri, 12 Aug 2005 11:21:00 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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@xxxxxxx> 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.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author