add new "set -o utf8-hack", currently no effect

set automatically on startup if we have locale functions (on MirOS)
This commit is contained in:
tg 2006-11-05 12:11:14 +00:00
parent 02c14f2a62
commit 1547b04e66
5 changed files with 31 additions and 8 deletions

View File

@ -1,9 +1,9 @@
# $MirOS: src/bin/mksh/Makefile,v 1.12 2006/08/26 20:30:27 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.13 2006/11/05 12:11:13 tg Exp $
PROG= mksh
SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c
CPPFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_ARC4RANDOM_PUSH
CPPFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_ARC4RANDOM_PUSH -DHAVE_LANGSTUFF
CDIAGFLAGS+= -Wno-cast-qual
LINKS+= ${BINDIR}/${PROG} ${BINDIR}/sh

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.67 2006/09/30 02:13:20 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.68 2006/11/05 12:11:13 tg 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: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -3872,5 +3872,5 @@ category: pdksh
stdin:
echo $KSH_VERSION
expected-stdout:
@(#)MIRBSD KSH R28 2006/09/30
@(#)MIRBSD KSH R28 2006/11/05
---

23
main.c
View File

@ -6,7 +6,12 @@
#define EXTERN
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.49 2006/09/30 02:13:21 tg Exp $");
#if (HAVE_LANGSTUFF - 0)
#include <langinfo.h>
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.50 2006/11/05 12:11:14 tg Exp $");
extern char **environ;
@ -60,6 +65,9 @@ main(int argc, char *argv[])
pid_t ppid;
struct tbl *vp;
struct stat s_stdin;
#if (HAVE_LANGSTUFF - 0)
const char *cc;
#endif
/* make sure argv[] is sane */
if (!*argv) {
@ -134,6 +142,19 @@ main(int argc, char *argv[])
setstr(vp, def_path, KSH_RETURN_ERROR);
#if (HAVE_LANGSTUFF - 0)
/* Check if we're in an UTF-8 locale */
cc = setlocale(LC_CTYPE, "");
#ifdef CODESET
if (strcasecmp(cc, "UTF-8") && strcasecmp(cc, "utf8") &&
strcasecmp(cc, "CESU-8") && strcasecmp(cc, "cesu8"))
cc = nl_langinfo(CODESET);
#endif
if (!strcasecmp(cc, "UTF-8") || !strcasecmp(cc, "utf8") ||
!strcasecmp(cc, "CESU-8") || !strcasecmp(cc, "cesu8"))
Flag(FUTFHACK) = 1;
#endif
/* Turn on nohup by default for now - will change to off
* by default once people are aware of its existence
* (at&t ksh does not have a nohup option - it always sends

3
misc.c
View File

@ -3,7 +3,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.16 2006/08/24 20:32:53 tg Exp $\t"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.17 2006/11/05 12:11:14 tg Exp $\t"
MKSH_SH_H_ID);
short chtypes[UCHAR_MAX+1]; /* type bits for unsigned char */
@ -142,6 +142,7 @@ const struct option options[] = {
{ "sh", 0, OF_ANY }, /* non-standard */
{ "stdin", 's', OF_CMDLINE }, /* pseudo non-standard */
{ "trackall", 'h', OF_ANY },
{ "utf8-hack", 0, OF_ANY }, /* non-standard */
{ "verbose", 'v', OF_ANY },
{ "vi", 0, OF_ANY },
{ "viraw", 0, OF_ANY }, /* no effect */

5
sh.h
View File

@ -8,8 +8,8 @@
/* $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 $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.47 2006/10/03 19:46:14 tg Exp $"
#define MKSH_VERSION "R28 2006/09/30"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.48 2006/11/05 12:11:14 tg Exp $"
#define MKSH_VERSION "R28 2006/11/05"
#include <sys/cdefs.h>
#if !defined(__RCSID) || !defined(__SCCSID)
@ -283,6 +283,7 @@ enum sh_flag {
FSH, /* -o sh (dummy, for pdksh compatibility) */
FSTDIN, /* -s: (invocation) parse stdin */
FTRACKALL, /* -h: create tracked aliases for all commands */
FUTFHACK, /* utf-8 hack for command line editing */
FVERBOSE, /* -v: echo input */
FVI, /* vi command editing */
FVIRAW, /* always read in raw mode (ignored) */