瀏覽代碼

Fix problem with first entry in config bintree.

git-svn-id: https://klish.googlecode.com/svn/trunk@107 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 14 年之前
父節點
當前提交
f079e77cf0
共有 2 個文件被更改,包括 6 次插入7 次删除
  1. 5 5
      cliconf/conf/conf.c
  2. 1 2
      clish/view/view_dump.c

+ 5 - 5
cliconf/conf/conf.c

@@ -187,16 +187,16 @@ cliconf_t *cliconf_find_conf(cliconf_t * this,
 		return lub_bintree_find(&this->tree, &key);
 	}
 
-	/* Empty tree */
+	/* If tree is empty */
 	if (!(conf = lub_bintree_findfirst(&this->tree)))
 		return NULL;
 
 	/* Iterate non-empty tree */
 	lub_bintree_iterator_init(&iter, &this->tree, conf);
-	while ((conf = lub_bintree_iterator_next(&iter))) {
+	do {
 		if (0 == lub_string_nocasecmp(conf->line, line))
 			return conf;
-	}
+	} while ((conf = lub_bintree_iterator_next(&iter)));
 
 	return NULL;
 }
@@ -213,12 +213,12 @@ void cliconf_del_pattern(cliconf_t *this,
 		return;
 
 	lub_bintree_iterator_init(&iter, &this->tree, conf);
-	while ((conf = lub_bintree_iterator_next(&iter))) {
+	do {
 		if (lub_string_nocasestr(conf->line, pattern) == conf->line) {
 			lub_bintree_remove(&this->tree, conf);
 			cliconf_delete(conf);
 		}
-	}
+	} while ((conf = lub_bintree_iterator_next(&iter)));
 }
 
 /*--------------------------------------------------------- */

+ 1 - 2
clish/view/view_dump.c

@@ -14,8 +14,6 @@ void clish_view_dump(clish_view_t * this)
 	lub_dump_printf("view(%p)\n", this);
 	lub_dump_indent();
 
-	c = lub_bintree_findfirst(&this->tree);
-
 	lub_dump_printf("name  : %s\n", clish_view__get_name(this));
 	lub_dump_printf("depth : %u\n", clish_view__get_depth(this));
 
@@ -25,6 +23,7 @@ void clish_view_dump(clish_view_t * this)
 	}
 
 	/* iterate the tree of commands */
+	c = lub_bintree_findfirst(&this->tree);
 	for (lub_bintree_iterator_init(&iter, &this->tree, c);
 	     c; c = lub_bintree_iterator_next(&iter)) {
 		clish_command_dump(c);