Browse Source

Fix PTYPE search

Serj Kalichev 5 years ago
parent
commit
fd16349cb5
2 changed files with 3 additions and 13 deletions
  1. 2 12
      clish/shell/shell_ptype.c
  2. 1 1
      lub/list/list.c

+ 2 - 12
clish/shell/shell_ptype.c

@@ -24,7 +24,7 @@ clish_ptype_t *clish_shell_find_ptype(clish_shell_t *this, const char *name)
 		r = strcmp(name, clish_ptype__get_name(ptype));
 		if (!r)
 			return ptype;
-		if (r > 0)
+		if (r < 0)
 			break;
 	}
 
@@ -39,21 +39,11 @@ clish_ptype_t *clish_shell_find_create_ptype(clish_shell_t * this,
 	clish_ptype_t *ptype = clish_shell_find_ptype(this, name);
 
 	if (!ptype) {
-		/* create a ptype */
+		/* Create a ptype */
 		ptype = clish_ptype_new(name, text, pattern,
 			method, preprocess);
 		assert(ptype);
 		lub_list_add(this->ptype_tree, ptype);
-	} else {
-		if (pattern) {
-			/* set the pattern */
-			clish_ptype__set_pattern(ptype, pattern, method);
-			/* set the preprocess */
-			clish_ptype__set_preprocess(ptype, preprocess);
-		}
-		/* set the help text */
-		if (text)
-			clish_ptype__set_text(ptype, text);
 	}
 
 	return ptype;

+ 1 - 1
lub/list/list.c

@@ -196,7 +196,7 @@ lub_list_node_t *lub_list_search_node(lub_list_t *this, void *data)
 		res = this->compareFn(data, iter->data);
 		if (!res)
 			return iter;
-		if (res > 0)
+		if (res < 0)
 			break; // No chances to find it
 		iter = iter->next;
 	}