[ttssh2-commit] [9858] ログフォルダをUnicode化

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 4月 12日 (火) 22:21:37 JST


Revision: 9858
          https://osdn.net/projects/ttssh2/scm/svn/commits/9858
Author:   zmatsuo
Date:     2022-04-12 22:21:35 +0900 (Tue, 12 Apr 2022)
Log Message:
-----------
ログフォルダをUnicode化

- 端末に流れる文字のログのフォルダ
  - 動作ログではない
  - [file]/[log]メニューのログ
- 修正前は ANSI文字列で、MAX_PATH長だった
- 設定ダイアログ、iniファイルの読み書きも修正

Modified Paths:
--------------
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/addsetting.cpp
    trunk/teraterm/teraterm/filesys_log.cpp
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2022-04-12 13:21:21 UTC (rev 9857)
+++ trunk/teraterm/common/tttypes.h	2022-04-12 13:21:35 UTC (rev 9858)
@@ -504,7 +504,7 @@
 	WORD LogTypePlainText;
 	WORD LogTimestamp;
 	char LogDefaultName[80];
-	char LogDefaultPath[MAX_PATH];
+	wchar_t *LogDefaultPathW;	// \x83\x8D\x83O\x83t\x83H\x83\x8B\x83_([file]/[log]\x83\x81\x83j\x83\x85\x81[\x82̃\x8D\x83O)
 	WORD LogAutoStart;
 	unsigned int PasteFlag;
 	WORD FallbackToCP932;	// ConfirmPasteMouseRButton \x82\xAA\x94p\x8E~\x82ɂȂ\xC1\x82\xBD\x82̂œ]\x97p

Modified: trunk/teraterm/teraterm/addsetting.cpp
===================================================================
--- trunk/teraterm/teraterm/addsetting.cpp	2022-04-12 13:21:21 UTC (rev 9857)
+++ trunk/teraterm/teraterm/addsetting.cpp	2022-04-12 13:21:35 UTC (rev 9858)
@@ -1317,7 +1317,7 @@
 	SetDlgItemTextA(IDC_DEFAULTNAME_EDITOR, ts.LogDefaultName);
 
 	// Log Default File Path (2007.5.30 maya)
-	SetDlgItemTextA(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath);
+	SetDlgItemTextW(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPathW);
 
 	/* Auto start logging (2007.5.31 maya) */
 	SetCheck(IDC_AUTOSTART, ts.LogAutoStart);
