[Ttssh2-commit] [8881] コメントの書き込みを Unicode 化した

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 8月 6日 (木) 00:06:45 JST


Revision: 8881
          https://osdn.net/projects/ttssh2/scm/svn/commits/8881
Author:   zmatsuo
Date:     2020-08-06 00:06:45 +0900 (Thu, 06 Aug 2020)
Log Message:
-----------
コメントの書き込みを Unicode 化した

- FLogWriteStr()

Modified Paths:
--------------
    branches/filesys_log/teraterm/teraterm/filesys_log.cpp
    branches/filesys_log/teraterm/teraterm/filesys_log.h
    branches/filesys_log/teraterm/teraterm/ttdde.c

-------------- next part --------------
Modified: branches/filesys_log/teraterm/teraterm/filesys_log.cpp
===================================================================
--- branches/filesys_log/teraterm/teraterm/filesys_log.cpp	2020-08-05 15:06:37 UTC (rev 8880)
+++ branches/filesys_log/teraterm/teraterm/filesys_log.cpp	2020-08-05 15:06:45 UTC (rev 8881)
@@ -114,8 +114,8 @@
 static void LogBinSkip(int add);
 static BOOL CreateLogBuf(void);
 static BOOL CreateBinBuf(void);
+void LogPut1(BYTE b);
 
-
 static BOOL OpenFTDlg_(PFileVar fv)
 {
 	PFileTransDlg FTDlg = new CFileTransDlg();
@@ -852,30 +852,6 @@
 	LeaveCriticalSection(&g_filelog_lock);
 }
 
- // \x83R\x83\x81\x83\x93\x83g\x82\xF0\x83\x8D\x83O\x82֒lj\xC1\x82\xB7\x82\xE9
-static void CommentLogToFile(char *buf, int size)
-{
-	DWORD wrote;
-
-	if (LogVar == NULL) {
-		char uimsg[MAX_UIMSG];
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_COMMENT_LOG_OPEN_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "It is not opened by the log file yet.", ts.UILanguageFile);
-		::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK|MB_ICONEXCLAMATION);
-		return;
-	}
-
-	logfile_lock();
-	WriteFile(LogVar->FileHandle, buf, size, &wrote, NULL);
-	WriteFile(LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // \x89\xFC\x8Ds
-	/* Set Line End Flag
-		2007.05.24 Gentaro
-	*/
-	LogVar->eLineEnd = Line_LineHead;
-	logfile_unlock();
-}
-
 // \x83\x8D\x83O\x82\xF0\x83\x8D\x81[\x83e\x81[\x83g\x82\xB7\x82\xE9\x81B
 // (2013.3.21 yutaka)
 static void LogRotate(void)
@@ -1244,13 +1220,13 @@
 		case WM_COMMAND:
 			switch (LOWORD(wp)) {
 				case IDOK: {
-					char buf[256];
-					memset(buf, 0, sizeof(buf));
-					ret = GetDlgItemTextA(hDlgWnd, IDC_EDIT_COMMENT, buf, sizeof(buf) - 1);
-					if (ret > 0) { // \x83e\x83L\x83X\x83g\x8E擾\x90\xAC\x8C\xF7
-						//buf[sizeof(buf) - 1] = '\0';  // null-terminate
-						CommentLogToFile(buf, ret);
-					}
+					size_t len = _SendDlgItemMessageW(hDlgWnd, IDC_EDIT_COMMENT, WM_GETTEXTLENGTH, 0, 0);
+					wchar_t *buf = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
+					_GetDlgItemTextW(hDlgWnd, IDC_EDIT_COMMENT, buf, len);
+					buf[len] = '\0';  // null-terminate
+					FLogWriteStr(buf);
+					FLogWriteStr(L"\n");		// TODO \x89\xFC\x8Ds\x83R\x81[\x83h
+					free(buf);
 					TTEndDialog(hDlgWnd, IDOK);
 					break;
 				}
@@ -1268,9 +1244,14 @@
 	return TRUE;
 }
 
+/**
+ * \x83\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82փR\x83\x81\x83\x93\x83g\x82\xF0\x92lj\xC1\x82\xB7\x82\xE9 (2004.8.6 yutaka)
+ */
 void FLogAddCommentDlg(HINSTANCE hInst, HWND hWnd)
 {
-	// \x83\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82փR\x83\x81\x83\x93\x83g\x82\xF0\x92lj\xC1\x82\xB7\x82\xE9 (2004.8.6 yutaka)
+	if (LogVar == NULL) {
+		return;
+	}
 	TTDialogBox(hInst, MAKEINTRESOURCE(IDD_COMMENT_DIALOG),
 				HVTWin, OnCommentDlgProc);
 }
