Kaynağa Gözat

Ignore parameters with failed conditions

git-svn-id: https://klish.googlecode.com/svn/trunk@249 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 yıl önce
ebeveyn
işleme
f9577c53bd
1 değiştirilmiş dosya ile 6 ekleme ve 10 silme
  1. 6 10
      clish/pargv/pargv.c

+ 6 - 10
clish/pargv/pargv.c

@@ -117,7 +117,6 @@ clish_pargv_parse(clish_pargv_t * this,
 		clish_param_t *param = clish_paramv__get_param(paramv,index);
 		clish_param_t *cparam = NULL;
 		int is_switch = 0;
-		int is_tested = 0;
 
 		/* Use real arg or PARAM's default value as argument */
 		if (*idx >= argc)
@@ -129,23 +128,20 @@ clish_pargv_parse(clish_pargv_t * this,
 		if (CLISH_PARAM_SWITCH == clish_param__get_mode(param))
 			is_switch = 1;
 
-		/* Check the 'test' condition */
+		/* Check the 'test' conditions */
 		if (param) {
 			char *str = clish_param__get_test(param,
 				NULL, cmd, this);
-			if (!str)
-				is_tested = 1;
-			else {
-				if (lub_system_line_test(str))
-					is_tested = 1;
-				else
-					is_tested = 0;
+			if (str && !lub_system_line_test(str)) {
 				lub_string_free(str);
+				index++;
+				continue;
 			}
+			lub_string_free(str);
 		}
 
 		/* Add param for help and completion */
-		if (last && (*idx == need_index) && is_tested &&
+		if (last && (*idx == need_index) &&
 			(NULL == clish_pargv_find_arg(this, clish_param__get_name(param)))) {
 			if (is_switch) {
 				clish_paramv_t *rec_paramv = clish_param__get_paramv(param);