Subject: bin/27593: ksh emacs editing mode has problems with 8-bit chars
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <arto.huusko@utu.fi>
List: netbsd-bugs
Date: 10/28/2004 08:32:11
>Number:         27593
>Category:       bin
>Synopsis:       ksh emacs editing mode has problems with 8-bit chars
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 28 05:33:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Arto Huusko
>Release:        NetBSD 2.0E
>Organization:
>Environment:
System: NetBSD maailma.yok.utu.fi 2.0E NetBSD 2.0E (MAAILMA) #4: Mon Jun 21 18:37:52 EEST 2004 root@lady:/local/netbsd/current/alpha/obj/sys/arch/alpha/compile/MAAILMA alpha
Architecture: alpha
Machine: alpha
>Description:
	ksh emacs editing mode does not really like 8-bit characters, even
	if they are acceptable by current locale. ksh calls iscntrl()
	to check whether input chars are control characters, and then
	prepends them with a ^ when they are control characters. However,
	with signed chars int promotion makes this go wrong. (Note that,
	oddly, some chars with MSB set do still work)

	Note that this same problem may or may not affect vi editing mode,
	too, but I didn't check.
>How-To-Repeat:
	Set CTYPE to something that allows 8-bit chars; try to type some
	in ksh prompt and see ksh turn them into control chars, e.g. "^".
>Fix:
	Here's the diff I'm using:

Index: emacs.c
===================================================================
RCS file: /cvsroot/netbsd/src/bin/ksh/emacs.c,v
retrieving revision 1.25
diff -r1.25 emacs.c
744c744
< 	if (iscntrl(c))		/* control char */
---
> 	if (iscntrl((unsigned char)c))		/* control char */
767c767
< 	} else if (iscntrl(c))  {
---
> 	} else if (iscntrl((unsigned char)c))  {
1393c1393
< 	if (iscntrl(c))  {
---
> 	if (iscntrl((unsigned char)c))  {
>Release-Note:
>Audit-Trail:
>Unformatted: