Revision: 10704 https://osdn.net/projects/ttssh2/scm/svn/commits/10704 Author: zmatsuo Date: 2023-05-15 00:37:10 +0900 (Mon, 15 May 2023) Log Message: ----------- ttpmenuのlngファイルのパスが誤っていたので修正 - exeファイルのあるフォルダの lng*/ フォルダを参照するようにした - 誤ってiniファイルのあるフォルダを参照していた - ttpmenu/.editorconfig 追加 - 行末のスペースを受け入れるようにした - メモリリーク調査コード追加 - crtdbg.h の include、_CrtSetDbgFlag() の追加 Modified Paths: -------------- trunk/ttpmenu/ttpmenu.cpp Added Paths: ----------- trunk/ttpmenu/.editorconfig -------------- next part -------------- Added: trunk/ttpmenu/.editorconfig =================================================================== --- trunk/ttpmenu/.editorconfig (rev 0) +++ trunk/ttpmenu/.editorconfig 2023-05-14 15:37:10 UTC (rev 10704) @@ -0,0 +1,6 @@ +[*.{cpp,c,h,cc}] +indent_style = tab +indent_size = 4 +end_of_line = crlf +charset = cp932 +insert_final_newline = true Modified: trunk/ttpmenu/ttpmenu.cpp =================================================================== --- trunk/ttpmenu/ttpmenu.cpp 2023-05-14 15:36:59 UTC (rev 10703) +++ trunk/ttpmenu/ttpmenu.cpp 2023-05-14 15:37:10 UTC (rev 10704) @@ -32,6 +32,9 @@ #include <commctrl.h> #include <windowsx.h> // for GET_X_LPARAM(), GET_Y_LPARAM() #include <string.h> +#define _CRTDBG_MAP_ALLOC +#include <stdlib.h> +#include <crtdbg.h> #include "ttpmenu.h" #include "registry.h" @@ -2642,34 +2645,29 @@ static void GetUILanguageFile(char *buf, int buflen) { - wchar_t *HomeDirW; - wchar_t *Temp; - wchar_t *SetupFName; - wchar_t *fullpath; - char *fullpathA; - /* Get home directory */ - HomeDirW = GetHomeDirW(NULL); + wchar_t *HomeDirW = GetHomeDirW(NULL); /* Get SetupFName */ - SetupFName = GetDefaultSetupFNameW(HomeDirW); + wchar_t *SetupFName = GetDefaultSetupFNameW(HomeDirW); + free(HomeDirW); /* Get LanguageFile name */ - hGetPrivateProfileStringW(L"Tera Term", L"UILanguageFile", NULL, SetupFName, &Temp); - if (Temp[0] == L'\0') { - free(Temp); - Temp = _wcsdup(L"lang\\Default.lng"); + wchar_t *lng_rel; + hGetPrivateProfileStringW(L"Tera Term", L"UILanguageFile", NULL, SetupFName, &lng_rel); + free(SetupFName); + if (lng_rel[0] == L'\0') { + free(lng_rel); + lng_rel = _wcsdup(L"lang\\Default.lng"); } - fullpath = GetUILanguageFileFullW(HomeDirW, Temp); - fullpathA = ToCharW(fullpath); - free(HomeDirW); - free(SetupFName); - free(Temp); + wchar_t *ExeDirW = GetExeDirW(NULL); + wchar_t *fullpath = GetUILanguageFileFullW(ExeDirW, lng_rel); + free(ExeDirW); + free(lng_rel); + + WideCharToACP_t(fullpath, buf, buflen); free(fullpath); - - strcpy_s(buf, buflen, fullpathA); - free(fullpathA); } /* ========================================================================== @@ -2699,6 +2697,10 @@ pSetDllDir setDllDir; pSetDefDllDir setDefDllDir; +#ifdef _DEBUG + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + if ((module = GetModuleHandle("kernel32.dll")) != NULL) { if ((setDefDllDir = (pSetDefDllDir)GetProcAddress(module, "SetDefaultDllDirectories")) != NULL) { // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82́A\x8C\x9F\x8D\xF5\x83p\x83X\x82\xF0 %WINDOWS%\system32 \x82݂̂ɐݒ肷\x82\xE9