* main.c: prevent segmentation faults on inferiour operating systems
such as Debian GNU/Linux "etch" 4.0 with not installed locale file corresponding to the current environmental settings. ばかたち!
This commit is contained in:
10
main.c
10
main.c
@@ -13,7 +13,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.63 2007/01/03 22:43:47 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.64 2007/01/06 17:08:14 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@@ -280,16 +280,18 @@ main(int argc, char *argv[])
|
||||
/* Do this after j_init(), as tty_fd is not initialized 'til then */
|
||||
if (Flag(FTALKING)) {
|
||||
#if HAVE_SETLOCALE_CTYPE
|
||||
#define isuc(x) (((x) != NULL) && \
|
||||
(strcasestr((x), "UTF-8") || strcasestr((x), "utf8")))
|
||||
/* Check if we're in a UTF-8 locale */
|
||||
if (!Flag(FUTFHACK)) {
|
||||
cc = setlocale(LC_CTYPE, "");
|
||||
#if HAVE_LANGINFO_CODESET
|
||||
if (!strcasestr(cc, "UTF-8") && !strcasestr(cc, "utf8"))
|
||||
if (!isuc(cc))
|
||||
cc = nl_langinfo(CODESET);
|
||||
#endif
|
||||
Flag(FUTFHACK) = strcasestr(cc, "UTF-8") ||
|
||||
strcasestr(cc, "utf8");
|
||||
Flag(FUTFHACK) = isuc(cc);
|
||||
}
|
||||
#undef isuc
|
||||
#endif
|
||||
x_init();
|
||||
}
|
||||
|
Reference in New Issue
Block a user