@@ -1336,13 +1317,15 @@
 	return LogVar != NULL && BinLog;
 }
 
-void FLogWriteStr(const char *str)
+void FLogWriteStr(const wchar_t *str)
 {
-	if (LogVar != NULL)
-	{
+	if (LogVar != NULL) {
 		DWORD wrote;
-		size_t len = strlen(str);
+		size_t len = wcslen(str)  * sizeof(wchar_t);
+		logfile_lock();
 		WriteFile(LogVar->FileHandle, str, len, &wrote, NULL);
+		LogVar->eLineEnd = Line_LineHead;
+		logfile_unlock();
 		LogVar->ByteCount =
 			LogVar->ByteCount + len;
 		LogVar->FLogDlg->RefreshNum(LogVar->StartTime, LogVar->FileSize, LogVar->ByteCount);
@@ -1562,7 +1545,7 @@
 	BOOL log_available = (cv.HLogBuf != 0);
 
 	if (!log_available) {
-		// \x83\x8D\x83O\x82ɂ͏o\x97͂\xB5\x82Ȃ\xA2(macro\x8Fo\x97͂\xBE\x82\xAF\x82\xBE\x82\xC1\x82\xBD)
+		// \x83\x8D\x83O\x82ɂ͏o\x97͂\xB5\x82Ȃ\xA2
 		return;
 	}
 

Modified: branches/filesys_log/teraterm/teraterm/filesys_log.h
===================================================================
--- branches/filesys_log/teraterm/teraterm/filesys_log.h	2020-08-05 15:06:37 UTC (rev 8880)
+++ branches/filesys_log/teraterm/teraterm/filesys_log.h	2020-08-05 15:06:45 UTC (rev 8881)
@@ -40,26 +40,28 @@
 	BOOL bom;				// TRUE = BOM\x82\xA0\x82\xE8
 	int code;				// 0/1/2 = UTF-8/UTF-16LE/UTF-16BE
 } FLogDlgInfo_t;
+BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info);
+void FLogAddCommentDlg(HINSTANCE hInst, HWND hWnd);
+wchar_t *FLogGetLogFilename(const wchar_t *log_filename);
+
 void logfile_lock_initialize(void);
 void FLogPause(BOOL Pause);
 void FLogRotateSize(size_t size);
 void FLogRotateRotate(int step);
 void FLogRotateHalt(void);
-void FLogAddCommentDlg(HINSTANCE hInst, HWND hWnd);
 void FLogClose(void);
 BOOL FLogOpen(const wchar_t *fname);
 BOOL FLogIsOpend(void);
 BOOL FLogIsOpendText(void);
 BOOL FLogIsOpendBin(void);
-void FLogWriteStr(const char *str);
+void FLogWriteStr(const wchar_t *str);
 void FLogInfo(char *param_ptr, size_t param_len);
 const wchar_t *FLogGetFilename(void);
-BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info);
-wchar_t *FLogGetLogFilename(const wchar_t *log_filename);
 BOOL FLogIsPause(void);
 void FLogWindow(int nCmdShow);
 void FLogShowDlg(void);
 int FLogGetCount(void);
+int FLogGetFreeCount(void);
 void FLogWriteFile(void);
 void FLogPutUTF32(unsigned int u32);
 void FLogSetCode(int code);

Modified: branches/filesys_log/teraterm/teraterm/ttdde.c
===================================================================
--- branches/filesys_log/teraterm/teraterm/ttdde.c	2020-08-05 15:06:37 UTC (rev 8880)
+++ branches/filesys_log/teraterm/teraterm/ttdde.c	2020-08-05 15:06:45 UTC (rev 8881)
@@ -597,9 +597,12 @@
 	case CmdLogStart:
 		FLogPause(FALSE);
 		break;
-	case CmdLogWrite:
-		FLogWriteStr(ParamFileName);
+	case CmdLogWrite: {
+		wchar_t *ParamFileNameW = ToWcharU8(ParamFileName);
+		FLogWriteStr(ParamFileNameW);
+		free(ParamFileNameW);
 		break;
+	}
 	case CmdQVRecv:
 		if ((FileVar==NULL) && NewFileVar(&FileVar))
 		{


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