File tcsh-6.17.06-dspmbyte.dif of Package tcsh

---
 sh.c       |    4 ++--
 sh.func.c  |   15 +++++++--------
 sh.set.c   |   14 ++++++++++----
 tc.const.c |    4 +++-
 4 files changed, 22 insertions(+), 15 deletions(-)

--- sh.c
+++ sh.c	2016-11-25 08:02:39.616478025 +0000
@@ -864,9 +864,9 @@ main(int argc, char **argv)
     /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
 #if defined(DSPMBYTE)
 #if defined(NLS) && defined(LC_CTYPE)
-    if (((tcp = setlocale(LC_CTYPE, NULL)) != NULL || (tcp = getenv("LANG")) != NULL) && !adrof(CHECK_MBYTEVAR))
+    if (((tcp = setlocale(LC_CTYPE, NULL)) != NULL || (tcp = getenv("LANG")) != NULL))
 #else
-    if ((tcp = getenv("LANG")) != NULL && !adrof(CHECK_MBYTEVAR))
+    if ((tcp = getenv("LANG")) != NULL)
 #endif
     {
 	autoset_dspmbyte(str2short(tcp));
--- sh.func.c
+++ sh.func.c	2016-11-25 08:02:39.616478025 +0000
@@ -1424,14 +1424,6 @@ dosetenv(Char **v, struct command *c)
     }
 #endif /* apollo */
 
-    /* dspkanji/dspmbyte autosetting */
-    /* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
-#if defined(DSPMBYTE)
-    if(eq(vp, STRLANG) && !adrof(CHECK_MBYTEVAR)) {
-	autoset_dspmbyte(lp);
-    }
-#endif
-
     if (islocale_var(vp)) {
 #ifdef NLS
 	int     k;
@@ -1456,6 +1448,13 @@ dosetenv(Char **v, struct command *c)
 	nlsclose();
 	nlsinit();
 # endif /* NLS_CATALOGS */
+# if defined(DSPMBYTE)
+	/* dspkanji/dspmbyte autosetting */
+	/* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
+	if (eq(vp, STRLANG)) {
+	    autoset_dspmbyte(lp);
+	}
+# endif
 # ifdef SETLOCALEBUG
 	dont_free = 0;
 # endif /* SETLOCALEBUG */
--- sh.set.c
+++ sh.set.c	2016-11-25 08:02:39.616478025 +0000
@@ -1168,11 +1168,11 @@ update_dspmbyte_vars(void)
 	dstr1 = vp->vec[0];
 	if(eq (dstr1, STRsjis))
 	    iskcode = 1;
-	else if (eq(dstr1, STReuc))
+	else if (eq(dstr1, STReuc) || eq(dstr1, STReucjp) || eq(dstr1, STRGB2312))
 	    iskcode = 2;
 	else if (eq(dstr1, STRbig5))
 	    iskcode = 3;
-	else if (eq(dstr1, STRutf8))
+	else if (eq(dstr1, STRutf8) || eq(dstr1, STRutfx8))
 	    iskcode = 4;
 	else if ((dstr1[0] - '0') >= 0 && (dstr1[0] - '0') <= 3) {
 	    iskcode = 0;
@@ -1256,7 +1256,7 @@ update_dspmbyte_vars(void)
 	_enable_mbdisp = 0;
 	dspmbyte_ls = 0;
     }
-#ifdef MBYTEDEBUG	/* Sorry, use for beta testing */
+# ifdef MBYTEDEBUG	/* Sorry, use for beta testing */
     {
 	Char mbmapstr[300];
 	for (lp = 0; lp < 256; lp++)
@@ -1264,7 +1264,7 @@ update_dspmbyte_vars(void)
 	mbmapstr[lp] = 0;
 	setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
     }
-#endif /* MBYTEMAP */
+# endif /* MBYTEMAP */
 }
 
 /* dspkanji/dspmbyte autosetting */
@@ -1273,6 +1273,7 @@ void
 autoset_dspmbyte(const Char *pcp)
 {
     int i;
+    struct varent *vp;
     static const struct dspm_autoset_Table {
 	Char *n;
 	Char *v;
@@ -1295,13 +1296,18 @@ autoset_dspmbyte(const Char *pcp)
 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
     static const struct dspm_autoset_Table dspmc[] = {
 	{ STRstarutfstar8, STRutf8 },
+	{ STRutfx8, STRutf8 },
 	{ STReuc, STReuc },
+	{ STReucjp, STReuc },
 	{ STRGB2312, STReuc },
 	{ STRLANGBIG5, STRbig5 },
 	{ NULL, NULL }
     };
     Char *codeset;
 
+    if ((vp = adrof(CHECK_MBYTEVAR)))
+	unsetv1(vp);
+
     codeset = str2short(nl_langinfo(CODESET));
     if (*codeset != '\0') {
 	for (i = 0; dspmc[i].n; i++) {
--- tc.const.c
+++ tc.const.c	2016-11-25 08:02:39.616478025 +0000
@@ -133,10 +133,12 @@ Char STRmmliteral[]	= { '-', 'G', '\0' }
 Char STRmmliteral[]	= { '-', '-', 'l', 'i', 't', 'e', 'r', 'a', 'l', '\0' };
 # endif
 Char STReuc[]		= { 'e', 'u', 'c', '\0' };
+Char STReucjp[]		= { 'e', 'u', 'c', '-', 'j', 'p', '\0' };
 Char STRsjis[]		= { 's', 'j', 'i', 's', '\0' };
 Char STRbig5[]		= { 'b', 'i', 'g', '5', '\0' };
 Char STRutf8[]		= { 'u', 't', 'f', '8', '\0' };
 Char STRstarutfstar8[]	= { '*', 'u', 't', 'f', '*', '8', '\0' };
+Char STRutfx8[]		= { 'u', 't', 'f', '-', '8', '\0' };
 Char STRGB2312[]	= { 'g', 'b', '2', '3', '1', '2', '\0' };
 #  ifdef MBYTEDEBUG	/* Sorry, use for beta testing */
 Char STRmbytemap[]	= { 'm', 'b', 'y', 't', 'e', 'm', 'a', 'p', '\0' };
@@ -443,7 +445,7 @@ Char STRkilldup[] 	= { 'k', 'i', 'l', 'l
 Char STRshlvl[]		= { 's', 'h', 'l', 'v', 'l', '\0' };
 Char STRKSHLVL[]	= { 'S', 'H', 'L', 'V', 'L', '\0' };
 Char STRLANG[]		= { 'L', 'A', 'N', 'G', '\0' };
-Char STRLC_ALL[]		= { 'L', 'C', '_', 'A', 'L', 'L', '\0' };
+Char STRLC_ALL[]	= { 'L', 'C', '_', 'A', 'L', 'L', '\0' };
 Char STRLC_CTYPE[]	= { 'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E' ,'\0' };
 Char STRLC_NUMERIC[]	= { 'L', 'C', '_', 'N', 'U', 'M', 'E', 'R', 'I',
 			    'C', '\0' };