[Ttssh2-commit] [8516] OpenHelp() リファクタリング

scmno****@osdn***** scmno****@osdn*****
2020年 1月 31日 (金) 08:42:36 JST


Revision: 8516
          https://osdn.net/projects/ttssh2/scm/svn/commits/8516
Author:   zmatsuo
Date:     2020-01-31 08:42:36 +0900 (Fri, 31 Jan 2020)
Log Message:
-----------
OpenHelp() リファクタリング

Modified Paths:
--------------
    trunk/teraterm/ttpcmn/ttcmn.c

-------------- next part --------------
Modified: trunk/teraterm/ttpcmn/ttcmn.c
===================================================================
--- trunk/teraterm/ttpcmn/ttcmn.c	2020-01-30 10:17:52 UTC (rev 8515)
+++ trunk/teraterm/ttpcmn/ttcmn.c	2020-01-30 23:42:36 UTC (rev 8516)
@@ -1168,7 +1168,7 @@
 	HWND HWin;
 	wchar_t HelpFN[MAX_PATH];
 	wchar_t uimsg[MAX_UIMSG];
-	wchar_t *HomeDirT;
+	wchar_t *HomeDirW;
 
 	/* Get home directory */
 	if (GetModuleFileNameA(NULL,Temp,_countof(Temp)) == 0) {
@@ -1175,29 +1175,22 @@
 		return;
 	}
 	ExtractDirName(Temp, HomeDir);
-	HomeDirT = ToWcharA(HomeDir);
-
+	HomeDirW = ToWcharA(HomeDir);
 	get_lang_msgW("HELPFILE", uimsg, _countof(uimsg), L"teraterm.chm", UILanguageFile);
+	_snwprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, L"%s\\%s", HomeDirW, uimsg);
+	free(HomeDirW);
 
 	// \x83w\x83\x8B\x83v\x82̃I\x81[\x83i\x81[\x82͏\xED\x82Ƀf\x83X\x83N\x83g\x83b\x83v\x82ɂȂ\xE9 (2007.5.12 maya)
 	HWin = GetDesktopWindow();
-	_snwprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, L"%s\\%s", HomeDirT, uimsg);
 	if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) {
-		goto error;
-	}
-	goto finish;
-
-error:
-	{
+		// \x83w\x83\x8B\x83v\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD
 		wchar_t buf[MAX_PATH];
 		get_lang_msgW("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg),
 					  L"Can't open HTML help file(%s).", UILanguageFile);
 		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN);
 		_MessageBoxW(HWin, buf, L"Tera Term: HTML help", MB_OK | MB_ICONERROR);
+		return;
 	}
-
-finish:
-	free(HomeDirT);
 }
 
 HWND WINAPI GetNthWin(int n)


Ttssh2-commit メーリングリストの案内