[Ttssh2-commit] [8364] 行毎の送信でデータが終端されていなくても動作するよう修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 11月 6日 (水) 22:27:52 JST


Revision: 8364
          https://osdn.net/projects/ttssh2/scm/svn/commits/8364
Author:   zmatsuo
Date:     2019-11-06 22:27:51 +0900 (Wed, 06 Nov 2019)
Log Message:
-----------
行毎の送信でデータが終端されていなくても動作するよう修正

Modified Paths:
--------------
    branches/unicode_buf/teraterm/teraterm/sendmem.cpp

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/teraterm/sendmem.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/sendmem.cpp	2019-11-06 13:27:41 UTC (rev 8363)
+++ branches/unicode_buf/teraterm/teraterm/sendmem.cpp	2019-11-06 13:27:51 UTC (rev 8364)
@@ -100,6 +100,21 @@
 	void (*OnPause_)(BOOL paused);
 };
 
+static wchar_t *wcsnchr(const wchar_t *str, size_t len, wchar_t chr)
+{
+	for (size_t i = 0; i < len; ++i) {
+		wchar_t c = *str;
+		if (c == 0) {
+			return NULL;
+		}
+		if (c == chr) {
+			return (wchar_t *)str;
+		}
+		str++;
+	}
+	return NULL;
+}
+
 static void EndPaste()
 {
 	sendmem_work_t *p = sendmem_work;
@@ -272,7 +287,7 @@
 
 		// 1\x8Ds\x8E\xE6\x82\xE8\x8Fo\x82\xB5(\x89\xFC\x8Ds\x83R\x81[\x83h\x82\xCD 0x0a \x82ɐ\xB3\x8BK\x89\xBB\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9)
 		const wchar_t *line_top = (wchar_t *)&p->send_ptr[p->send_index];
-		const wchar_t *line_end = wcschr(line_top, 0x0a);
+		const wchar_t *line_end = wcsnchr(line_top, p->send_left, 0x0a);
 		if (line_end != NULL) {
 			// 0x0a \x82܂ő\x97\x90M
 			send_len = ((line_end - line_top) + 1) * sizeof(wchar_t);
@@ -282,8 +297,10 @@
 			send_len = p->send_left;
 		}
 
-		// \x91\x97\x90M\x82ł\xAB\x82Ȃ\xA2
+		// 1\x8Ds\x82\xAA\x91\x97\x90M\x83o\x83b\x83t\x83@\x82\xE6\x82\xE8\x91傫\x82\xA2
 		if (buff_len < send_len) {
+			// \x91\x97\x90M\x83o\x83b\x83t\x83@\x92\xB7\x82܂Ő؂\xE8\x8Bl\x82߂\xE9
+			send_len = buff_len;
 			return;
 		}
 	}


Ttssh2-commit メーリングリストの案内
Back to archive index