|
@@ -47,7 +47,6 @@ static void clish_nspace_fini(clish_nspace_t * this)
|
|
|
while ((cmd = lub_bintree_findfirst(&this->tree))) {
|
|
|
|
|
|
lub_bintree_remove(&this->tree, cmd);
|
|
|
-
|
|
|
|
|
|
clish_command_delete(cmd);
|
|
|
}
|
|
@@ -76,6 +75,8 @@ static clish_command_t *clish_nspace_find_create_command(clish_nspace_t * this,
|
|
|
{
|
|
|
clish_command_t *cmd;
|
|
|
char *name = NULL;
|
|
|
+ clish_command_t *tmp = NULL;
|
|
|
+ lub_bintree_iterator_t iter;
|
|
|
|
|
|
assert(prefix);
|
|
|
if (!ref) {
|
|
@@ -98,6 +99,17 @@ static clish_command_t *clish_nspace_find_create_command(clish_nspace_t * this,
|
|
|
free(name);
|
|
|
assert(cmd);
|
|
|
|
|
|
+
|
|
|
+ tmp = lub_bintree_findfirst(&this->tree);
|
|
|
+ for(lub_bintree_iterator_init(&iter, &this->tree, tmp);
|
|
|
+ tmp; tmp = lub_bintree_iterator_next(&iter)) {
|
|
|
+ const char *str = clish_command__get_name(tmp);
|
|
|
+ if (lub_string_nocasestr(str, prefix) == str)
|
|
|
+ continue;
|
|
|
+ lub_bintree_remove(&this->tree, tmp);
|
|
|
+ clish_command_delete(tmp);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (-1 == lub_bintree_insert(&this->tree, cmd)) {
|
|
|
clish_command_delete(cmd);
|