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

Re: PATCH: zle input changes for Unicode



Bart Schaefer wrote:
> The obvious question is whether there is any case where getkey() was
> called but lastchar was not updated.  Scanning through the patch I see
> two places where that might have been true -- in deltochar() and in
> getkeybuf() -- and one where it appears really to be true, that is, in
> getzlequery().  But maybe the callers fix up something thereafter, I
> didn't look carefully at the whole context.

The question then was whether the callers of those functions would want
to have something other than the actual last character read available to
them.  I didn't think that was the case.

Previously, lastchar was always set to the return value from the only
call to getkeybuf, which must surely be the same value it's set to now,
right?  (In fact getkeybuf doesn't need to return that byte at all now,
so it might be neater to remove it.)

> Misc. remarks:
> 
> Is last_widechar_valid set to 1 too soon in getrestchar()?

If you mean, should it be set when last_widechar is set to WEOF as well
as when it's a genuine character, the answer is yes; WEOF is a usable
value as far as the rest of the code is concerned.  (It needs to be
tested before inserting, etc., but we don't want to attempt to read more
of a multibyte character, which would be the result of setting the flag
false.)

> Sometimes you assign 1 to last_widechar_valid, and sometimes TRUE.

Gag.  TRUE isn't even defined.  I've borrowed that from the other code I
was writing today.

Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.15
diff -u -r1.15 zle_misc.c
--- Src/Zle/zle_misc.c	18 Feb 2005 13:57:28 -0000	1.15
+++ Src/Zle/zle_misc.c	18 Feb 2005 17:21:59 -0000
@@ -86,7 +86,7 @@
      * with multibyte input.
      */
     lastchar_wide = (ZLE_CHAR_T)lastchar;
-    lastchar_wide_valid = TRUE;
+    lastchar_wide_valid = 1;
 #endif
 }
 
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.48
diff -u -r1.48 zle_tricky.c
--- Src/Zle/zle_tricky.c	18 Feb 2005 13:57:28 -0000	1.48
+++ Src/Zle/zle_tricky.c	18 Feb 2005 17:22:00 -0000
@@ -2308,7 +2308,7 @@
      * since lastchar is a full character, but it's safer anyway...
      */
     lastchar_wide = L' ';
-    lastchar_wide_valid = TRUE;
+    lastchar_wide_valid = 1;
 #endif
 }
 


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