[Ttssh2-commit] [6495] Vista / 7 でドロップダウンリストで正しく無い値が設定されている事がある為、

svnno****@sourc***** svnno****@sourc*****
2016年 9月 27日 (火) 14:06:05 JST


Revision: 6495
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6495
Author:   doda
Date:     2016-09-27 14:06:05 +0900 (Tue, 27 Sep 2016)
Log Message:
-----------
Vista / 7 でドロップダウンリストで正しく無い値が設定されている事がある為、
Setup - General ダイアログで落ちる事があるのを修正した。

https://twitter.com/hk1v/status/735106508606689284

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/ttpdlg/ttdlg.c

-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2016-09-27 05:06:01 UTC (rev 6494)
+++ trunk/doc/en/html/about/history.html	2016-09-27 05:06:05 UTC (rev 6495)
@@ -31,26 +31,26 @@
 
 <h2><a name="teraterm">Tera Term</a></h2>
 
-
 <h3><a name="teraterm_4.93">2016.xx.xx (Ver 4.93)</a></h3>
 <ul class="history">
-  <li>Changes
+  <!-- li>Changes
     <ul>
       <li></li>
     </ul>
-  </li>
+  </li -->
 
   <li>Bug fixes
     <ul>
       <li>When <a href="../setup/teraterm-misc.html#DeferredLogWriteMode">DeferredLogWriteMode</a>=on is enabled and a log file is closed soon after opening the file, Tera Term rarely halts by dead-lock.</li>
+      <!-- li>Windows 7 / Vista \x82\xC5 <a href="..\menu\setup-general.html">General setup \x83_\x83C\x83A\x83\x8D\x83O</a> \x82œ\xC1\x8E\xEA\x82ȑ\x80\x8D\xEC\x82\xF0\x82\xB5\x82\xBD\x8E\x9E\x82ɗ\x8E\x82\xBF\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li -->
     </ul>
   </li>
 
-  <li>Misc
+  <!-- li>Misc
     <ul>
       <li></li>
     </ul>
-  </li>
+  </li -->
 </ul>
 
 

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2016-09-27 05:06:01 UTC (rev 6494)
+++ trunk/doc/ja/html/about/history.html	2016-09-27 05:06:05 UTC (rev 6495)
@@ -31,26 +31,26 @@
 
 <h2><a name="teraterm">Tera Term</a></h2>
 
-
 <h3><a name="teraterm_4.93">2016.xx.xx (Ver 4.93)</a></h3>
 <ul class="history">
-  <li>\x95ύX
+  <!-- li>\x95ύX
     <ul>
       <li></li>
     </ul>
-  </li>
+  </li -->
 
   <li>\x83o\x83O\x8FC\x90\xB3
     <ul>
       <li><a href="../setup/teraterm-misc.html#DeferredLogWriteMode">DeferredLogWriteMode</a>=on \x82̏ꍇ\x82ɂ\xA8\x82\xA2\x82āA\x83\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82̃I\x81[\x83v\x83\x93\x8C\xE3\x81A\x82\xB7\x82\xAE\x82ɃN\x83\x8D\x81[\x83Y\x82\xF0\x8Ds\x82\xA4\x82ƁA\x82܂\xEA\x82\xC9 Tera Term \x82\xAA\x83f\x83b\x83h\x83\x8D\x83b\x83N\x82\xB5\x82ăX\x83g\x81[\x83\x8B\x82\xB7\x82\xE9\x82Ƃ\xA2\x82\xA4\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
+      <li>Windows 7 / Vista \x82\xC5 <a href="..\menu\setup-general.html">General setup \x83_\x83C\x83A\x83\x8D\x83O</a> \x82œ\xC1\x8E\xEA\x82ȑ\x80\x8D\xEC\x82\xF0\x82\xB5\x82\xBD\x8E\x9E\x82ɗ\x8E\x82\xBF\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
     </ul>
   </li>
 
-  <li>\x82\xBB\x82̑\xBC
+  <!-- li>\x82\xBB\x82̑\xBC
     <ul>
       <li></li>
     </ul>
-  </li>
+  </li -->
 </ul>
 
 

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2016-09-27 05:06:01 UTC (rev 6494)
+++ trunk/teraterm/common/tttypes.h	2016-09-27 05:06:05 UTC (rev 6495)
@@ -192,6 +192,7 @@
 #define IdRussian  3
 #define IdKorean   4  //HKS
 #define IdUtf8     5
+#define IdLangMax IdUtf8
 
 // log flags (used in ts.LogFlag) 
 #define LOG_TEL 1

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2016-09-27 05:06:01 UTC (rev 6494)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2016-09-27 05:06:05 UTC (rev 6495)
@@ -3042,7 +3042,7 @@
 #define LANG_PATH "lang"
 #define LANG_EXT ".lng"
 
-static void make_sel_lang_ui(char *HomeDir)
+static int make_sel_lang_ui(char *HomeDir)
 {
 	int    i;
 	int    file_num;
@@ -3068,8 +3068,9 @@
 	hFind = FindFirstFile(fullpath,&fd);
 	if (hFind != INVALID_HANDLE_VALUE) {
 		do {
-		  if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
-			file_num ++;
+			if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+				file_num++;
+			}
 		} while(FindNextFile(hFind,&fd));
 		FindClose(hFind);
 	}
@@ -3084,11 +3085,12 @@
 			if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
 				LangUIList[i++] = _strdup(fd.cFileName);
 			}
-		} while(FindNextFile(hFind,&fd));
+		} while(FindNextFile(hFind,&fd) && i < file_num);
 		FindClose(hFind);
 	}
