Przeglądaj źródła

COMMAND gets min and max attributes

Serj Kalichev 1 rok temu
rodzic
commit
3c6196f1e6
2 zmienionych plików z 5 dodań i 4 usunięć
  1. 1 2
      klish/ksession/ksession_parse.c
  2. 4 2
      klish/xml-helper/load.c

+ 1 - 2
klish/ksession/ksession_parse.c

@@ -213,13 +213,13 @@ static kpargv_status_e ksession_parse_arg(ksession_t *session,
 			size_t num = 0;
 			size_t min = kentry_min(nested);
 
-//fprintf(stderr, "SEQ arg: %s, entry %s\n", *argv_iter ? faux_argv_current(*argv_iter) : "<empty>", kentry_name(nested));
 			// Ignore entries with non-COMMON purpose.
 			if (kentry_purpose(nested) != KENTRY_PURPOSE_COMMON)
 				continue;
 			// Filter out double parsing for optional entries.
 			if (kpargv_entry_exists(pargv, nested))
 				continue;
+//fprintf(stderr, "SEQ arg: %s, entry %s\n", *argv_iter ? faux_argv_current(*argv_iter) : "<empty>", kentry_name(nested));
 			// Try to match argument and current entry
 			// (from 'min' to 'max' times)
 			for (num = 0; num < kentry_max(nested); num++) {
@@ -246,7 +246,6 @@ static kpargv_status_e ksession_parse_arg(ksession_t *session,
 			}
 			// It's not an error if optional parameter is absend
 			rc = KPARSE_INPROGRESS;
-
 			// Mandatory or ordered parameter
 			if ((min > 0) || kentry_order(nested))
 				saved_iter = iter;

+ 4 - 2
klish/xml-helper/load.c

@@ -849,8 +849,8 @@ static bool_t process_command(const kxml_node_t *element, void *parent,
 		ientry.purpose = "common";
 		break;
 	}
-	ientry.min = "1";
-	ientry.max = "1";
+	ientry.min = kxml_node_attr(element, "min");
+	ientry.max = kxml_node_attr(element, "max");
 	ientry.ref = kxml_node_attr(element, "ref");
 	if ((KTAG_FILTER == tag) || (KTAG_COMMAND == tag)) {
 		ientry.value = kxml_node_attr(element, "value");
@@ -899,6 +899,8 @@ err:
 		kxml_node_attr_free(ientry.name);
 	kxml_node_attr_free(ientry.help);
 	kxml_node_attr_free(ientry.mode);
+	kxml_node_attr_free(ientry.min);
+	kxml_node_attr_free(ientry.max);
 	kxml_node_attr_free(ientry.ref);
 	if ((KTAG_FILTER == tag) || (KTAG_COMMAND == tag)) {
 		kxml_node_attr_free(ientry.value);