[Ttssh2-commit] [7408] Merge branch 'trunk' r7407 into cmake

アーカイブの一覧に戻る
scmno****@osdn***** scmno****@osdn*****
2019年 1月 26日 (土) 00:45:19 JST


Revision: 7408
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7408
Author:   zmatsuo
Date:     2019-01-26 00:45:19 +0900 (Sat, 26 Jan 2019)
Log Message:
-----------
Merge branch 'trunk' r7407 into cmake

Revision Links:
--------------
    http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7407

Modified Paths:
--------------
    branches/cmake/doc/en/html/setup/teraterm.html
    branches/cmake/doc/ja/html/setup/teraterm.html
    branches/cmake/teraterm/common/codeconv.cpp
    branches/cmake/teraterm/common/tttypes.h
    branches/cmake/teraterm/teraterm/vtterm.c
    branches/cmake/teraterm/ttpcmn/language.c
    branches/cmake/teraterm/ttpcmn/language.h
    branches/cmake/teraterm/ttpcmn/ttcmn.c
    branches/cmake/teraterm/ttpcmn/ttpcmn.vcproj
    branches/cmake/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: branches/cmake/doc/en/html/setup/teraterm.html
===================================================================
--- branches/cmake/doc/en/html/setup/teraterm.html	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/doc/en/html/setup/teraterm.html	2019-01-25 15:45:19 UTC (rev 7408)
@@ -26,7 +26,7 @@
   <th>Placement</th>
  </tr>
  <tr>
-  <td>Vista/7/8</td>
+  <td>Vista/7/8/10</td>
   <td>%UserProfile%\Documents</td>
  </tr>
  <tr>

Modified: branches/cmake/doc/ja/html/setup/teraterm.html
===================================================================
--- branches/cmake/doc/ja/html/setup/teraterm.html	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/doc/ja/html/setup/teraterm.html	2019-01-25 15:45:19 UTC (rev 7408)
@@ -26,7 +26,7 @@
   <th>\x8Fꏊ</th>
  </tr>
  <tr>
-  <td>Vista/7/8</td>
+  <td>Vista/7/8/10</td>
   <td>%UserProfile%\Documents</td>
  </tr>
  <tr>