-	LangUIList[i++] = NULL;
+	LangUIList[i] = NULL;
 
+	return i;
 }
 
 static int get_sel_lang_ui(char **list, char *selstr)
@@ -3113,7 +3115,7 @@
 
 BOOL CALLBACK GenDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
-	static int langui_sel = 1;
+	static int langui_sel = 1, uilist_count = 0;
 	PTTSet ts;
 	WORD w;
 	char Temp[8];
@@ -3191,7 +3193,7 @@
 			}
 
 			// \x8Dŏ\x89\x82Ɏw\x92肳\x82\xEA\x82Ă\xA2\x82錾\x8C\xEA\x83t\x83@\x83C\x83\x8B\x82̔ԍ\x86\x82\xF0\x8Ao\x82\xA6\x82Ă\xA8\x82\xAD\x81B
-			make_sel_lang_ui(ts->HomeDir);
+			uilist_count = make_sel_lang_ui(ts->HomeDir);
 			langui_sel = get_sel_lang_ui(LangUIList, ts->UILanguageFile_ini);
 			SetDropDownList(Dialog, IDC_GENLANG_UI, LangUIList, langui_sel);
 			if (LangUIList[0] == NULL) {
@@ -3213,24 +3215,26 @@
 						else {
 							ts->PortType = IdTCPIP;
 						}
+
 						if ((ts->MenuFlag & MF_NOLANGUAGE)==0) {
 							WORD language = (WORD)GetCurSel(Dialog, IDC_GENLANG);
 
 							// Language \x82\xAA\x95ύX\x82\xB3\x82ꂽ\x82Ƃ\xAB\x81A
 							// KanjiCode/KanjiCodeSend \x82\xF0\x95ύX\x90\xE6\x82\xCC Language \x82ɑ\xB6\x8D݂\xB7\x82\xE9\x92l\x82ɒu\x82\xAB\x8A\xB7\x82\xA6\x82\xE9
-							if (language != ts->Language) {
+							if (1 <= language && language <= IdLangMax && language != ts->Language) {
 								WORD KanjiCode = ts->KanjiCode;
 								WORD KanjiCodeSend = ts->KanjiCodeSend;
 								ts->KanjiCode = KanjiCodeTranslate(language,KanjiCode);
 								ts->KanjiCodeSend = KanjiCodeTranslate(language,KanjiCodeSend);
+
+								ts->Language = language;
 							}
 
-							ts->Language = language;
 						}
 
 						// \x8C\xBE\x8C\xEA\x83t\x83@\x83C\x83\x8B\x82\xAA\x95ύX\x82\xB3\x82\xEA\x82Ă\xA2\x82\xBD\x8Fꍇ
 						w = (WORD)GetCurSel(Dialog, IDC_GENLANG_UI);
-						if (w != langui_sel) {
+						if (1 <= w && w <= uilist_count && w != langui_sel) {
 							char CurDir[MAX_PATH];
 
 							_snprintf_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), _TRUNCATE,



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