* PATCH: self-insert with bad multibyte input
@ 2006-01-06 14:06 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2006-01-06 14:06 UTC (permalink / raw)
To: Zsh hackers list
Playing around with the Solaris problems, I noticed that handling
of bad character input is poor. selfinsert() tries to grab the rest of
a wide character. It assumes, quite reasonably, that we already have
something to insert because it only gets called with real input,
although that may be an incomplete character. However, we currently set
the wide character to WEOF in this case, which self-insert inserts; this
isn't a very good solution. This patch checks for the return value when
reading the key and beeps when necessary. It doesn't fix the problems
inputting multibyte characters, but it prevents any consequent problems.
Multibyte editing appears to be OK on the Solaris 8 systems here as long
as the characters don't come from the keyboard: this is basically
consistent with the problem I was seeing before.
Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.33
diff -u -r1.33 zle_hist.c
--- Src/Zle/zle_hist.c 12 Dec 2005 18:35:47 -0000 1.33
+++ Src/Zle/zle_hist.c 6 Jan 2006 14:01:33 -0000
@@ -1107,7 +1107,10 @@
} else if (cmd == Th(z_selfinsert)) {
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
- getrestchar(lastchar);
+ if (getrestchar(lastchar) == WEOF) {
+ handlefeep(zlenoargs);
+ continue;
+ }
#else
;
#endif
@@ -1303,7 +1306,10 @@
} else {
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
- getrestchar(lastchar);
+ if (getrestchar(lastchar) == WEOF) {
+ handlefeep(zlenoargs);
+ continue;
+ }
#else
;
#endif
Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.38
diff -u -r1.38 zle_misc.c
--- Src/Zle/zle_misc.c 30 Nov 2005 16:49:44 -0000 1.38
+++ Src/Zle/zle_misc.c 6 Jan 2006 14:01:36 -0000
@@ -64,7 +64,8 @@
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
- getrestchar(lastchar);
+ if (getrestchar(lastchar) == WEOF)
+ return 1;
#endif
tmp = LASTFULLCHAR;
doinsert(&tmp, 1);
@@ -1018,6 +1019,9 @@
#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
getrestchar(lastchar);
+ if (lastchar_wide == WEOF)
+ feep = 1;
+ else
#endif
if (ZC_icntrl(LASTFULLCHAR))
feep = 1;
--
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
Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser: http://www.csr.com/email_sig.html
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-01-06 14:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-06 14:06 PATCH: self-insert with bad multibyte input 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).