Subject: bin/36546: problems with 8-bit input in /bin/ksh
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <cheusov@tut.by>
List: netbsd-bugs
Date: 06/24/2007 13:10:00
>Number:         36546
>Category:       bin
>Synopsis:       problems with 8-bit input in /bin/ksh
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 24 13:10:00 +0000 2007
>Originator:     cheusov@tut.by
>Release:        NetBSD 4.0_BETA2
>Organization:
Best regards, Aleksey Cheusov.
>Environment:
System: NetBSD chen.chizhovka.net 4.0_BETA2 NetBSD 4.0_BETA2 (GENERIC) #20: Wed Jun 20 19:58:12 EEST 2007 cheusov@chen.chizhovka.net:/srv/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
Lots of ksh line editing functions e.g.
upcase-word, capitalize-word, forward-word etc.
work incorrectly with 8-bit input (cyrillic in my case).
This is because setlocale(3) is not called.
>Fix:

Index: bin/ksh/main.c
===================================================================
RCS file: /cvsroot/src/bin/ksh/main.c,v
retrieving revision 1.13
diff -u -r1.13 main.c
--- bin/ksh/main.c	13 May 2006 21:42:45 -0000	1.13
+++ bin/ksh/main.c	24 Jun 2007 12:59:17 -0000
@@ -4,6 +4,7 @@
  * startup, main loop, environments and error handling
  */
 #include <sys/cdefs.h>
+#include <locale.h>
 
 #ifndef lint
 __RCSID("$NetBSD: main.c,v 1.13 2006/05/13 21:42:45 christos Exp $");
@@ -447,6 +448,7 @@
 	} else
 		Flag(FTRACKALL) = 1;	/* set after ENV */
 
+	setlocale(LC_CTYPE, "");
 	shell(s, TRUE);	/* doesn't return */
 	return 0;
 }