@@ -1425,14 +1425,18 @@
 			// \x83\x8D\x83O\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82̑I\x91\xF0\x83_\x83C\x83A\x83\x8D\x83O
 			{
 				wchar_t *title = TTGetLangStrW("Tera Term", "FILEDLG_SELECT_LOGDIR_TITLE", L"Select log folder", ts.UILanguageFile);
-				wchar_t *buf;
-				hGetDlgItemTextW(m_hWnd, IDC_DEFAULTPATH_EDITOR, &buf);
-				wchar_t *buf2;
-				if (doSelectFolderW(GetSafeHwnd(), buf, title, &buf2)) {
-					SetDlgItemTextW(IDC_DEFAULTPATH_EDITOR, buf2);
-					free(buf2);
+				wchar_t *default_path;
+				hGetDlgItemTextW(m_hWnd, IDC_DEFAULTPATH_EDITOR, &default_path);
+				if (default_path[0] == 0) {
+					free(default_path);
+					default_path = _wcsdup(ts.LogDirW);
 				}
-				free(buf);
+				wchar_t *new_path;
+				if (doSelectFolderW(GetSafeHwnd(), default_path, title, &new_path)) {
+					SetDlgItemTextW(IDC_DEFAULTPATH_EDITOR, new_path);
+					free(new_path);
+				}
+				free(default_path);
 				free(title);
 			}
 
@@ -1534,7 +1538,8 @@
 	strncpy_s(ts.LogDefaultName, sizeof(ts.LogDefaultName), buf, _TRUNCATE);
 
 	// Log Default File Path (2007.5.30 maya)
-	GetDlgItemTextA(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath, _countof(ts.LogDefaultPath));
+	free(ts.LogDefaultPathW);
+	hGetDlgItemTextW(m_hWnd, IDC_DEFAULTPATH_EDITOR, &ts.LogDefaultPathW);
 
 	/* Auto start logging (2007.5.31 maya) */
 	ts.LogAutoStart = GetCheck(IDC_AUTOSTART);

Modified: trunk/teraterm/teraterm/filesys_log.cpp
===================================================================
--- trunk/teraterm/teraterm/filesys_log.cpp	2022-04-12 13:21:21 UTC (rev 9857)
+++ trunk/teraterm/teraterm/filesys_log.cpp	2022-04-12 13:21:35 UTC (rev 9858)
@@ -608,9 +608,8 @@
 			ofn.lpstrFile = fname;
 			ofn.nMaxFile = _countof(fname);
 			ofn.lpstrTitle = caption;
-			ofn.lpstrInitialDir = ToWcharA(work->pts->LogDefaultPath);
+			ofn.lpstrInitialDir = work->pts->LogDefaultPathW;
 			BOOL Ok = GetSaveFileNameW(&ofn);
-			free((void *)ofn.lpstrInitialDir);
 			free(caption);
 			free(FNFilter);
 			if (Ok) {
@@ -1354,15 +1353,8 @@
  */
 wchar_t *FLogGetLogFilename(const wchar_t *log_filename)
 {
-	char *logdir;
+	const char *logdir = ToCharW(ts.LogDefaultPathW);
 
-	if (strlen(ts.LogDefaultPath) > 0) {
-		logdir = _strdup(ts.LogDefaultPath);
-	}
-	else {
-		logdir = ToCharW(ts.LogDirW);
-	}
-
 	// \x8C\xB3\x82ƂȂ\xE9\x83t\x83@\x83C\x83\x8B\x96\xBC
 	char base_name[MAX_PATH];
 	if (log_filename == NULL) {
@@ -1380,7 +1372,7 @@
 	ParseStrftimeFileName(full_path, sizeof(full_path));
 	ConvertLogname(full_path, sizeof(full_path));
 
-	free(logdir);
+	free((void *)logdir);
 	return ToWcharA(full_path);
 }
 

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2022-04-12 13:21:21 UTC (rev 9857)
+++ trunk/teraterm/ttpset/ttset.c	2022-04-12 13:21:35 UTC (rev 9858)
@@ -1266,10 +1266,13 @@
 	                        ts->LogDefaultName, sizeof(ts->LogDefaultName),
 	                        FName);
 
-	/* Default Log file path (2007.5.30 maya) */
-	GetPrivateProfileString(Section, "LogDefaultPath", "",
-	                        ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
-	                        FName);
+	/* Default Log file path */
+	hGetPrivateProfileStringW(SectionW, L"LogDefaultPath", ts->LogDirW, FName, &ts->LogDefaultPathW);
+	if (ts->LogDefaultPathW[0] == 0) {
+		// \x96\xA2\x8Ew\x92\xE8("LogDefaultPath=")\x82\xBE\x82\xC1\x82\xBD\x81A\x83f\x83t\x83H\x83\x8B\x83g\x92l\x82\xF0\x93\xFC\x82\xEA\x82Ă\xA8\x82\xAD
+		free(ts->LogDefaultPathW);
+		ts->LogDefaultPathW = _wcsdup(ts->LogDirW);
+	}
 
 	/* Auto start logging (2007.5.31 maya) */
 	ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
@@ -2746,9 +2749,12 @@
 	WritePrivateProfileString(Section, "LogDefaultName",
 	                          ts->LogDefaultName, FName);
 
-	/* Default Log file path (2007.5.30 maya) */
-	WritePrivateProfileString(Section, "LogDefaultPath",
-	                          ts->LogDefaultPath, FName);
+	/* Default Log file path */
+	if (wcscmp(ts->LogDefaultPathW, ts->LogDirW) != 0) {
+		// \x88قȂ\xC1\x82Ă\xA2\x82\xE9\x82Ƃ\xAB\x81A\x83t\x83H\x83\x8B\x83_\x82\xF0\x8Ew\x92肵\x82Ă\xE9
+		WritePrivateProfileStringW(SectionW, L"LogDefaultPath",
+								   ts->LogDefaultPathW, FName);
+	}
 
 	/* Auto start logging (2007.5.31 maya) */
 	WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);


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