[Ttssh2-commit] [7405] tttypes.h tttset::CodePage をlocale設定と合わせて自動で設定するようにした

scmno****@osdn***** scmno****@osdn*****
2019年 1月 25日 (金) 21:37:40 JST


Revision: 7405
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7405
Author:   zmatsuo
Date:     2019-01-25 21:37:39 +0900 (Fri, 25 Jan 2019)
Log Message:
-----------
tttypes.h tttset::CodePage をlocale設定と合わせて自動で設定するようにした
- locale文字列から自動で設定するようにした
- CodePageの設定をiniファイルから読まない/書き込まないようにした
- デフォルト値をなくした

Modified Paths:
--------------
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2019-01-24 14:20:34 UTC (rev 7404)
+++ trunk/teraterm/common/tttypes.h	2019-01-25 12:37:39 UTC (rev 7405)
@@ -556,7 +556,6 @@
 	char CygwinDirectory[MAX_PATH];
 #define DEFAULT_LOCALE "japanese"
 	char Locale[80];
-#define DEFAULT_CODEPAGE 932
 	int CodePage;
 	int DuplicateSession;
 	char ViewlogEditor[MAX_PATH];

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2019-01-24 14:20:34 UTC (rev 7404)
+++ trunk/teraterm/teraterm/vtterm.c	2019-01-25 12:37:39 UTC (rev 7405)
@@ -36,6 +36,8 @@
 #include <mbstring.h>
 #include <locale.h>
 #include <ctype.h>
+#include <crtdbg.h>
+#include <tchar.h>
 
 #include "buffer.h"
 #include "ttwinman.h"
@@ -50,9 +52,18 @@
 #include "telnet.h"
 #include "ttime.h"
 #include "clipboar.h"
+#include "../ttpcmn/language.h"
 
 #include "vtterm.h"
 
+#ifdef _DEBUG
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define realloc(p, l) _realloc_dbg((p), (l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK)
+#define strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define _strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
 void ParseFirst(BYTE b);
 
 #define MAPSIZE(x) (sizeof(x)/sizeof((x)[0]))
@@ -342,6 +353,7 @@
 
 void ResetCharSet()
 {
+	char *result;
 	if (ts.Language==IdJapanese) {
 		Gn[0] = IdASCII;
 		Gn[1] = IdKatakana;
@@ -382,7 +394,16 @@
 	cv.KanjiIn = ts.KanjiIn;
 	cv.KanjiOut = ts.KanjiOut;
 
-	setlocale(LC_ALL, ts.Locale);
+	// \x83\x8D\x83P\x81[\x83\x8B\x82̐ݒ\xE8
+	// wctomb \x82̂\xBD\x82\xDF
+	result = setlocale(LC_ALL, ts.Locale);
+    if (result == NULL) {
+		// \x82\xA8\x82\xA9\x82\xB5\x82\xC8Locale\x95\xB6\x8E\x9A\x97񂪃Z\x83b\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9?
+		// default\x82\xF0\x83Z\x83b\x83g\x82\xB5\x82Ă\xA8\x82\xAD
+		strcpy(ts.Locale, DEFAULT_LOCALE);
+		result = setlocale(LC_ALL, ts.Locale);
+	}
+	ts.CodePage = atoi(strrchr(result, '.')+1);
 }
 
 void ResetKeypadMode(BOOL DisabledModeOnly)

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2019-01-24 14:20:34 UTC (rev 7404)
+++ trunk/teraterm/ttpset/ttset.c	2019-01-25 12:37:39 UTC (rev 7405)
@@ -1591,11 +1591,6 @@
 	                        Temp, sizeof(Temp), FName);
 	strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
 
-	// CodePage
-	ts->CodePage =
-		GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
-		                     FName);
-
 	// UI language message file
 	GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
 	                        Temp, sizeof(Temp), FName);
@@ -2302,8 +2297,6 @@
 	WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
 	                          FName);
 	WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
-	_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
-	WritePrivateProfileString(Section, "CodePage", Temp, FName);
 
 	// ANSI color(2004.9.5 yutaka)
 	Temp[0] = '\0';


Ttssh2-commit メーリングリストの案内