Modified: branches/cmake/teraterm/common/codeconv.cpp
===================================================================
--- branches/cmake/teraterm/common/codeconv.cpp	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/common/codeconv.cpp	2019-01-25 15:45:19 UTC (rev 7408)
@@ -89,7 +89,7 @@
  *	\x83}\x83\x8B\x83`\x83o\x83C\x83g\x95\xB6\x8E\x9A\x97\xF1\x82\xF0wchar_t\x95\xB6\x8E\x9A\x97\xF1\x82֕ϊ\xB7
  *	@param[in]	*str_ptr	mb(char)\x95\xB6\x8E\x9A\x97\xF1
  *	@param[in]	str_len		mb(char)\x95\xB6\x8E\x9A\x97\xF1\x92\xB7(0\x82̂Ƃ\xAB\x8E\xA9\x93\xAE)
- *	@param[in]	code_page	\x95ϊ\xB7\x90\xE6\x83R\x81[\x83h\x83y\x81[\x83W
+ *	@param[in]	code_page	\x95ϊ\xB7\x8C\xB3\x83R\x81[\x83h\x83y\x81[\x83W
  *	@param[out]	*w_len_		wchar_t\x95\xB6\x8E\x9A\x97\xF1\x92\xB7
  *	@retval		mb\x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^(NULL\x82̎\x9E\x95ϊ\xB7\x83G\x83\x89\x81[)
  */

Modified: branches/cmake/teraterm/common/tttypes.h
===================================================================
--- branches/cmake/teraterm/common/tttypes.h	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/common/tttypes.h	2019-01-25 15:45:19 UTC (rev 7408)
@@ -552,10 +552,10 @@
 	char MouseCursorName[16];
 	BYTE AlphaBlendActive;
 	BYTE AlphaBlendInactive;
+	BYTE reserve_0[2];				// \x96\xA2\x8Eg\x97p
 	char CygwinDirectory[MAX_PATH];
 #define DEFAULT_LOCALE "japanese"
 	char Locale[80];
-#define DEFAULT_CODEPAGE 932
 	int CodePage;
 	int DuplicateSession;
 	char ViewlogEditor[MAX_PATH];

Modified: branches/cmake/teraterm/teraterm/vtterm.c
===================================================================
--- branches/cmake/teraterm/teraterm/vtterm.c	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/teraterm/vtterm.c	2019-01-25 15:45:19 UTC (rev 7408)
@@ -52,6 +52,7 @@
 #include "telnet.h"
 #include "ttime.h"
 #include "clipboar.h"
+#include "../ttpcmn/language.h"
 #include "codeconv.h"
 
 #include "vtterm.h"
@@ -353,6 +354,7 @@
 
 void ResetCharSet()
 {
+	char *result;
 	if (ts.Language==IdJapanese) {
 		Gn[0] = IdASCII;
 		Gn[1] = IdKatakana;
@@ -392,6 +394,17 @@
 	cv.JIS7KatakanaSend = ts.JIS7KatakanaSend;
 	cv.KanjiIn = ts.KanjiIn;
 	cv.KanjiOut = ts.KanjiOut;
+
+	// \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)
@@ -5415,7 +5428,7 @@
 #include "uni_combining.map"
 
 static unsigned short GetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code,
-										 const combining_map_t table[], int tmax)
+										 const combining_map_t *table, int tmax)
 {
 	unsigned short result = 0;
 	int i;
@@ -5434,7 +5447,7 @@
 	return (result);
 }
 
-static int GetIndexOfCombiningFirstCode(unsigned short code, const combining_map_t table[], int tmax)
+static int GetIndexOfCombiningFirstCode(unsigned short code, const combining_map_t *table, int tmax)
 {
 	int low, mid, high;
 	int index = -1;

Modified: branches/cmake/teraterm/ttpcmn/language.c
===================================================================
--- branches/cmake/teraterm/ttpcmn/language.c	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/ttpcmn/language.c	2019-01-25 15:45:19 UTC (rev 7408)
@@ -37,6 +37,7 @@
 #include <mbstring.h>
 #include <locale.h>
 
+#include "language.h"
 #include "codeconv.h"
 #include "sjis2uni.map"
 
@@ -48,7 +49,7 @@
 #endif
 #endif
 
-DllExport unsigned short WINAPI ConvertUnicode(unsigned short code, const codemap_t *table, int tmax)
+unsigned short ConvertUnicode(unsigned short code, const codemap_t *table, int tmax)
 {
 	int low, mid, high;
 	unsigned short result;
@@ -74,29 +75,29 @@
 	return (result);
 }
 
-DllExport unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, char *locale)
+// \x93\xE0\x95\x94\x83R\x81[\x83h(CodePage)\x82\xF0UTF8\x82֕ϊ\xB7\x82\xB7\x82\xE9
+DllExport unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, int CodePage)
 {
 	wchar_t wchar;
 	int ret;
-	unsigned int code = KCode;
+	unsigned int code;
 	unsigned int c, c1, c2, c3;
-	unsigned char *ptr, buf[3];
-	unsigned short cset;
+	unsigned char buf[3];
 	unsigned char KCode_h;
 	int len = 0;
 
-	*byte = 2;
-
-	// CP932\x82\xA9\x82\xE7UTF-16LE\x82֕ϊ\xB7\x82\xB7\x82\xE9
+	// \x93\xE0\x95\x94\x83R\x81[\x83h(CodePage)\x82\xA9\x82\xE7UTF-16LE\x82֕ϊ\xB7\x82\xB7\x82\xE9
 	KCode_h = (unsigned char)(KCode >> 8);
 	if (KCode_h != 0) {
 		buf[len++] = KCode_h;
 	}
 	buf[len++] = KCode & 0xff;
-	ret = CP932ToWideChar(buf, len, &wchar, 1);
-	if (ret <= 0) { // \x95ϊ\xB7\x8E\xB8\x94s
-		cset = 0;
-		if (_stricmp(locale, DEFAULT_LOCALE) == 0) {
+	ret = MultiByteToWideChar(CodePage, MB_ERR_INVALID_CHARS, buf, len, &wchar, 1);
+	if (ret <= 0) {
+		// \x95ϊ\xB7\x8E\xB8\x94s
+		unsigned short cset = 0;
+		if (CodePage == 932) {
+			// CP932
 			cset = ConvertUnicode(KCode, mapSJISToUnicode, sizeof(mapSJISToUnicode)/sizeof(mapSJISToUnicode[0]));
 		}
 		if (cset == 0) {
@@ -105,27 +106,32 @@
 			c = cset;
 		}
 	} else {
-		ptr = (unsigned char *)&wchar;
-		c = ((ptr[1] << 8) | ptr[0]);
+		c = (unsigned int)wchar;
 	}
 
 	// UTF-16LE\x82\xA9\x82\xE7UTF-8\x82֕ϊ\xB7\x82\xB7\x82\xE9
-	if (0x00000000 <= c && c <= 0x0000007f) {
+	if (c <= 0x0000007f) {
+		// 0x00000000 <= c <= 0x0000007f
 		code = (c & 0xff);
 		*byte = 1;
 
-	} else if (0x00000080 <= c && c <= 0x000007ff) {
+	} else if (c <= 0x000007ff) {
+		// 0x00000080 <= c <= 0x000007ff
 		c1 = ((c >> 6) & 0x1f) | 0xc0;
 		c2 = (c & 0x3f) | 0x80;
 		code = (c1 << 8) | c2;
 		*byte = 2;
 
-	} else if (0x00000800 <= c && c <= 0x0000ffff) {
+	} else if (c <= 0x0000ffff) {
+		// 0x00000800 <= c <= 0x0000ffff
 		c1 = ((c >> 12) & 0xf) | 0xe0;
 		c2 = ((c >> 6) & 0x3f) | 0x80;
 		c3 = ((c) & 0x3f) | 0x80;
 		code = (c1 << 16) | (c2 << 8) | c3;
 		*byte = 3;
+	} else {
+		code = KCode;
+		*byte = 2;
 	}
 
 	return (code);

Modified: branches/cmake/teraterm/ttpcmn/language.h
===================================================================
--- branches/cmake/teraterm/ttpcmn/language.h	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/ttpcmn/language.h	2019-01-25 15:45:19 UTC (rev 7408)
@@ -43,13 +43,13 @@
 #endif
 
 /* proto types */
-DllExport unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, char *locale);
+DllExport unsigned int WINAPI SJIS2UTF8(WORD KCode, int *byte, int CodePage);
 DllExport WORD WINAPI SJIS2JIS(WORD KCode);
 DllExport WORD WINAPI SJIS2EUC(WORD KCode);
 DllExport WORD WINAPI JIS2SJIS(WORD KCode);
 DllExport BYTE WINAPI RussConv(int cin, int cout, BYTE b);
 DllExport void WINAPI RussConvStr(int cin, int cout, PCHAR Str, int count);
-DllExport unsigned short WINAPI ConvertUnicode(unsigned short code, const codemap_t *table, int tmax);
+DllExport unsigned short ConvertUnicode(unsigned short code, const codemap_t *table, int tmax);
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/ttpcmn/ttcmn.c
===================================================================
--- branches/cmake/teraterm/ttpcmn/ttcmn.c	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/ttpcmn/ttcmn.c	2019-01-25 15:45:19 UTC (rev 7408)
@@ -1562,7 +1562,7 @@
 	int outlen;
 	int TempLen = 0;
 
-	code = SJIS2UTF8(K, &outlen, cv->Locale);
+	code = SJIS2UTF8(K, &outlen, *cv->CodePage);
 	switch (outlen) {
 	  case 4:
 		TempStr[TempLen++] = (code >> 24) & 0xff;

Modified: branches/cmake/teraterm/ttpcmn/ttpcmn.vcproj
===================================================================
--- branches/cmake/teraterm/ttpcmn/ttpcmn.vcproj	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/ttpcmn/ttpcmn.vcproj	2019-01-25 15:45:19 UTC (rev 7408)
@@ -207,6 +207,10 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
 			>
 			<File
+				RelativePath="..\common\codeconv.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\common\i18n.c"
 				>
 			</File>

Modified: branches/cmake/teraterm/ttpset/ttset.c
===================================================================
--- branches/cmake/teraterm/ttpset/ttset.c	2019-01-25 12:38:03 UTC (rev 7407)
+++ branches/cmake/teraterm/ttpset/ttset.c	2019-01-25 15:45:19 UTC (rev 7408)
@@ -1594,11 +1594,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);
@@ -2305,8 +2300,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 メーリングリストの案内
アーカイブの一覧に戻る