Przeglądaj źródła

The 'link' commands now contain the link to original command.

git-svn-id: https://klish.googlecode.com/svn/trunk@176 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 14 lat temu
rodzic
commit
360c98fb1a
3 zmienionych plików z 13 dodań i 4 usunięć
  1. 1 0
      clish/command.h
  2. 11 3
      clish/command/command.c
  3. 1 1
      clish/command/private.h

+ 1 - 0
clish/command.h

@@ -100,5 +100,6 @@ unsigned short clish_command__get_seq(const clish_command_t * instance,
 clish_view_restore_t clish_command__get_restore(const clish_command_t * instance);
 bool_t clish_command__get_unique(const clish_command_t * instance);
 void clish_command__set_unique(clish_command_t * instance, bool_t unique);
+const clish_command_t * clish_command__get_orig(const clish_command_t * instance);
 
 #endif				/* _clish_command_h */

+ 11 - 3
clish/command/command.c

@@ -27,7 +27,7 @@ clish_command_init(clish_command_t * this, const char *name, const char *text)
 	lub_bintree_node_init(&this->bt_node);
 
 	/* set up defaults */
-	this->link = BOOL_FALSE;
+	this->link = NULL;
 	this->paramv = clish_paramv_new();
 	this->viewid = NULL;
 	this->view = NULL;
@@ -129,7 +129,7 @@ clish_command_t *clish_command_new(const char *name, const char *text)
 
 /*--------------------------------------------------------- */
 clish_command_t *clish_command_new_link(const char *name,
-					const clish_command_t * ref)
+	const clish_command_t * ref)
 {
 	if (!ref)
 		return NULL;
@@ -144,7 +144,7 @@ clish_command_t *clish_command_new_link(const char *name,
 	/* Be a good binary tree citizen */
 	lub_bintree_node_init(&this->bt_node);
 	/* It a link to command so set the link flag */
-	this->link = BOOL_TRUE;
+	this->link = ref;
 
 	return this;
 }
@@ -540,3 +540,11 @@ void clish_command__set_unique(clish_command_t * this, bool_t unique)
 {
 	this->unique = unique;
 }
+
+/*--------------------------------------------------------- */
+const clish_command_t * clish_command__get_orig(const clish_command_t * this)
+{
+	if (this->link)
+		return clish_command__get_orig(this->link);
+	return this;
+}

+ 1 - 1
clish/command/private.h

@@ -18,7 +18,7 @@ struct clish_command_s {
 	char *builtin;
 	char *escape_chars;
 	clish_param_t *args;
-	bool_t link;
+	const struct clish_command_s * link;
 	clish_view_t *pview;
 
 	/* CONFIG params: