소스 검색

Copy all sym attrs while linking

Serj Kalichev 11 년 전
부모
커밋
51d0842117
3개의 변경된 파일16개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 0
      clish/plugin.h
  2. 14 0
      clish/plugin/plugin.c
  3. 1 2
      clish/shell/shell_plugin.c

+ 1 - 0
clish/plugin.h

@@ -39,6 +39,7 @@ void clish_sym__set_permanent(clish_sym_t *instance, bool_t permanent);
 bool_t clish_sym__get_permanent(clish_sym_t *instance);
 void clish_sym__set_plugin(clish_sym_t *instance, clish_plugin_t *plugin);
 clish_plugin_t *clish_sym__get_plugin(clish_sym_t *instance);
+int clish_sym_clone(clish_sym_t *dst, clish_sym_t *src);
 
 /* Plugin */
 

+ 14 - 0
clish/plugin/plugin.c

@@ -95,6 +95,20 @@ clish_plugin_t *clish_sym__get_plugin(clish_sym_t *this)
 	return this->plugin;
 }
 
+/*--------------------------------------------------------- */
+int clish_sym_clone(clish_sym_t *dst, clish_sym_t *src)
+{
+	char *name;
+
+	if (!dst || !src)
+		return -1;
+	name = dst->name;
+	*dst = *src;
+	dst->name = name;
+
+	return 0;
+}
+
 /**********************************************************
  * PLUGIN functions                                       *
  **********************************************************/

+ 1 - 2
clish/shell/shell_plugin.c

@@ -161,8 +161,7 @@ int clish_shell_link_plugins(clish_shell_t *this)
 			return -1;
 		}
 		/* Copy symbol attributes */
-		clish_sym__set_func(sym, clish_sym__get_func(plugin_sym));
-		clish_sym__set_permanent(sym, clish_sym__get_permanent(plugin_sym));
+		clish_sym_clone(sym, plugin_sym);
 	}
 
 	return 0;