* 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:
parent
8a59ee0311
commit
dbf5cdf632
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.77 2007/01/03 22:43:47 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.78 2007/01/06 17:08:14 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -7,7 +7,7 @@
|
|||||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R29 2007/01/03
|
@(#)MIRBSD KSH R29 2007/01/06
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
category: pdksh
|
category: pdksh
|
||||||
|
10
main.c
10
main.c
@ -13,7 +13,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#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;
|
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 */
|
/* Do this after j_init(), as tty_fd is not initialized 'til then */
|
||||||
if (Flag(FTALKING)) {
|
if (Flag(FTALKING)) {
|
||||||
#if HAVE_SETLOCALE_CTYPE
|
#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 */
|
/* Check if we're in a UTF-8 locale */
|
||||||
if (!Flag(FUTFHACK)) {
|
if (!Flag(FUTFHACK)) {
|
||||||
cc = setlocale(LC_CTYPE, "");
|
cc = setlocale(LC_CTYPE, "");
|
||||||
#if HAVE_LANGINFO_CODESET
|
#if HAVE_LANGINFO_CODESET
|
||||||
if (!strcasestr(cc, "UTF-8") && !strcasestr(cc, "utf8"))
|
if (!isuc(cc))
|
||||||
cc = nl_langinfo(CODESET);
|
cc = nl_langinfo(CODESET);
|
||||||
#endif
|
#endif
|
||||||
Flag(FUTFHACK) = strcasestr(cc, "UTF-8") ||
|
Flag(FUTFHACK) = isuc(cc);
|
||||||
strcasestr(cc, "utf8");
|
|
||||||
}
|
}
|
||||||
|
#undef isuc
|
||||||
#endif
|
#endif
|
||||||
x_init();
|
x_init();
|
||||||
}
|
}
|
||||||
|
4
sh.h
4
sh.h
@ -8,8 +8,8 @@
|
|||||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||||
|
|
||||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.89 2007/01/03 22:43:48 tg Exp $"
|
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.90 2007/01/06 17:08:14 tg Exp $"
|
||||||
#define MKSH_VERSION "R29 2007/01/03"
|
#define MKSH_VERSION "R29 2007/01/06"
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user