Wouldn't it make sense to set LC_CTYPE to environment's value during ksh
initialization ? Currently this code in bin/ksh/emacs.c doesn't seem to be
functional:

1414     /* Determine if we can translate meta key or use 8-bit AscII
1415      * XXX - It would be nice if there was a locale attribute to
1416      * determine if the locale is 7-bit or not.
1417      */
1418     locale = setlocale(LC_CTYPE, NULL);
1419     if (locale == NULL || !strcmp(locale, "C") || !strcmp(locale,
"POSIX"))
1420         Flag(FEMACSUSEMETA) = 1;
1421 }

ksh doesn't set its locale during startup thus by default it always gets "C"
locale and emacs-usemeta is always on. Another problem arises when using
en_US.UTF-8 with ksh's emacs editing mode, since it uses wctype(3) functions
to recognize control characters some multi-byte characters are treated
incorrectly (most of the extended characters from my language contain bytes
that are recognized as control characters, others might be just lucky).
Small change fixes these things for me:

Index: main.c
===================================================================
RCS file: /cvs/src/bin/ksh/main.c,v
retrieving revision 1.46
diff -u -r1.46 main.c
--- main.c    19 May 2010 17:36:08 -0000    1.46
+++ main.c    15 Jul 2011 14:29:35 -0000
@@ -9,6 +9,7 @@
 #include "sh.h"
 #include <sys/stat.h>
 #include <pwd.h>
+#include <locale.h>

 extern char **environ;

@@ -307,6 +308,11 @@
     i = Flag(FMONITOR) != 127;
     Flag(FMONITOR) = 0;
     j_init(i);
+
+    /* Set default locale */
+    if (!setlocale(LC_CTYPE,""))
+        warningf(false, "Failed to set LC_CTYPE");
+
 #ifdef EDIT
     /* Do this after j_init(), as tty_fd is not initialized 'til then */
     if (Flag(FTALKING))


Regards.

Reply via email to