Revision: 11014 https://osdn.net/projects/ttssh2/scm/svn/commits/11014 Author: zmatsuo Date: 2023-10-19 21:51:56 +0900 (Thu, 19 Oct 2023) Log Message: ----------- ログダイアログを整理 - コンパイル時の警告を減らした - 不要変数削除 - グローバル変数への直接アクセスをなくした Modified Paths: -------------- trunk/teraterm/teraterm/logdlg.cpp trunk/teraterm/teraterm/logdlg.h trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/logdlg.cpp =================================================================== --- trunk/teraterm/teraterm/logdlg.cpp 2023-10-19 12:51:47 UTC (rev 11013) +++ trunk/teraterm/teraterm/logdlg.cpp 2023-10-19 12:51:56 UTC (rev 11014) @@ -39,7 +39,6 @@ #include "teraterm.h" #include "tttypes.h" #include "ftdlg.h" -#include "ttwinman.h" #include "ttcommon.h" #include "ttlib.h" #include "dlglib.h" @@ -73,31 +72,31 @@ * \x83_\x83C\x83A\x83\x8D\x83O\x82Őݒ肵\x82\xBD\x92l\x82͈ꎞ\x93I\x82Ȃ\xE0\x82̂\xC5 * \x90ݒ\xE8\x82\xF0\x8F㏑\x82\xAB\x82\xB7\x82\xE9\x82̂͗ǂ\xAD\x82Ȃ\xA2\x82̂ł͂Ȃ\xA2\x82\xBE\x82낤\x82\xA9? */ -static void SetLogFlags(HWND Dialog) +static void SetLogFlags(HWND Dialog, TTTSet *pts) { WORD BinFlag, val; GetRB(Dialog, &BinFlag, IDC_FOPTBIN, IDC_FOPTBIN); - ts.LogBinary = BinFlag; + pts->LogBinary = BinFlag; GetRB(Dialog, &val, IDC_APPEND, IDC_APPEND); - ts.Append = val; + pts->Append = val; if (!BinFlag) { GetRB(Dialog, &val, IDC_PLAINTEXT, IDC_PLAINTEXT); - ts.LogTypePlainText = val; + pts->LogTypePlainText = val; GetRB(Dialog, &val, IDC_TIMESTAMP, IDC_TIMESTAMP); - ts.LogTimestamp = val; + pts->LogTimestamp = val; } GetRB(Dialog, &val, IDC_HIDEDIALOG, IDC_HIDEDIALOG); - ts.LogHideDialog = val; + pts->LogHideDialog = val; GetRB(Dialog, &val, IDC_ALLBUFF_INFIRST, IDC_ALLBUFF_INFIRST); - ts.LogAllBuffIncludedInFirst = val; + pts->LogAllBuffIncludedInFirst = val; - ts.LogTimestampType = (WORD)(GetCurSel(Dialog, IDC_TIMESTAMPTYPE) - 1); + pts->LogTimestampType = (WORD)(GetCurSel(Dialog, IDC_TIMESTAMPTYPE) - 1); } /** @@ -122,8 +121,9 @@ *exist = TRUE; // BOM\x97L\x82\xE8/\x96\xB3\x82\xB5\x83`\x83F\x83b\x83N - FILE *fp = _wfopen(filename, L"rb"); - if (fp != NULL) { + FILE *fp; + errno_t e = _wfopen_s(&fp, filename, L"rb"); + if (e == 0 && fp != NULL) { unsigned char tmp[4]; size_t l = fread(tmp, 1, sizeof(tmp), fp); fclose(fp); @@ -145,6 +145,15 @@ } } +static void CheckLogFile(const wchar_t *filename, LogDlgWork_t *work) +{ + BOOL exist; + int bom; + CheckLogFile(filename, &exist, &bom); + work->file_exist = exist; + work->current_bom = bom; +} + /** * \x83\x89\x83W\x83I\x83{\x83^\x83\x93\x81A\x83t\x83@\x83C\x83\x8B\x82̏\xF3\x91Ԃ\xA9\x82\xE7\x83R\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x82\xF0Enable/Disable\x82\xB7\x82\xE9 */ @@ -227,15 +236,6 @@ } } -static void CheckLogFile(HWND Dialog, const wchar_t *filename, LogDlgWork_t *work) -{ - BOOL exist; - int bom; - CheckLogFile(filename, &exist, &bom); - work->file_exist = exist; - work->current_bom = bom; -} - static LRESULT CALLBACK FNameEditProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -350,7 +350,7 @@ work->info->append = IsDlgButtonChecked(Dialog, IDC_APPEND) == BST_CHECKED; work->info->bom = IsDlgButtonChecked(Dialog, IDC_BOM) == BST_CHECKED; work->info->code = (LogCode_t)SendDlgItemMessageA(Dialog, IDC_TEXTCODING_DROPDOWN, CB_GETCURSEL, 0, 0); - SetLogFlags(Dialog); + SetLogFlags(Dialog, work->pts); EndDialog(Dialog, IDOK); break; } @@ -410,7 +410,7 @@ if (HIWORD(wParam) == EN_CHANGE){ wchar_t *filename; hGetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, &filename); - CheckLogFile(Dialog, filename, work); + CheckLogFile(filename, work); free(filename); ArrangeControls(Dialog, work); } @@ -464,14 +464,14 @@ * @retval TRUE [ok] \x82\xAA\x89\x9F\x82\xB3\x82ꂽ * @retval FALSE \x83L\x83\x83\x83\x93\x83Z\x83\x8B\x82\xB3\x82ꂽ */ -BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info) +BOOL FLogOpenDialog(HINSTANCE hInst_, HWND hWnd, FLogDlgInfo_t *info) { LogDlgWork_t *work = (LogDlgWork_t *)calloc(sizeof(LogDlgWork_t), 1); work->info = info; - work->pts = &ts; - work->pcv = &cv; + work->pts = info->pts; + work->pcv = info->pcv; INT_PTR ret = TTDialogBoxParam( - hInst, MAKEINTRESOURCE(IDD_LOGDLG), + hInst_, MAKEINTRESOURCE(IDD_LOGDLG), hWnd, LogFnHook, (LPARAM)work); free(work); return ret == IDOK ? TRUE : FALSE; Modified: trunk/teraterm/teraterm/logdlg.h =================================================================== --- trunk/teraterm/teraterm/logdlg.h 2023-10-19 12:51:47 UTC (rev 11013) +++ trunk/teraterm/teraterm/logdlg.h 2023-10-19 12:51:56 UTC (rev 11014) @@ -35,6 +35,8 @@ BOOL append; // TRUE/FALSE = append/new(overwrite) BOOL bom; // TRUE = BOM\x82\xA0\x82\xE8 LogCode_t code; + TTTSet *pts; + TComVar *pcv; } FLogDlgInfo_t; BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info); Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2023-10-19 12:51:47 UTC (rev 11013) +++ trunk/teraterm/teraterm/vtwin.cpp 2023-10-19 12:51:56 UTC (rev 11014) @@ -3793,6 +3793,8 @@ { FLogDlgInfo_t info; info.filename = NULL; + info.pts = &ts; + info.pcv = &cv; BOOL r = FLogOpenDialog(hInst, m_hWnd, &info); if (r) { const wchar_t *filename = info.filename;