[Ttssh2-commit] [5156] listbox マクロコマンドに渡す選択肢を文字列配列に変更

svnno****@sourc***** svnno****@sourc*****
2013年 3月 22日 (金) 19:12:55 JST


Revision: 5156
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5156
Author:   maya
Date:     2013-03-22 19:12:55 +0900 (Fri, 22 Mar 2013)
Log Message:
-----------
listbox マクロコマンドに渡す選択肢を文字列配列に変更

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/ttl.c

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2013-03-22 10:06:04 UTC (rev 5155)
+++ trunk/teraterm/ttpmacro/ttl.c	2013-03-22 10:12:55 UTC (rev 5156)
@@ -3063,9 +3063,9 @@
 	TStrVal Str1, Str2;
 	int sp = 0;
 	int ret;
-	char *s[LISTBOX_ITEM_NUM] = {0};
-	TStrVal str;
-	int i;
+	char **s;
+	int i, ary_size;
+	TVarId VarId, VarId2;
 
 	*Err = 0;
 	GetStrVal2(Str1, Err, TRUE);
@@ -3107,18 +3107,23 @@
 
 	} else if (BoxId==IdListBox) {
 		//  \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82̑I\x91\xF0\x8E\x88\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B
-		for (i = 0 ; i < LISTBOX_ITEM_NUM ; i++) {
-			if (CheckParameterGiven()) {
-				GetStrVal2(str, Err, TRUE);
-				if (*Err ==0 ) 
-					s[i] = _strdup(str);
-			} else {
-				s[i] = NULL;
-			}
+		GetStrAryVar(&VarId, Err);
+		if (*Err!=0) return 0;
+
+		ary_size = GetStrAryVarSize(VarId);
+		s = (char **)calloc(ary_size + 1, sizeof(char *));
+		if (s == NULL) {
+			*Err = ErrFewMemory;
+			return -1;
 		}
+		for (i = 0 ; i < ary_size ; i++) {
+			VarId2 = GetStrVarFromArray(VarId, i, Err);
+			if (*Err!=0) return -1;
+			s[i] = _strdup(StrVarPtr(VarId2));
+		}
 		if (s[0] == NULL) {
 			*Err = ErrSyntax;
-			return 0;
+			return -1;
 		}
 
 		// return 
@@ -3126,9 +3131,10 @@
 		//   -1: \x83L\x83\x83\x83\x93\x83Z\x83\x8B
 		ret = OpenListDlg(Str1, Str2, s);
 
-		for (i = 0 ; i < LISTBOX_ITEM_NUM ; i++) {
+		for (i = 0 ; i < ary_size ; i++) {
 			free(s[i]);
 		}
+		free(s);
 
 		return (ret);
 



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