浏览代码

Try to fix eternal loop

Serj Kalichev 1 年之前
父节点
当前提交
ad8aca6b49
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      klish/ksession/ksession_parse.c

+ 4 - 0
klish/ksession/ksession_parse.c

@@ -223,11 +223,14 @@ static kpargv_status_e ksession_parse_arg(ksession_t *session,
 			// Try to match argument and current entry
 			// (from 'min' to 'max' times)
 			for (num = 0; num < kentry_max(nested); num++) {
+				faux_argv_node_t *iter_before_parse = *argv_iter;
 				nrc = ksession_parse_arg(session, nested,
 					argv_iter, pargv, BOOL_FALSE, is_filter);
 //fprintf(stderr, "%s: %s\n", kentry_name(nested), kpargv_status_decode(nrc));
 				if (nrc != KPARSE_INPROGRESS)
 					break;
+				if (iter_before_parse == *argv_iter)
+					break;
 			}
 			// All errors will break the loop
 			if ((KPARSE_ERROR == nrc) ||
@@ -253,6 +256,7 @@ static kpargv_status_e ksession_parse_arg(ksession_t *session,
 			// If optional entry is found then go back to nearest
 			// non-optional (or ordered) entry to try to find
 			// another optional entries.
+//fprintf(stderr, "%s: min=%d, num=%d\n", kentry_name(nested), min, num);
 			if ((0 == min) && (num > 0))
 				iter = saved_iter;
 		}