Browse Source

scheme: Fix PARAM list creation for COMMAND

Serj Kalichev 3 years ago
parent
commit
a559a1da3d
3 changed files with 12 additions and 8 deletions
  1. 4 0
      klish/kcommand.h
  2. 3 2
      klish/kscheme/kcommand.c
  3. 5 6
      klish/kscheme/kview.c

+ 4 - 0
klish/kcommand.h

@@ -42,6 +42,10 @@ bool_t kcommand_set_help(kcommand_t *command, const char *help);
 bool_t kcommand_add_param(kcommand_t *command, kparam_t *param);
 kparam_t *kcommand_find_param(const kcommand_t *command, const char *name);
 
+bool_t kcommand_nested_from_icommand(kcommand_t *kcommand, icommand_t *icommand,
+	faux_error_t *error_stack);
+kcommand_t *kcommand_from_icommand(icommand_t *icommand, faux_error_t *error_stack);
+
 C_DECL_END
 
 #endif // _klish_kcommand_h

+ 3 - 2
klish/kscheme/kcommand.c

@@ -28,7 +28,8 @@ KGET_STR(command, help);
 KSET_STR(command, help);
 
 // PARAM list
-KCMP_NESTED_BY_KEY(command, param, name);
+static KCMP_NESTED(command, param, name);
+static KCMP_NESTED_BY_KEY(command, param, name);
 KADD_NESTED(command, param);
 KFIND_NESTED(command, param);
 
@@ -47,7 +48,7 @@ static kcommand_t *kcommand_new_empty(void)
 	command->help = NULL;
 
 	command->params = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_UNIQUE,
-		NULL, kcommand_param_kcompare,
+		kcommand_param_compare, kcommand_param_kcompare,
 		(void (*)(void *))kcommand_free);
 	assert(command->params);
 

+ 5 - 6
klish/kscheme/kview.c

@@ -149,12 +149,11 @@ bool_t kview_nested_from_iview(kview_t *kview, iview_t *iview,
 			kcommand_t *kcommand = NULL;
 			icommand_t *icommand = *p_icommand;
 printf("command %s\n", icommand->name);
-//			kcommand = kcommand_from_icommand(icommand, error_stack);
-//			if (!kcommand) {
-//				retval = BOOL_FALSE;
-//				continue;
-//			}
-kcommand = kcommand;
+			kcommand = kcommand_from_icommand(icommand, error_stack);
+			if (!kcommand) {
+				retval = BOOL_FALSE;
+				continue;
+			}
 		}
 	}