[Ttssh2-commit] [7495] Merge branch 'trunk' into cmake

アーカイブの一覧に戻る
scmno****@osdn***** scmno****@osdn*****
2019年 3月 18日 (月) 22:57:53 JST


Revision: 7495
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7495
Author:   zmatsuo
Date:     2019-03-18 22:57:53 +0900 (Mon, 18 Mar 2019)
Log Message:
-----------
Merge branch 'trunk' into cmake

Modified Paths:
--------------
    branches/cmake/TTProxy/CMakeLists.txt
    branches/cmake/doc/convtext.bat
    branches/cmake/doc/en/html/about/history.html
    branches/cmake/doc/ja/html/about/history.html
    branches/cmake/doc/ja/html/index.html
    branches/cmake/doc/ja/html/reference/build_with_cmake.md
    branches/cmake/teraterm/common/codeconv.cpp
    branches/cmake/teraterm/keycode/keycode.c
    branches/cmake/teraterm/teraterm/CMakeLists.txt
    branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c
    branches/cmake/teraterm/teraterm/ttime.c
    branches/cmake/teraterm/teraterm/ttime.h
    branches/cmake/teraterm/teraterm/ttwsk.c
    branches/cmake/teraterm/teraterm/vtdisp.c
    branches/cmake/teraterm/teraterm/vtterm.c
    branches/cmake/teraterm/teraterm/vtwin.cpp
    branches/cmake/ttssh2/ttxssh/auth.c
    branches/cmake/ttssh2/ttxssh/auth.h
    branches/cmake/ttssh2/ttxssh/ssh.c
    branches/cmake/ttssh2/ttxssh/ttxssh.h

-------------- next part --------------
Modified: branches/cmake/TTProxy/CMakeLists.txt
===================================================================
--- branches/cmake/TTProxy/CMakeLists.txt	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/TTProxy/CMakeLists.txt	2019-03-18 13:57:53 UTC (rev 7495)
@@ -97,14 +97,12 @@
   ${YCL_SRC}
   )
 
-if(MINGW)
-  set_target_properties(
-    ttproxy
-    PROPERTIES
-    PREFIX ""
-    OUTPUT_NAME "TTXProxy"
-    )
-endif()
+set_target_properties(
+  ttproxy
+  PROPERTIES
+  PREFIX ""
+  OUTPUT_NAME "TTXProxy"
+  )
 
 target_link_libraries(
   ttproxy

Modified: branches/cmake/doc/convtext.bat
===================================================================
--- branches/cmake/doc/convtext.bat	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/doc/convtext.bat	2019-03-18 13:57:53 UTC (rev 7495)
@@ -17,6 +17,5 @@
 %ZLIBCP% -i ..\libs\zlib\README         -o %REF_E%\zlib-LICENSE.txt      -l unix
 %ZLIBCP% -i ..\libs\zlib\README         -o %REF_J%\zlib-LICENSE.txt      -l unix
 
-sed -e '1s/^\xef\xbb\xbf//' < ja/html/reference/build_with_cmake.md > ja/html/reference/build_with_cmake_without_bom.md
-perl Markdown_1.0.1/Markdown.pl ja/html/reference/build_with_cmake_without_bom.md > ja/html/reference/build_with_cmake_utf8.html
+perl -pe 'tr/\x{feff}//d' ja/html/reference/build_with_cmake.md | perl Markdown_1.0.1/Markdown.pl > ja/html/reference/build_with_cmake_utf8.html
 %TOSJIS% -i ja/html/reference/build_with_cmake_utf8.html -o ja/html/reference/build_with_cmake.html  -c utf8

Modified: branches/cmake/doc/en/html/about/history.html
===================================================================
--- branches/cmake/doc/en/html/about/history.html	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/doc/en/html/about/history.html	2019-03-18 13:57:53 UTC (rev 7495)
@@ -35,7 +35,8 @@
 <ul class="history">
   <li>Bug fixes
     <ul>
-      <li><!--IME\x82̕ϊ\xB7\x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x88ʒu\x82\xAA\x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɒǏ]\x82\xB5\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B-->This bus was introduced in 4.102.</li>
+      <li><!--IME\x82̕ϊ\xB7\x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x88ʒu\x82\xAA\x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɒǏ]\x82\xB5\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B-->This bug was introduced in 4.102.</li>
+      <li>Can't display character such as U+2014 EM DASH, U+2212 MINUS SIGN, U+301C WAVE DASH etc. This bug was introduced in 4.102.</li>
     </ul>
   </li>
 
@@ -3112,6 +3113,7 @@
   <li>Bug fixes
     <ul>
       <li>garbage data is added to the CipherOrder and MacOrder settings when saving settings.</li>
+      <li>when echo flag is 1 in the server's authentication informatin message, password string is masked on the keyboard-interactive authentication dialog.</li>
     </ul>
   </li>
 </ul>

Modified: branches/cmake/doc/ja/html/about/history.html
===================================================================
--- branches/cmake/doc/ja/html/about/history.html	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/doc/ja/html/about/history.html	2019-03-18 13:57:53 UTC (rev 7495)
@@ -36,6 +36,7 @@
   <li>\x83o\x83O\x8FC\x90\xB3
     <ul>
       <li>IME\x82̕ϊ\xB7\x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x88ʒu\x82\xAA\x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɒǏ]\x82\xB5\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.102\x82ł̃G\x83\x93\x83o\x83O\x81B</li>
+      <li>U+2014 EM DASH, U+2212 MINUS SIGN, U+301C WAVE DASH \x93\x99\x82̕\xB6\x8E\x9A\x82\xAA\x95\\x8E\xA6\x82ł\xAB\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.102\x82ł̃G\x83\x93\x83o\x83O\x81B</li>
     </ul>
   </li>
 
@@ -3118,6 +3119,7 @@
   <li>\x83o\x83O\x8FC\x90\xB3
     <ul>
       <li>\x90ݒ\xE8\x82̕ۑ\xB6\x8E\x9E\x81ACipherOrder, MacOrder \x90ݒ\xE8\x82ɃS\x83~\x82\xAA\x95t\x89\xC1\x82\xB3\x82\xEA\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
