[ttssh2-commit] [10398] 表示文字列が正しくない場合があったので修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 12月 5日 (月) 22:29:32 JST


Revision: 10398
          https://osdn.net/projects/ttssh2/scm/svn/commits/10398
Author:   zmatsuo
Date:     2022-12-05 22:29:32 +0900 (Mon, 05 Dec 2022)
Log Message:
-----------
表示文字列が正しくない場合があったので修正

- lng読み込み(GetI18nStrWW())時、keyを未指定(=NULL)時に発生

Modified Paths:
--------------
    trunk/teraterm/common/i18n_static.c

-------------- next part --------------
Modified: trunk/teraterm/common/i18n_static.c
===================================================================
--- trunk/teraterm/common/i18n_static.c	2022-12-04 15:29:36 UTC (rev 10397)
+++ trunk/teraterm/common/i18n_static.c	2022-12-05 13:29:32 UTC (rev 10398)
@@ -38,7 +38,8 @@
  *	lng\x83t\x83@\x83C\x83\x8B(ini\x83t\x83@\x83C\x83\x8B)\x82\xA9\x82當\x8E\x9A\x97\xF1\x82\xF0\x8E擾
  *
  *	@param[in]		section
- *	@param[in]		key
+ *	@param[in]		key			\x83L\x81[
+ *								NULL\x82̂Ƃ\xAB\x82\xCD str = def \x82\xAA\x95Ԃ\xE9
  *	@param[in]		def			\x83f\x83t\x83H\x83\x8B\x83g\x95\xB6\x8E\x9A\x97\xF1
  *								NULL=\x96\xA2\x8Ew\x92\xE8
  *	@param[in]		iniFile		ini\x83t\x83@\x83C\x83\x8B
@@ -51,12 +52,18 @@
  */
 size_t GetI18nStrWW(const char *section, const char *key, const wchar_t *def, const wchar_t *iniFile, wchar_t **str)
 {
-	wchar_t sectionW[64];
-	wchar_t keyW[128];
 	size_t size;
-	MultiByteToWideChar(CP_ACP, 0, section, -1, sectionW, _countof(sectionW));
-	MultiByteToWideChar(CP_ACP, 0, key, -1, keyW, _countof(keyW));
-	hGetPrivateProfileStringW(sectionW, keyW, def, iniFile, str);
+	if (key == NULL) {
+		assert(def != NULL);
+		*str = _wcsdup(def);
+	}
+	else {
+		wchar_t sectionW[64];
+		wchar_t keyW[128];
+		MultiByteToWideChar(CP_ACP, 0, section, -1, sectionW, _countof(sectionW));
+		MultiByteToWideChar(CP_ACP, 0, key, -1, keyW, _countof(keyW));
+		hGetPrivateProfileStringW(sectionW, keyW, def, iniFile, str);
+	}
 	assert(*str != NULL);		// \x83\x81\x83\x82\x83\x8A\x82\xAA\x82Ȃ\xA2\x8E\x9E NULL \x82\xAA\x95Ԃ\xC1\x82Ă\xAD\x82\xE9
 	size = RestoreNewLineW(*str);
 	return size;


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