+      <li>\x83T\x81[\x83o\x82̔F\x8F؏\xEE\x95񃁃b\x83Z\x81[\x83W\x82\xC5 echo \x83t\x83\x89\x83O\x82\xAA 1 \x82̎\x9E\x82ɂ\xE0\x83L\x81[\x83{\x81[\x83h\x83C\x83\x93\x83^\x83\x89\x83N\x83e\x83B\x83u\x94F\x8F؃_\x83C\x83A\x83\x8D\x83O\x82Ńp\x83X\x83\x8F\x81[\x83h\x82\xAA\x83}\x83X\x83N\x82\xB3\x82\xEA\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
     </ul>
   </li>
 </ul>

Modified: branches/cmake/doc/ja/html/index.html
===================================================================
--- branches/cmake/doc/ja/html/index.html	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/doc/ja/html/index.html	2019-03-18 13:57:53 UTC (rev 7495)
@@ -144,6 +144,9 @@
  <LI><A HREF="reference/SFMT-LICENSE.txt">SFMT \x83\x89\x83C\x83Z\x83\x93\x83X</A></LI>
  <LI><A HREF="reference/CygTerm+-LICENSE.txt">CygTerm+ \x83\x89\x83C\x83Z\x83\x93\x83X</A></LI>
  <LI><A HREF="reference/develop.txt">\x8AJ\x94\xAD\x8EҌ\xFC\x82\xAF</A></LI>
+ <UL>
+   <LI><A HREF="reference/build_with_cmake.html">CMake\x83r\x83\x8B\x83h\x83V\x83X\x83e\x83\x80\x82\xF0\x8Eg\x97p\x82\xB5\x82\xBD\x83r\x83\x8B\x83h(experimental)</A></LI>
+ </UL>
  <LI><A HREF="reference/sourcecode.html">\x83\\x81[\x83X\x83R\x81[\x83h\x89\xF0\x90\xE0</A></LI>
 </UL>
 

Modified: branches/cmake/doc/ja/html/reference/build_with_cmake.md
===================================================================
--- branches/cmake/doc/ja/html/reference/build_with_cmake.md	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/doc/ja/html/reference/build_with_cmake.md	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1,12 +1,12 @@
 # cmakeを使ったビルド
 
-- 実験的に cmake を使用してビルドすることができます
-- cmake https://cmake.org/
+- cmake を使用してビルドすることができます(実験的な位置づけです)
+	- https://cmake.org/
 
 ## cmakeのバージョン
 
 - Visual Studio 2005 をサポートしている cmake の最後のバージョンは 3.11.4 です
-- 2005 以外の Visual Studio を使用する場合は特に制限はありません
+- Visual Studio 2005 以外を使用する場合は特に制限はありません
 - Visual Studio 2017 インストーラーで、オプションを選べば cmake をインストールできます
 
 ## ライブラリのビルド
@@ -21,12 +21,15 @@
     ```
     mkdir build_vs2005
     cd build_vs2005
-    "c:\Program Files (x86)\CMake-3.11.4\bin\cmake.exe" .. -G "Visual Studio 8 2005"
+	..\libs\cmake-3.11.4-win32-x86\bin\cmake.exe .. -G "Visual Studio 8 2005"
     ```
-    - パスが通っていれば cmake はフルパスで書く必要はありません
     - `-G` オプションの後ろは使用する Visual Studio のバージョンに合わせて調整します
 - sln ファイルが生成されるので Visual Studio で開くことができます
 - cmakeを使ってビルドする場合は次のコマンドを実行します  
     ```
-    cmake --build . --config release
+	..\libs\cmake-3.11.4-win32-x86\bin\cmake.exe --build . --config release
     ```
+- パスが通っていれば cmake はフルパスで書く必要はありません
+- 生成された sln ファイルから起動したVisual Studioでビルドすると
+  CMakeLists.txt を変更を検出してプロジェクトファイルの再生成を自動で行うので
+  sln ファイルの生成を手動で行うのは最初の1回だけです

Modified: branches/cmake/teraterm/common/codeconv.cpp
===================================================================
--- branches/cmake/teraterm/common/codeconv.cpp	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/common/codeconv.cpp	2019-03-18 13:57:53 UTC (rev 7495)
@@ -122,7 +122,7 @@
 		buf[1] = cp932 & 0xff;
 		len = 2;
 	}
-	ret = MultiByteToWideChar(932, MB_ERR_INVALID_CHARS, (char *)buf, len, &wchar, 1);
+	ret = ::MultiByteToWideChar(932, MB_ERR_INVALID_CHARS, (char *)buf, len, &wchar, 1);
 	if (ret <= 0) {
 		// MultiByteToWideChar()\x82\xAA\x95ϊ\xB7\x8E\xB8\x94s
 #if !defined(PRIORITY_CP932_TABLE)
@@ -164,6 +164,7 @@
  *	@param mb_code		\x83}\x83\x8B\x83`\x83o\x83C\x83g\x82̕\xB6\x8E\x9A\x83R\x81[\x83h(0x0000-0xffff)
  *	@param code_page	\x83}\x83\x8B\x83`\x83o\x83C\x83g\x82̃R\x81[\x83h\x83y\x81[\x83W
  *	@retval				unicode(UTF-32\x95\xB6\x8E\x9A\x83R\x81[\x83h)
+ *						0=\x83G\x83\x89\x81[(\x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD)
  */
 unsigned int MBCP_UTF32(unsigned short mb_code, int code_page)
 {
@@ -187,7 +188,7 @@
 			buf[1] = mb_code & 0xff;
 			len = 2;
 		}
-		ret = MultiByteToWideChar(code_page, MB_ERR_INVALID_CHARS, buf, len, &wchar, 1);
+		ret = ::MultiByteToWideChar(code_page, MB_ERR_INVALID_CHARS, buf, len, &wchar, 1);
 		if (ret <= 0) {
 			c = 0;
 		} else {
@@ -210,6 +211,7 @@
 	DWORD mblen;
 	wchar_t u16_str[2];
 	size_t u16_len;
+	BOOL use_default_char;
 
 	if (u32 < 0x80) {
 		return (unsigned short)u32;
@@ -230,22 +232,20 @@
 	if (u16_len == 0) {
 		return 0;
 	}
-	mblen = WideCharToMultiByte(932, 0, u16_str, (int)u16_len, mbstr, 2, NULL, NULL);
+	use_default_char = FALSE;
+	mblen = ::WideCharToMultiByte(932, 0, u16_str, (int)u16_len, mbstr, 2, NULL, &use_default_char);
+	if (use_default_char) {
+		// \x95ϊ\xB7\x82ł\xAB\x82\xB8\x81A\x8A\xF9\x92\xE8\x82̕\xB6\x8E\x9A\x82\xF0\x8Eg\x82\xC1\x82\xBD
+		goto next_convert;
+	}
 	switch (mblen) {
 	case 0:
+		// \x95ϊ\xB7\x8E\xB8\x94s
+		goto next_convert;
 	case 1:
-	default:
-		if (mblen == 0 || mbstr[0] == '?') {
-			goto next_convert;
-		} else {
-			mb = (unsigned char)mbstr[0];
-			return mb;
-		}
+		mb = (unsigned char)mbstr[0];
+		return mb;
 	case 2:
-		if (mbstr[0] == '?' && mbstr[1] == '?') {
-			// 2byte\x8Fo\x97\xCD && "??" \x82̏ꍇ\x82͕ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD
-			goto next_convert;
-		}
 		mb = (((unsigned char)mbstr[0]) << 8) | (unsigned char)mbstr[1];
 		return mb;
 	}
@@ -320,7 +320,7 @@
 		} else {
 			goto error;
 		}
-	} else if (0xf0 <= c1 && c1 <= 0xf7 && u8_len >= 4) {
+	} else if (0xf0 <= c1 && c1 <= 0xf7) {
 		// 4byte
 		if (u8_len >= 4) {
 			const uint8_t c2 = *u8_ptr++;
@@ -504,6 +504,12 @@
 size_t UTF32ToUTF16(uint32_t u32, wchar_t *wstr_ptr, size_t wstr_len)
 {
 	size_t u16_out;
+	if (wstr_ptr == NULL) {
+		wstr_len = 2;
+	}
+	if (wstr_len == 0) {
+		return 0;
+	}
 	if (u32 < 0x10000) {
 		if (wstr_len >= 1) {
 			if (wstr_ptr != NULL) {
@@ -540,11 +546,26 @@
  */
 size_t UTF32ToCP932(uint32_t u32, char *mb_ptr, size_t mb_len)
 {
+	uint16_t cp932;
 	size_t cp932_out;
-	const uint16_t cp932 = UTF32_CP932(u32);
-	if (cp932 == 0 && u32 != 0) {
+	if (mb_ptr == NULL) {
+		mb_len = 2;		// 2byte\x82\xA0\x82\xEA\x82Α\xAB\x82\xE8\x82\xE9\x82͂\xB8
+	}
+	if (mb_len == 0) {
+		// \x8Fo\x97͐\xE6\x83T\x83C\x83Y\x82\xAA0
 		return 0;
 	}
+	if (u32 == 0) {
+		if (mb_ptr != NULL) {
+			*mb_ptr = 0;
+		}
+		return 1;
+	}
+	cp932 = UTF32_CP932(u32);
+	if (cp932 == 0) {
+		// \x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD
+		return 0;
+	}
 	if (mb_ptr == NULL) {
 		mb_len = 2;
 	}
@@ -577,7 +598,7 @@
  * @param[in]		code_page	\x95ϊ\xB7\x90\xE6codepage
  * @param[in,out]	mb_ptr		\x95ϊ\xB7\x90敶\x8E\x9A\x97\xF1\x8Fo\x97͐\xE6(NULL\x82̂Ƃ\xAB\x8Fo\x97͂\xB5\x82Ȃ\xA2)
  * @param[in]		mb_len		CP932\x8Fo\x97͐敶\x8E\x9A\x90\x94(\x95\xB6\x8E\x9A\x90\x94,sizeof(wchar_t)*wstr_len bytes)
- * @retval			\x8Fo\x97͂\xB5\x82\xBDCP932\x95\xB6\x8E\x9A\x90\x94(byte\x90\x94)
+ * @retval			\x8Fo\x97͂\xB5\x82\xBDmultibyte\x95\xB6\x8E\x9A\x90\x94(byte\x90\x94)
  *					0=\x83G\x83\x89\x81[(\x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD)
  */
 size_t UTF32ToMBCP(unsigned int u32, int code_page, char *mb_ptr, size_t mb_len)
@@ -588,6 +609,7 @@
 	if (code_page == 932) {
 		return UTF32ToCP932(u32, mb_ptr, mb_len);
 	} else {
+		BOOL use_default_char;
 		wchar_t u16_str[2];
 		size_t u16_len;
 		u16_len = UTF32ToUTF16(u32, u16_str, 2);
@@ -594,10 +616,11 @@
 		if (u16_len == 0) {
 			return 0;
 		}
-		mb_len = WideCharToMultiByte(code_page, 0, u16_str, u16_len, mb_ptr, mb_len, NULL, NULL);
-		if (mb_ptr != NULL && u32 != '?' && mb_len == 1 && mb_ptr[0] == '?') {
-			// \x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD\x82Ƃ\xAB\x81A\x96߂\xE8\x92l=1, \x95\xB6\x8E\x9A[0]='?' \x82\xF0\x95Ԃ\xB5\x82Ă\xAD\x82\xE9
-			mb_len = 0;
+		use_default_char = FALSE;
+		mb_len = ::WideCharToMultiByte(code_page, 0, u16_str, u16_len, mb_ptr, mb_len, NULL, &use_default_char);
+		if (use_default_char) {
+			// \x95ϊ\xB7\x82ł\xAB\x82\xB8\x81A\x8A\xF9\x92\xE8\x82̕\xB6\x8E\x9A\x82\xF0\x8Eg\x82\xC1\x82\xBD
+			return 0;
 		}
 		return mb_len;
 	}
@@ -605,10 +628,11 @@
 
 /**
  *	wchar_t(UTF-16)\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x83}\x83\x8B\x83`\x83o\x83C\x83g\x95\xB6\x8E\x9A\x97\xF1\x82ɕϊ\xB7\x82\xB7\x82\xE9
+ *	\x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA2\x95\xB6\x8E\x9A\x82\xCD '?' \x82ŏo\x97͂\xB7\x82\xE9
  *
  *	@param[in]		*wstr_ptr	wchar_t\x95\xB6\x8E\x9A\x97\xF1
  *	@param[in,out]	*wstr_len	wchar_t\x95\xB6\x8E\x9A\x97\xF1\x92\xB7
- *								NULL\x82܂\xBD\x82\xCD0\x82̂Ƃ\xAB\x8E\xA9\x93\xAE\x81AL'\0'\x82Ń^\x81[\x83~\x83l\x81[\x83g\x82\xB7\x82邱\x82\xC6)
+ *								NULL\x82܂\xBD\x82\xCD0\x82̂Ƃ\xAB\x8E\xA9\x93\xAE(L'\0'\x82Ń^\x81[\x83~\x83l\x81[\x83g\x82\xB7\x82邱\x82\xC6)
  *								NULL\x88ȊO\x82̂Ƃ\xAB\x93\xFC\x97͂\xB5\x82\xBD\x95\xB6\x8E\x9A\x90\x94\x82\xF0\x95Ԃ\xB7
  *	@param[in]		*mb_ptr		\x95ϊ\xB7\x82\xB5\x82\xBD\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8E\xFB\x94[\x82\xB7\x82\xE9\x83|\x83C\x83\x93\x83^
  *								(NULL\x82̂Ƃ\xAB\x95ϊ\xB7\x82\xB9\x82\xB8\x82ɕ\xB6\x8E\x9A\x90\x94\x82\xF0\x83J\x83E\x83\x93\x83g\x82\xB7\x82\xE9)
@@ -642,34 +666,24 @@
 	}
 
 	while(mb_len > 0 && wstr_len > 0) {
-		const wchar_t u16 = *wstr_ptr++;
-		uint32_t u32 = u16;
 		size_t mb_out;
-		wstr_len--;
-		wstr_in++;
-		// \x83T\x83\x8D\x83Q\x81[\x83g high?
-		if (IsHighSurrogate(u16)) {
-			if (wstr_len >= 1) {
-				const wchar_t u16_lo = *wstr_ptr++;
-				wstr_len--;
-				wstr_in++;
-				// \x83T\x83\x8D\x83Q\x81[\x83g low?
-				if (IsLowSurrogate(u16_lo)) {
-					// \x83T\x83\x8D\x83Q\x81[\x83g\x83y\x83A \x83f\x83R\x81[\x83h
-					u32 = 0x10000 + (u16 - 0xd800) * 0x400 + (u16_lo - 0xdc00);
-				} else {
-					goto unknown_code;
-				}
-			} else {
-				goto unknown_code;
-			}
+		uint32_t u32;
+		size_t wb_in = UTF16ToUTF32(wstr_ptr, wstr_len, &u32);
+		if (wb_in == 0) {
+			wstr_len -= 1;
+			wstr_in += 1;
+			wstr_ptr++;
+			goto unknown_code;
 		}
+		wstr_len -= wb_in;
+		wstr_in += wb_in;
+		wstr_ptr += wb_in;
 		mb_out = UTF32ToMB(u32, mb_ptr, mb_len);
 		if (mb_out == 0) {
 		unknown_code:
 			if (mb_ptr != NULL) {
 				// \x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD\x8Fꍇ
-				*mb_ptr++ = '?';
+				*mb_ptr = '?';
 			}
 			mb_out = 1;
 		}
@@ -739,10 +753,16 @@
 	while(wstr_len > 0 && u8_len > 0) {
 		uint32_t u32;
 		size_t u16_out;
-		size_t u8_in = UTF8ToUTF32(u8_ptr, u8_len, &u32);
-		if (u8_in == 0) {
-			u32 = '?';
+		size_t u8_in;
+		if (*u8_ptr == 0) {
+			u32 = 0;
 			u8_in = 1;
+		} else {
+			u8_in = UTF8ToUTF32(u8_ptr, u8_len, &u32);
+			if (u8_in == 0) {
+				u32 = '?';
+				u8_in = 1;
+			}
 		}
 		u8_ptr += u8_in;
 		u8_len -= u8_in;
@@ -779,6 +799,8 @@
 
 /**
  *	wchar_t\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x83}\x83\x8B\x83`\x83o\x83C\x83g\x95\xB6\x8E\x9A\x97\xF1\x82֕ϊ\xB7
+ *	\x95ϊ\xB7\x82ł\xAB\x82Ȃ\xA2\x95\xB6\x8E\x9A\x82\xCD '?' \x82ŏo\x97͂\xB7\x82\xE9
+ *
  *	@param[in]	*wstr_ptr	wchar_t\x95\xB6\x8E\x9A\x97\xF1
  *	@param[in]	wstr_len	wchar_t\x95\xB6\x8E\x9A\x97\xF1\x92\xB7(0\x82̂Ƃ\xAB\x8E\xA9\x93\xAE\x81A\x8E\xA9\x93\xAE\x82̂Ƃ\xAB\x82\xCDL'\0'\x82Ń^\x81[\x83~\x83l\x81[\x83g\x82\xB7\x82邱\x82\xC6)
  *	@param[in]	code_page	\x95ϊ\xB7\x90\xE6\x83R\x81[\x83h\x83y\x81[\x83W

Modified: branches/cmake/teraterm/keycode/keycode.c
===================================================================
--- branches/cmake/teraterm/keycode/keycode.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/keycode/keycode.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -169,16 +169,16 @@
 {
 	PAINTSTRUCT ps;
 	HDC hDC;
-	TCHAR OutStr[30];
+	char OutStr[30];
 
 	hDC = BeginPaint(hWnd, &ps);
 
 	if (KeyDown) {
-		_sntprintf_s(OutStr,_countof(OutStr),_TRUNCATE, _T("Key code is %u.") ,Scan);
-		TextOut(hDC,10,10,OutStr,_tcslen(OutStr));
+		_snprintf_s(OutStr,sizeof(OutStr),_TRUNCATE,"Key code is %u.",Scan);
+		TextOutA(hDC,10,10,OutStr,strlen(OutStr));
 	}
 	else {
-		TextOut(hDC,10,10,_T("Push any key."),13);
+		TextOutA(hDC,10,10,"Push any key.",13);
 	}
 
 	EndPaint(hWnd, &ps);

Modified: branches/cmake/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/teraterm/CMakeLists.txt	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/CMakeLists.txt	2019-03-18 13:57:53 UTC (rev 7495)
@@ -192,10 +192,8 @@
   gdi32
   comctl32
   ws2_32
-  imm32
   imagehlp
   delayimp
-  oleaut32
   uuid
   )
 

Modified: branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c
===================================================================
--- branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2017 TeraTerm Project
+ * Copyright (C) 2010-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: branches/cmake/teraterm/teraterm/ttime.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttime.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/ttime.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1,6 +1,6 @@
-/*
+/*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,21 +29,23 @@
 /* Tera Term */
 /* TERATERM.EXE, IME interface */
 
-#undef UNICODE
-#undef _UNICODE
-
-#include "teraterm.h"
-#include "tttypes.h"
+#include <windows.h>
 #include <stdlib.h>
 #include <string.h>
 #include <imm.h>
+#include <crtdbg.h>
+#include <stdio.h>
+#include <assert.h>
 
-#include "ttwinman.h"
-#include "ttcommon.h"
-
 #include "ttime.h"
-#include "ttlib.h"
 
+#ifdef _DEBUG
+#define malloc(l)	_malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define calloc(l,n)	_calloc_dbg((l), (n), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)		_free_dbg((p), _NORMAL_BLOCK)
+#endif
+
+// imm.h \x82\xAA include \x82ł\xAB\x82\xEA\x82\xCE _IMM_ \x82\xAA define \x82\xB3\x82\xEA\x82\xE9 \x81\xA8 \x82\xB1\x82̃u\x83\x8D\x83b\x83N\x95s\x97v?
 #ifndef _IMM_
   #define _IMM_
 
@@ -54,12 +56,14 @@
     POINT ptCurrentPos;
     RECT  rcArea;
   } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, *LPCOMPOSITIONFORM;
-#endif //_IMM_
 
 #define GCS_RESULTSTR 0x0800
+#endif //_IMM_
 
-typedef LONG (WINAPI *TImmGetCompositionString)
-	(HIMC, DWORD, LPVOID, DWORD);
+// #define ENABLE_DUMP	1
+
+typedef LONG (WINAPI *TImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
+typedef LONG (WINAPI *TImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
 typedef HIMC (WINAPI *TImmGetContext)(HWND);
 typedef BOOL (WINAPI *TImmReleaseContext)(HWND, HIMC);
 typedef BOOL (WINAPI *TImmSetCompositionFont)(HIMC, LPLOGFONTA);
@@ -67,7 +71,8 @@
 typedef BOOL (WINAPI *TImmGetOpenStatus)(HIMC);
 typedef BOOL (WINAPI *TImmSetOpenStatus)(HIMC, BOOL);
 
-static TImmGetCompositionString PImmGetCompositionStringW;
+static TImmGetCompositionStringW PImmGetCompositionStringW;
+static TImmGetCompositionStringA PImmGetCompositionStringA;
 static TImmGetContext PImmGetContext;
 static TImmReleaseContext PImmReleaseContext;
 static TImmSetCompositionFont PImmSetCompositionFont;
@@ -79,81 +84,66 @@
 static HANDLE HIMEDLL = NULL;
 static LOGFONTA lfIME;
 
-
-BOOL LoadIME()
+BOOL LoadIME(void)
 {
   BOOL Err;
-#if 0
-  PTTSet tempts;
-#endif
-  char uimsg[MAX_UIMSG];
   char imm32_dll[MAX_PATH];
 
   if (HIMEDLL != NULL) return TRUE;
+
   GetSystemDirectoryA(imm32_dll, sizeof(imm32_dll));
   strncat_s(imm32_dll, sizeof(imm32_dll), "\\imm32.dll", _TRUNCATE);
   HIMEDLL = LoadLibraryA(imm32_dll);
   if (HIMEDLL == NULL)
   {
-    get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg),  "Tera Term: Error", ts.UILanguageFile);
-    get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile);
-    MessageBoxA(0,ts.UIMsg,uimsg,MB_ICONEXCLAMATION);
-    WritePrivateProfileStringA("Tera Term","IME","off",ts.SetupFName);
-    ts.UseIME = 0;
-#if 0
-    tempts = (PTTSet)malloc(sizeof(TTTSet));
-    if (tempts!=NULL)
-    {
-      GetDefaultSet(tempts);
-      tempts->UseIME = 0;
-      ChangeDefaultSet(tempts,NULL);
-      free(tempts);
-    }
-#endif
-    return FALSE;
+	return FALSE;
   }
 
   Err = FALSE;
 
-  PImmGetCompositionStringW = (TImmGetCompositionString)GetProcAddress(
-    HIMEDLL, "ImmGetCompositionStringW");
+  PImmGetCompositionStringW = (TImmGetCompositionStringW)GetProcAddress(
+	HIMEDLL, "ImmGetCompositionStringW");
   if (PImmGetCompositionStringW==NULL) Err = TRUE;
 
+  PImmGetCompositionStringA = (TImmGetCompositionStringA)GetProcAddress(
+	HIMEDLL, "ImmGetCompositionStringA");
+  if (PImmGetCompositionStringA==NULL) Err = TRUE;
+
   PImmGetContext = (TImmGetContext)GetProcAddress(
-    HIMEDLL, "ImmGetContext");
+	HIMEDLL, "ImmGetContext");
   if (PImmGetContext==NULL) Err = TRUE;
 
   PImmReleaseContext = (TImmReleaseContext)GetProcAddress(
-    HIMEDLL, "ImmReleaseContext");
+	HIMEDLL, "ImmReleaseContext");
   if (PImmReleaseContext==NULL) Err = TRUE;
 
   PImmSetCompositionFont = (TImmSetCompositionFont)GetProcAddress(
-    HIMEDLL, "ImmSetCompositionFontA");
+	HIMEDLL, "ImmSetCompositionFontA");
   if (PImmSetCompositionFont==NULL) Err = TRUE;
 
   PImmSetCompositionWindow = (TImmSetCompositionWindow)GetProcAddress(
-    HIMEDLL, "ImmSetCompositionWindow");
+	HIMEDLL, "ImmSetCompositionWindow");
   if (PImmSetCompositionWindow==NULL) Err = TRUE;
 
   PImmGetOpenStatus = (TImmGetOpenStatus)GetProcAddress(
-    HIMEDLL, "ImmGetOpenStatus");
+	HIMEDLL, "ImmGetOpenStatus");
   if (PImmGetOpenStatus==NULL) Err = TRUE;
 
   PImmSetOpenStatus = (TImmSetOpenStatus)GetProcAddress(
-    HIMEDLL, "ImmSetOpenStatus");
+	HIMEDLL, "ImmSetOpenStatus");
   if (PImmSetOpenStatus==NULL) Err = TRUE;
 
   if ( Err )
   {
-    FreeLibrary(HIMEDLL);
-    HIMEDLL = NULL;
-    return FALSE;
+	FreeLibrary(HIMEDLL);
+	HIMEDLL = NULL;
+	return FALSE;
   }
-  else
-    return TRUE;
+
+  return TRUE;
 }
 
-void FreeIME()
+void FreeIME(HWND hWnd)
 {
   HANDLE HTemp;
 
@@ -162,17 +152,17 @@
   HIMEDLL = NULL;
 
   /* position of conv. window -> default */
-  SetConversionWindow(HVTWin,-1,0);
+  SetConversionWindow(hWnd,-1,0);
   Sleep(1); // for safety
   FreeLibrary(HTemp);
 }
 
-BOOL CanUseIME()
+BOOL CanUseIME(void)
 {
   return (HIMEDLL != NULL);
 }
 
-void SetConversionWindow(HWND HWin, int X, int Y)
+void SetConversionWindow(HWND HWnd, int X, int Y)
 {
   HIMC	hIMC;
   COMPOSITIONFORM cf;
@@ -179,20 +169,20 @@
 
   if (HIMEDLL == NULL) return;
 // Adjust the position of conversion window
-  hIMC = (*PImmGetContext)(HVTWin);
+  hIMC = (*PImmGetContext)(HWnd);
   if (X>=0)
   {
-    cf.dwStyle = CFS_POINT;
-    cf.ptCurrentPos.x = X;
-    cf.ptCurrentPos.y = Y;
+	cf.dwStyle = CFS_POINT;
+	cf.ptCurrentPos.x = X;
+	cf.ptCurrentPos.y = Y;
   }
   else
-    cf.dwStyle = CFS_DEFAULT;
+	cf.dwStyle = CFS_DEFAULT;
   (*PImmSetCompositionWindow)(hIMC,&cf);
-  (*PImmReleaseContext)(HVTWin,hIMC);
+  (*PImmReleaseContext)(HWnd,hIMC);
 }
 
-void SetConversionLogFont(HWND HWin, PLOGFONT lf)
+void SetConversionLogFont(HWND HWnd, PLOGFONTA lf)
 {
   HIMC	hIMC;
   if (HIMEDLL == NULL) return;
@@ -199,54 +189,129 @@
 
   memcpy(&lfIME,lf,sizeof(LOGFONT));
 
-  hIMC = (*PImmGetContext)(HVTWin);
+  hIMC = (*PImmGetContext)(HWnd);
   // Set font for the conversion window
   (*PImmSetCompositionFont)(hIMC,&lfIME);
-  (*PImmReleaseContext)(HVTWin,hIMC);
+  (*PImmReleaseContext)(HWnd,hIMC);
 }
 
+// \x93\xE0\x95\x94\x97p
+static const char *GetConvStringA_i(HWND hWnd, DWORD index, size_t *len)
+{
+	HIMC hIMC;
+	LONG size;
+	char *lpstr;
+
+	hIMC = (*PImmGetContext)(hWnd);
+	if (hIMC==0)
+		goto error_2;
+
+	// Get the size of the result string.
+	//		\x92\x8D\x88\xD3 ImmGetCompositionStringA() \x82̖߂\xE8\x92l\x82\xCD byte \x90\x94
+	size = PImmGetCompositionStringA(hIMC, index, NULL, 0);
+	if (size <= 0)
+		goto error_1;
+
+	lpstr = malloc(size + sizeof(char));
+	if (lpstr == NULL)
+		goto error_1;
+
+	size = PImmGetCompositionStringA(hIMC, index, lpstr, size);
+	if (size <= 0) {
+		free(lpstr);
+		goto error_1;
+	}
+
+	*len = size;
+	lpstr[size] = 0;	// \x83^\x81[\x83~\x83l\x81[\x83g\x82\xB7\x82\xE9
+
+	(*PImmReleaseContext)(hWnd, hIMC);
+	return lpstr;
+
+error_1:
+	(*PImmReleaseContext)(hWnd, hIMC);
+error_2:
+	*len = 0;
+	return NULL;
+}
+
+// \x93\xE0\x95\x94\x97p wchar_t\x94\xC5
+static const wchar_t *GetConvStringW_i(HWND hWnd, DWORD index, size_t *len)
+{
+	HIMC hIMC;
+	LONG size;
+	wchar_t *lpstr;
+
+	hIMC = (*PImmGetContext)(hWnd);
+	if (hIMC==0)
+		goto error_2;
+
+	// Get the size of the result string.
+	//		\x92\x8D\x88\xD3 ImmGetCompositionStringW() \x82̖߂\xE8\x92l\x82\xCD byte \x90\x94
+	size = PImmGetCompositionStringW(hIMC, index, NULL, 0);
+	if (size <= 0)
+		goto error_1;
+
+	lpstr = malloc(size + sizeof(wchar_t));
+	if (lpstr == NULL)
+		goto error_1;
+
+	size = PImmGetCompositionStringW(hIMC, index, lpstr, size);
+	if (size <= 0) {
+		free(lpstr);
+		goto error_1;
+	}
+
+	*len = size/2;
+	lpstr[(size/2)] = 0;	// \x83^\x81[\x83~\x83l\x81[\x83g\x82\xB7\x82\xE9
+
+	(*PImmReleaseContext)(hWnd, hIMC);
+	return lpstr;
+
+error_1:
+	(*PImmReleaseContext)(hWnd, hIMC);
+error_2:
+	*len = 0;
+	return NULL;
+}
+
 /*
- *	@param[in,out]	*len	wchar_t文字数
- *	@reterun		変換wchar_t文字列へのポインタ
- *					NULLの場合変換確定していない(またはエラー)
- *					文字列は使用後free()すること
+ *	@param[out]		*len	wchar_t\x95\xB6\x8E\x9A\x90\x94('\0'\x82͊܂܂Ȃ\xA2)
+ *	@retval			\x95ϊ\xB7wchar_t\x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ *					NULL\x82̏ꍇ\x95ϊ\xB7\x8Am\x92肵\x82Ă\xA2\x82Ȃ\xA2(\x82܂\xBD\x82̓G\x83\x89\x81[)
+ *					\x95\xB6\x8E\x9A\x97\xF1\x82͎g\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6
  */
-const wchar_t *GetConvString(HWND hWnd, UINT wParam, LPARAM lParam, size_t *len)
+const wchar_t *GetConvStringW(HWND hWnd, LPARAM lParam, size_t *len)
 {
-	wchar_t *lpstr;
+	const wchar_t *lpstr;
 
 	*len = 0;
 	if (HIMEDLL==NULL) return NULL;
 
 	if ((lParam & GCS_RESULTSTR) != 0) {
-		HIMC hIMC;
-		LONG size;
+		lpstr = GetConvStringW_i(hWnd, GCS_RESULTSTR, len);
+	} else {
+		lpstr = NULL;
+	}
 
-		hIMC = (*PImmGetContext)(hWnd);
-		if (hIMC==0) return NULL;
+	return lpstr;
+}
 
-		// Get the size of the result string.
-		//		注意 ImmGetCompositionStringW() の戻り値は byte 数
-		size = PImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
-		if (size <= 0) {
-			lpstr = NULL;		// エラー
-		} else {
-			lpstr = malloc(size + sizeof(WCHAR));
-			if (lpstr != NULL)
-			{
-				size = PImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpstr, size);
-				if (size <= 0) {
-					free(lpstr);
-					lpstr = NULL;
-				} else {
-					*len = size/2;
-					lpstr[(size/2)] = 0;	// ターミネートする
-				}
-			}
-		}
+/*
+ *	@param[out]		*len	\x95\xB6\x8E\x9A\x90\x94('\0'\x82͊܂܂Ȃ\xA2)
+ *	@retval			\x95ϊ\xB7\x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ *					NULL\x82̏ꍇ\x95ϊ\xB7\x8Am\x92肵\x82Ă\xA2\x82Ȃ\xA2(\x82܂\xBD\x82̓G\x83\x89\x81[)
+ *					\x95\xB6\x8E\x9A\x97\xF1\x82͎g\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6
+ */
+const char *GetConvStringA(HWND hWnd, LPARAM lParam, size_t *len)
+{
+	const char *lpstr;
 
-		(*PImmReleaseContext)(hWnd, hIMC);
+	*len = 0;
+	if (HIMEDLL==NULL) return NULL;
 
+	if ((lParam & GCS_RESULTSTR) != 0) {
+		lpstr = GetConvStringA_i(hWnd, GCS_RESULTSTR, len);
 	} else {
 		lpstr = NULL;
 	}
@@ -254,25 +319,206 @@
 	return lpstr;
 }
 
-BOOL GetIMEOpenStatus()
+BOOL GetIMEOpenStatus(HWND hWnd)
 {
 	HIMC hIMC;
 	BOOL stat;
 
 	if (HIMEDLL==NULL) return FALSE;
-	hIMC = (*PImmGetContext)(HVTWin);
+	hIMC = (*PImmGetContext)(hWnd);
 	stat = (*PImmGetOpenStatus)(hIMC);
-	(*PImmReleaseContext)(HVTWin, hIMC);
+	(*PImmReleaseContext)(hWnd, hIMC);
 
 	return stat;
-
 }
 
-void SetIMEOpenStatus(BOOL stat) {
+void SetIMEOpenStatus(HWND hWnd, BOOL stat)
+{
 	HIMC hIMC;
 
 	if (HIMEDLL==NULL) return;
-	hIMC = (*PImmGetContext)(HVTWin);
+	hIMC = (*PImmGetContext)(hWnd);
 	(*PImmSetOpenStatus)(hIMC, stat);
-	(*PImmReleaseContext)(HVTWin, hIMC);
+	(*PImmReleaseContext)(hWnd, hIMC);
 }
+
+#if defined(ENABLE_DUMP)
+static void DumpReconvStringSt(RECONVERTSTRING *pReconv, BOOL unicode)
+{
+	if (unicode) {
+		wchar_t tmp[1024];
+		_snwprintf(tmp, _countof(tmp),
+				   L"Str %d,%d CompStr %d,%d TargeteStr %d,%d '%s'\n",
+				   pReconv->dwStrLen,
+				   pReconv->dwStrOffset,
+				   pReconv->dwCompStrLen,
+				   pReconv->dwCompStrOffset,
+				   pReconv->dwTargetStrLen,
+				   pReconv->dwTargetStrOffset,
+				   (wchar_t *)(((char *)pReconv) + pReconv->dwStrOffset)
+			);
+		OutputDebugStringW(tmp);
+	} else {
+		char tmp[1024];
+		_snprintf(tmp, sizeof(tmp),
+				  "Str %d,%d CompStr %d,%d TargeteStr %d,%d '%s'\n",
+				  pReconv->dwStrLen,
+				  pReconv->dwStrOffset,
+				  pReconv->dwCompStrLen,
+				  pReconv->dwCompStrOffset,
+				  pReconv->dwTargetStrLen,
+				  pReconv->dwTargetStrOffset,
+				  (((char *)pReconv) + pReconv->dwStrOffset)
+			);
+		OutputDebugStringA(tmp);
+	}
+}
+#endif
+
+// IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x82ւ̑Ή\x9E
+// MS\x82\xA9\x82炿\x82\xE1\x82\xF1\x82Ǝd\x97l\x82\xAA\x92񎦂\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x82̂ŁA\x83A\x83h\x83z\x83b\x83N\x82ɂ\xE2\x82邵\x82\xA9\x82Ȃ\xA2\x82炵\x82\xA2\x81B
+// cf. http://d.hatena.ne.jp/topiyama/20070703
+//	   http://ice.hotmint.com/putty/#DOWNLOAD
+//	   http://27213143.at.webry.info/201202/article_2.html
+//	   http://webcache.googleusercontent.com/search?q=cache:WzlX3ouMscIJ:anago.2ch.net/test/read.cgi/software/1325573999/82+IMR_DOCUMENTFEED&cd=13&hl=ja&ct=clnk&gl=jp
+// (2012.5.9 yutaka)
+/**
+ * IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x97p\x8D\\x91\xA2\x91̂\xF0\x8D쐬\x82\xB7\x82\xE9
+ *		msg == WM_IME_REQUEST,wParam == IMR_DOCUMENTFEED \x82̉\x9E\x93\x9A\x82Ɏg\x82\xA4
+ *		ANSI\x82\xA9Unicode\x83E\x83B\x83\x93\x83h\x83E\x82ɂ\xE6\x82\xC1\x82ĎQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82\xF0\x95ύX\x82\xB7\x82邱\x82\xC6
+ * unicode		TRUE\x82̂Ƃ\xABunicode
+ * str_ptr		\x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ * str_count	\x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82̕\xB6\x8E\x9A\x90\x94(char\x82Ȃ\xE7bytes\x90\x94,wchar_t\x82Ȃ\xE7wchar_t\x90\x94)
+ * cx			\x83J\x81[\x83\\x83\x8B\x88ʒu(char/wchar_t\x92P\x88\xCA)
+ * st_size		\x90\xB6\x90\xAC\x82\xB5\x82\xBD\x8D\\x91\xA2\x91̂̃T\x83C\x83Y
+ * \x96߂\xE8\x92l		\x8D\\x91\xA2\x91̂ւ̃|\x83C\x83\x93\x83^
+ *				\x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7 free()\x82\xB7\x82邱\x82\xC6
+ */
+static void *CreateReconvStringSt(HWND hWnd, BOOL unicode,
+								  const void *str_ptr, size_t str_count,
+								  size_t cx, size_t *st_size_)
+{
+	static int new_str_len_bytes;
+	static int new_buf_len_bytes;
+	int new_str_len_count;
+	int str_len_bytes;
+	size_t str_len_count;
+	int cx_bytes;
+	RECONVERTSTRING *pReconv;
+	const void *comp_ptr;
+	size_t complen_count;
+	size_t complen_bytes;
+	const void *buf;
+	size_t st_size;
+	char *newbuf;
+
+	buf = str_ptr;
+	str_len_count = str_count;
+
+	if(unicode) {
+		str_len_bytes = str_len_count * sizeof(wchar_t);
+		cx_bytes = cx * sizeof(wchar_t);
+	} else {
+		str_len_bytes = str_len_count;
+		cx_bytes = cx;
+	}
+
+	// \x95ϊ\xB7\x92\x86\x8C\xF3\x95╶\x8E\x9A\x97\xF1\x82\xF0\x8E擾
+	// ATOK2012\x82ł͏\xED\x82\xC9 complen_count=0 \x82ƂȂ\xE9\x81B
+	if (!unicode) {
+		const char *comp_strA;
+		comp_strA = GetConvStringA_i(hWnd, GCS_COMPSTR, &complen_count);
+		complen_bytes = complen_count;
+		comp_ptr = comp_strA;
+	} else {
+		const wchar_t *comp_strW;
+		comp_strW = GetConvStringW_i(hWnd,GCS_COMPSTR,	&complen_count);
+		complen_bytes = complen_count * sizeof(wchar_t);
+		comp_ptr = comp_strW;
+	}
+
+	// \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null)
+	if (!unicode) {
+		new_str_len_bytes = str_len_bytes + complen_bytes;
+		new_buf_len_bytes = new_str_len_bytes + 1;
+		new_str_len_count = new_str_len_bytes;
+	} else {
+		new_str_len_bytes = str_len_bytes + complen_bytes;
+		new_buf_len_bytes = new_str_len_bytes + sizeof(wchar_t);
+		new_str_len_count = new_str_len_bytes / sizeof(wchar_t);
+	}
+
+	st_size = sizeof(RECONVERTSTRING) + new_buf_len_bytes;
+	pReconv = calloc(1, st_size);
+
+	// Len\x82͕\xB6\x8E\x9A\x90\x94(char/wchar_t\x92P\x88\xCA)
+	// Offset\x82\xCDbyte\x92P\x88\xCA
+//	pReconv->dwSize				= sizeof(RECONVERTSTRING);
+	pReconv->dwSize				= sizeof(RECONVERTSTRING) + new_buf_len_bytes;
+	pReconv->dwVersion			= 0;
+	pReconv->dwStrLen			= new_str_len_count;
+	pReconv->dwStrOffset		= sizeof(RECONVERTSTRING);
+	pReconv->dwCompStrLen		= complen_count;
+	pReconv->dwCompStrOffset	= cx_bytes;
+	pReconv->dwTargetStrLen		= complen_count;		// = dwCompStrOffset
+	pReconv->dwTargetStrOffset	= cx_bytes;				// = dwTargetStrLen
+
+	// RECONVERTSTRING\x82̌\xE3\x82\xEB\x82\xC9
+	// \x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82\xF0\x83R\x83s\x81[+\x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɕϕ\xB6\x8E\x9A\x97\xF1\x82\xF0\x91}\x93\xFC
+	newbuf = (char *)pReconv + sizeof(RECONVERTSTRING);
+	if (comp_ptr != NULL) {
+		memcpy(newbuf, buf, cx_bytes);
+		newbuf += cx_bytes;
+		memcpy(newbuf, comp_ptr, complen_bytes);
+		newbuf += complen_bytes;
+		memcpy(newbuf, (char *)buf + cx_bytes, str_len_bytes - cx_bytes);
+		free((void *)comp_ptr);
+		comp_ptr = NULL;
+	} else {
+		memcpy(newbuf, buf, str_len_bytes);
+	}
+#if defined(ENABLE_DUMP)
+	DumpReconvStringSt(pReconv, unicode);
+#endif
+
+	*st_size_ = st_size;
+	return pReconv;
+}
+
+/**
+ * IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x97p\x8D\\x91\xA2\x91̂\xF0\x8D쐬\x82\xB7\x82\xE9
+ * ANSI\x83E\x83B\x83\x93\x83h\x83E\x97p
+ *		msg == WM_IME_REQUEST,wParam == IMR_DOCUMENTFEED \x82̉\x9E\x93\x9A\x82Ɏg\x82\xA4
+ * str_ptr		\x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ * str_count	\x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82̕\xB6\x8E\x9A\x90\x94(char\x90\x94,bytes\x90\x94)
+ * cx			\x83J\x81[\x83\\x83\x8B\x88ʒu(char\x92P\x88\xCA)
+ * st_size		\x90\xB6\x90\xAC\x82\xB5\x82\xBD\x8D\\x91\xA2\x91̂̃T\x83C\x83Y(byte)
+ * \x96߂\xE8\x92l		\x8D\\x91\xA2\x91̂ւ̃|\x83C\x83\x93\x83^
+ *				\x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7 free()\x82\xB7\x82邱\x82\xC6
+ */
+void *CreateReconvStringStA(
+	HWND hWnd, const char *str_ptr, size_t str_count,
+	size_t cx, size_t *st_size_)
+{
+	assert(IsWindowUnicode(hWnd) == FALSE);
+	return CreateReconvStringSt(hWnd, FALSE, str_ptr, str_count, cx, st_size_);
+}
+
+/**
+ * IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x97p\x8D\\x91\xA2\x91̂\xF0\x8D쐬\x82\xB7\x82\xE9
+ * unicode\x83E\x83B\x83\x93\x83h\x83E\x97p
+ *		msg == WM_IME_REQUEST,wParam == IMR_DOCUMENTFEED \x82̉\x9E\x93\x9A\x82Ɏg\x82\xA4
+ * str_ptr		\x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ * str_count	\x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82̕\xB6\x8E\x9A\x90\x94(wchar_t\x90\x94)
+ * cx			\x83J\x81[\x83\\x83\x8B\x88ʒu(wchar_t\x92P\x88\xCA)
+ * st_size		\x90\xB6\x90\xAC\x82\xB5\x82\xBD\x8D\\x91\xA2\x91̂̃T\x83C\x83Y(byte)
+ * \x96߂\xE8\x92l		\x8D\\x91\xA2\x91̂ւ̃|\x83C\x83\x93\x83^
+ *				\x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7 free()\x82\xB7\x82邱\x82\xC6
+ */
+void *CreateReconvStringStW(
+	HWND hWnd, const wchar_t *str_ptr, size_t str_count,
+	size_t cx, size_t *st_size_)
+{
+	assert(IsWindowUnicode(hWnd) == TRUE);
+	return CreateReconvStringSt(hWnd, TRUE, str_ptr, str_count, cx, st_size_);
+}

Modified: branches/cmake/teraterm/teraterm/ttime.h
===================================================================
--- branches/cmake/teraterm/teraterm/ttime.h	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/ttime.h	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,19 +34,22 @@
 #endif
 
 /* proto types */
-BOOL LoadIME();
-void FreeIME();
-BOOL CanUseIME();
-void SetConversionWindow(HWND HWin, int X, int Y);
-void SetConversionLogFont(HWND HWin, PLOGFONTA lf);
-BOOL GetIMEOpenStatus(void);
-void SetIMEOpenStatus(BOOL stat);
-const wchar_t *GetConvString(HWND hWnd, UINT wParam, LPARAM lParam, size_t *len);
+BOOL LoadIME(void);
+void FreeIME(HWND hWnd);
+BOOL CanUseIME(void);
+void SetConversionWindow(HWND HWnd, int X, int Y);
+void SetConversionLogFont(HWND HWnd, PLOGFONTA lf);
+BOOL GetIMEOpenStatus(HWND hWnd);
+void SetIMEOpenStatus(HWND hWnd, BOOL stat);
+const wchar_t *GetConvStringW(HWND hWnd, LPARAM lParam, size_t *len);
+//const char *GetConvStringA(HWND hWnd, LPARAM lParam, size_t *len);
+void *CreateReconvStringStW(HWND hWnd,
+							const wchar_t *str_ptr, size_t str_count,
+							size_t cx, size_t *st_size_);
+void *CreateReconvStringStA(HWND hWnd,
+							const char *str_ptr, size_t str_count,
+							size_t cx, size_t *st_size_);
 
-#ifndef WM_IME_COMPOSITION
-#define WM_IME_COMPOSITION              0x010F
-#endif
-
 #ifdef __cplusplus
 }
 #endif

Modified: branches/cmake/teraterm/teraterm/ttwsk.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttwsk.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/ttwsk.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: branches/cmake/teraterm/teraterm/vtdisp.c
===================================================================
--- branches/cmake/teraterm/teraterm/vtdisp.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/vtdisp.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -2032,9 +2032,15 @@
 	if ((ts.Language==IdJapanese) || (ts.Language==IdKorean) || (ts.Language==IdUtf8)) //HKS
 	{
 		if (ts.UseIME==0)
-			FreeIME();
-		else if (! LoadIME())
+			FreeIME(HVTWin);
+		else if (! LoadIME()) {
+			char uimsg[MAX_UIMSG];
+			get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg),  "Tera Term: Error", ts.UILanguageFile);
+			get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile);
+			MessageBoxA(0,ts.UIMsg,uimsg,MB_ICONEXCLAMATION);
+			WritePrivateProfileStringA("Tera Term","IME","off",ts.SetupFName);
 			ts.UseIME = 0;
+		}
 
 		if (ts.UseIME>0)
 		{
@@ -2048,7 +2054,7 @@
 		}
 	}
 	else
-		FreeIME();
+		FreeIME(HVTWin);
 
 	if (IsCaretOn()) CaretOn();
 }

Modified: branches/cmake/teraterm/teraterm/vtterm.c
===================================================================
--- branches/cmake/teraterm/teraterm/vtterm.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/vtterm.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -2645,19 +2645,19 @@
 	switch (b) {
 	  case 'r':
 		if (CanUseIME()) {
-			SetIMEOpenStatus(IMEstat);
+			SetIMEOpenStatus(HVTWin, IMEstat);
 		}
 		break;
 
 	  case 's':
 		if (CanUseIME()) {
-			IMEstat = GetIMEOpenStatus();
+			IMEstat = GetIMEOpenStatus(HVTWin);
 		}
 		break;
 
 	  case 't':
 		if (CanUseIME()) {
-			SetIMEOpenStatus(Param[1] == 1);
+			SetIMEOpenStatus(HVTWin, Param[1] == 1);
 		}
 		break;
 	}

Modified: branches/cmake/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/vtwin.cpp	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/teraterm/teraterm/vtwin.cpp	2019-03-18 13:57:53 UTC (rev 7495)
@@ -72,6 +72,7 @@
 #include <windowsx.h>
 #include <imm.h>
 #include <dbt.h>
+#include <assert.h>
 
 #include "tt_res.h"
 #include "vtwin.h"
@@ -136,6 +137,10 @@
 
 static int AutoDisconnectedPort = -1;
 
+#ifndef WM_IME_COMPOSITION
+#define WM_IME_COMPOSITION              0x010F
+#endif
+
 /////////////////////////////////////////////////////////////////////////////
 // CVTWindow
 
@@ -1858,7 +1863,7 @@
 
 	OpenHelp(HH_CLOSE_ALL, 0, ts.UILanguageFile);
 
-	FreeIME();
+	FreeIME(HVTWin);
 	FreeTTSET();
 #if 0	// free\x82Ɏ\xB8\x94s\x82\xB7\x82\xE9\x82܂\xC5free\x82\xB5\x91\xB1\x82\xAF\x82\xE9
 	do { }
@@ -3120,24 +3125,25 @@
 {
 	if (CanUseIME()) {
 		size_t len;
-		const wchar_t *lpstr = GetConvString(HVTWin, wParam, lParam, &len);
+		const wchar_t *lpstr = GetConvStringW(HVTWin, lParam, &len);
 		if (lpstr != NULL) {
+			const wchar_t *output_wstr = lpstr;
 			if (len == 1 && ControlKey()) {
 				const static wchar_t code_ctrl_space = 0;
 				const static wchar_t code_ctrl_backslash = 0x1c;
 				switch(*lpstr) {
 				case 0x20:
-					lpstr = &code_ctrl_space;
+					output_wstr = &code_ctrl_space;
 					break;
 				case 0x5c: // Ctrl-\ support for NEC-PC98
-					lpstr = &code_ctrl_backslash;
+					output_wstr = &code_ctrl_backslash;
 					break;
 				}
 			}
 			if (ts.LocalEcho>0) {
-				CommTextEchoW(&cv,lpstr,len);
+				CommTextEchoW(&cv,output_wstr,len);
 			}
-			CommTextOutW(&cv,lpstr,len);
+			CommTextOutW(&cv,output_wstr,len);
 			free((void *)lpstr);
 			return 0;
 		}
@@ -3159,7 +3165,7 @@
 		// \x93\xFC\x97̓R\x83\x93\x83e\x83L\x83X\x83g\x82̊J\x95\xF3\x91Ԃ\xAA\x8DX\x90V\x82\xB3\x82\xEA\x82\xE9(IME On/OFF)
 
 		// IME\x82\xCCOn/Off\x82\xF0\x8E擾\x82\xB7\x82\xE9
-		IMEstat = GetIMEOpenStatus();
+		IMEstat = GetIMEOpenStatus(HVTWin);
 
 		// \x8F\xF3\x91Ԃ\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9IME\x82̂\xBD\x82߂Ɉʒu\x82\xF0\x92ʒm\x82\xB7\x82\xE9
 		int CaretX = (CursorX-WinOrgX)*FontWidth;
@@ -3197,73 +3203,78 @@
 	return CFrameWnd::DefWindowProc(WM_IME_NOTIFY,wParam,lParam);
 }
 
-// IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x82ւ̑Ή\x9E
-// MS\x82\xA9\x82炿\x82\xE1\x82\xF1\x82Ǝd\x97l\x82\xAA\x92񎦂\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x82̂ŁA\x83A\x83h\x83z\x83b\x83N\x82ɂ\xE2\x82邵\x82\xA9\x82Ȃ\xA2\x82炵\x82\xA2\x81B
-// cf. http://d.hatena.ne.jp/topiyama/20070703
-//     http://ice.hotmint.com/putty/#DOWNLOAD
-//     http://27213143.at.webry.info/201202/article_2.html
-//     http://webcache.googleusercontent.com/search?q=cache:WzlX3ouMscIJ:anago.2ch.net/test/read.cgi/software/1325573999/82+IMR_DOCUMENTFEED&cd=13&hl=ja&ct=clnk&gl=jp
-// (2012.5.9 yutaka)
-LRESULT CVTWindow::OnIMERequest(WPARAM wParam, LPARAM lParam)
+static LRESULT ReplyIMERequestDocumentfeed(HWND hWnd, LPARAM lParam)
 {
-	static int complen, newsize;
-	static char comp[512];
-	int size, ret;
-	char buf[512], newbuf[1024];
-	HIMC hIMC;
+	static RECONVERTSTRING *pReconvPtrSave;		// TODO leak
+	static size_t ReconvSizeSave;
+	LRESULT result;
 
-	// "IME=off"\x82̏ꍇ\x82́A\x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x81B
-	if (ts.UseIME > 0 &&
-		wParam == IMR_DOCUMENTFEED) {
-		size = NumOfColumns + 1;   // \x83J\x81[\x83\\x83\x8B\x82\xAA\x82\xA0\x82\xE9\x8Ds\x82̒\xB7\x82\xB3+null
+	if (lParam == 0)
+	{  // 1\x89\xF1\x96ڂ̌Ăяo\x82\xB5 \x83T\x83C\x83Y\x82\xBE\x82\xAF\x82\xF0\x95Ԃ\xB7
+		char buf[512];			// \x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x82\xF0\x8E󂯎\xE6\x82\xE9\x83o\x83b\x83t\x83@
+		size_t str_len_count;
+		int cx;
+		assert(IsWindowUnicode(hWnd) == FALSE);
 
-		if (lParam == 0) {  // 1\x89\xF1\x96ڂ̌Ăяo\x82\xB5
-			// \x83o\x83b\x83t\x83@\x82̃T\x83C\x83Y\x82\xF0\x95Ԃ\xB7\x82̂݁B
-			// ATOK2012\x82ł͏\xED\x82\xC9 complen=0 \x82ƂȂ\xE9\x81B
-			complen = 0;
-			memset(comp, 0, sizeof(comp));
-			hIMC = ImmGetContext(HVTWin);
-			if (hIMC) {
-				// TODO \x82\xA2\x82\xAB\x82Ȃ\xE8\x83C\x83\x93\x83|\x81[\x83g\x82\xB5\x82Ă\xA2\x82\xE9
-				ret = ImmGetCompositionStringA(hIMC, GCS_COMPSTR, comp, sizeof(comp));
-				if (ret == IMM_ERROR_NODATA || ret == IMM_ERROR_GENERAL) {
-					memset(comp, 0, sizeof(comp));
+		// \x8EQ\x8Fƕ\xB6\x8E\x9A\x97\xF1\x8E擾\x81A1\x8Ds\x8E\xE6\x82\xE8\x8Fo\x82\xB7
+		{	// \x83J\x81[\x83\\x83\x8B\x82\xA9\x82\xE7\x8C\xE3\x82\xEB\x81A\x83X\x83y\x81[\x83X\x88ȊO\x82\xAA\x8C\xA9\x82‚\xA9\x82\xC1\x82\xBD\x82Ƃ\xB1\x82\xEB\x82\xF0\x8Ds\x96\x96\x82Ƃ\xB7\x82\xE9
+			int x;
+			int len;
+			cx = BuffGetCurrentLineData(buf, sizeof(buf));
+			len = cx;
+			for (x=cx; x < NumOfColumns; x++) {
+				const char c = buf[x];
+				if (c != 0 && c != 0x20) {
+					len = x+1;
 				}
-				complen = strlen(comp);  // w/o null
-				ImmReleaseContext(HVTWin, hIMC);
 			}
-			newsize = size + complen;  // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null)
+			str_len_count = len;
+		}
 
-		} else {  // 2\x89\xF1\x96ڂ̌Ăяo\x82\xB5
-			//lParam \x82\xF0 RECONVERTSTRING \x82\xC6 \x95\xB6\x8E\x9A\x97\xF1\x8Ai\x94[\x83o\x83b\x83t\x83@\x82Ɏg\x97p\x82\xB7\x82\xE9
-			RECONVERTSTRING *pReconv   = (RECONVERTSTRING*)lParam;
-			char*  pszParagraph        = (char*)pReconv + sizeof(RECONVERTSTRING);
-			int cx;
+		// IME\x82ɕԂ\xB7\x8D\\x91\xA2\x91̂\xF0\x8D쐬\x82\xB7\x82\xE9
+		if (pReconvPtrSave != NULL) {
+			free(pReconvPtrSave);
+		}
+		pReconvPtrSave = (RECONVERTSTRING *)CreateReconvStringStA(
+			hWnd, buf, str_len_count, cx, &ReconvSizeSave);
 
-			cx = BuffGetCurrentLineData(buf, sizeof(buf));
+		// 1\x89\xF1\x96ڂ̓T\x83C\x83Y\x82\xBE\x82\xAF\x82\xF0\x95Ԃ\xB7
+		result = ReconvSizeSave;
+	}
+	else {
+		// 2\x89\xF1\x96ڂ̌Ăяo\x82\xB5 \x8D\\x91\xA2\x91̂\xF0\x93n\x82\xB7
+		if (pReconvPtrSave != NULL) {
+			RECONVERTSTRING *pReconv = (RECONVERTSTRING*)lParam;
+			memcpy(pReconv, pReconvPtrSave, ReconvSizeSave);
+			result = ReconvSizeSave;
+			free(pReconvPtrSave);
+			pReconvPtrSave = NULL;
+			ReconvSizeSave = 0;
+		} else {
+			// 3\x89\xF1\x96\xDA?
+			result = 0;
+		}
+	}
 
-			// \x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɕϊ\xB7\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x91}\x93\xFC\x82\xB7\x82\xE9\x81B
-			memset(newbuf, 0, sizeof(newbuf));
-			memcpy(newbuf, buf, cx);
-			memcpy(newbuf + cx, comp, complen);
-			memcpy(newbuf + cx + complen, buf + cx, size - cx);
-			newsize = size + complen;  // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null)
+#if 0
+	OutputDebugPrintf("WM_IME_REQUEST,IMR_DOCUMENTFEED lp=%p LRESULT %d\n",
+		lParam, result);
+#endif
 
-			pReconv->dwSize            = sizeof(RECONVERTSTRING);
-			pReconv->dwVersion         = 0;
-			pReconv->dwStrLen          = newsize - 1;
-			pReconv->dwStrOffset       = sizeof(RECONVERTSTRING);
-			pReconv->dwCompStrLen      = complen;
-			pReconv->dwCompStrOffset   = cx;
-			pReconv->dwTargetStrLen    = complen;
-			pReconv->dwTargetStrOffset = cx;
+	return result;
+}
 
-			memcpy(pszParagraph, newbuf, newsize);
-			//OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf);
+LRESULT CVTWindow::OnIMERequest(WPARAM wParam, LPARAM lParam)
+{
+	// "IME=off"\x82̏ꍇ\x82́A\x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x81B
+	if (ts.UseIME > 0) {
+		switch(wParam) {
+		case IMR_DOCUMENTFEED:
+			return ReplyIMERequestDocumentfeed(HVTWin, lParam);
+		default:
+			break;
 		}
-		return (sizeof(RECONVERTSTRING) + newsize);
 	}
-
 	return CFrameWnd::DefWindowProc(WM_IME_REQUEST,wParam,lParam);
 }
 

Modified: branches/cmake/ttssh2/ttxssh/auth.c
===================================================================
--- branches/cmake/ttssh2/ttxssh/auth.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/ttssh2/ttxssh/auth.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1190,6 +1190,10 @@
 					   pvar->auth_state.TIS_prompt);
 		destroy_malloced_string(&pvar->auth_state.TIS_prompt);
 	}
+
+	if (pvar->auth_state.echo) {
+		SendMessage(GetDlgItem(dlg, IDC_SSHPASSWORD), EM_SETPASSWORDCHAR, 0, 0);
+	}
 }
 
 static BOOL end_TIS_dlg(PTInstVar pvar, HWND dlg)
@@ -1541,6 +1545,7 @@
 	pvar->auth_state.user = NULL;
 	pvar->auth_state.flags = 0;
 	pvar->auth_state.TIS_prompt = NULL;
+	pvar->auth_state.echo = 0;
 	pvar->auth_state.supported_types = 0;
 	pvar->auth_state.cur_cred.method = SSH_AUTH_NONE;
 	pvar->auth_state.cur_cred.password = NULL;
@@ -1555,7 +1560,7 @@
 	destroy_malloced_string(&pvar->auth_state.TIS_prompt);
 }
 
-void AUTH_set_TIS_mode(PTInstVar pvar, char *prompt, int len)
+void AUTH_set_TIS_mode(PTInstVar pvar, char *prompt, int len, int echo)
 {
 	if (pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
 		pvar->auth_state.mode = TIS_AUTH_MODE;
@@ -1564,6 +1569,7 @@
 		pvar->auth_state.TIS_prompt = malloc(len + 1);
 		memcpy(pvar->auth_state.TIS_prompt, prompt, len);
 		pvar->auth_state.TIS_prompt[len] = 0;
+		pvar->auth_state.echo = echo;
 	} else {
 		AUTH_set_generic_mode(pvar);
 	}

Modified: branches/cmake/ttssh2/ttxssh/auth.h
===================================================================
--- branches/cmake/ttssh2/ttxssh/auth.h	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/ttssh2/ttxssh/auth.h	2019-03-18 13:57:53 UTC (rev 7495)
@@ -56,6 +56,7 @@
 
   AuthMode mode;
   char *TIS_prompt;
+  int echo;
 } AUTHState;
 
 void AUTH_init(PTInstVar pvar);
@@ -62,7 +63,7 @@
 char *AUTH_get_user_name(PTInstVar pvar);
 int AUTH_set_supported_auth_types(PTInstVar pvar, int types);
 void AUTH_set_generic_mode(PTInstVar pvar);
-void AUTH_set_TIS_mode(PTInstVar pvar, char *prompt, int len);
+void AUTH_set_TIS_mode(PTInstVar pvar, char *prompt, int len, int echo);
 void AUTH_advance_to_next_cred(PTInstVar pvar);
 void AUTH_do_cred_dialog(PTInstVar pvar);
 void AUTH_do_default_cred_dialog(PTInstVar pvar);

Modified: branches/cmake/ttssh2/ttxssh/ssh.c
===================================================================
--- branches/cmake/ttssh2/ttxssh/ssh.c	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/ttssh2/ttxssh/ssh.c	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1502,7 +1502,7 @@
 		if (grab_payload(pvar, len)) {
 			logputs(LOG_LEVEL_VERBOSE, "Received TIS challenge");
 
-			AUTH_set_TIS_mode(pvar, pvar->ssh_state.payload + 4, len);
+			AUTH_set_TIS_mode(pvar, pvar->ssh_state.payload + 4, len, 0);
 			AUTH_advance_to_next_cred(pvar);
 			pvar->ssh_state.status_flags &= ~STATUS_DONT_SEND_CREDENTIALS;
 			try_send_credentials(pvar);
@@ -7332,7 +7332,7 @@
 		// keyboard-interactive method (2005.3.12 yutaka)
 		if (pvar->keyboard_interactive_password_input == 0 &&
 			pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
-			AUTH_set_TIS_mode(pvar, prompt, slen);
+			AUTH_set_TIS_mode(pvar, prompt, slen, echo);
 			AUTH_advance_to_next_cred(pvar);
 			pvar->ssh_state.status_flags &= ~STATUS_DONT_SEND_CREDENTIALS;
 			//try_send_credentials(pvar);
@@ -7457,7 +7457,7 @@
 		finish_send_packet(pvar);
 		buffer_free(msg);
 
-		logputs(LOG_LEVEL_VERBOSE, "SSH2_MSG_USERAUTH_REQUEST was sent at handle_SSH2_userauth_inforeq().");
+		logputs(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_USERAUTH_REQUEST method=publickey");
 
 		pvar->pageant_keyfinal = TRUE;
 

Modified: branches/cmake/ttssh2/ttxssh/ttxssh.h
===================================================================
--- branches/cmake/ttssh2/ttxssh/ttxssh.h	2019-03-18 13:57:37 UTC (rev 7494)
+++ branches/cmake/ttssh2/ttxssh/ttxssh.h	2019-03-18 13:57:53 UTC (rev 7495)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 1998-2001, Robert O'Callahan
- * (C) 2004-2017 TeraTerm Project
+ * (C) 2004-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without


Ttssh2-commit メーリングリストの案内
アーカイブの一覧に戻る