Browse Source

Fix dump files

Serj Kalichev 11 years ago
parent
commit
7573350396

+ 3 - 8
clish/action/action_dump.c

@@ -10,18 +10,13 @@
 /*--------------------------------------------------------- */
 void clish_action_dump(const clish_action_t *this)
 {
-	char *builtin_name;
-
 	lub_dump_printf("action(%p)\n", this);
 	lub_dump_indent();
 
-	lub_dump_printf("script  : %s\n",
-		this->script ? this->script : "(null)");
-	builtin_name = clish_sym__get_name(this->builtin);
+	lub_dump_printf("script  : %s\n", LUB_DUMP_STR(this->script));
 	lub_dump_printf("builtin : %s\n",
-		builtin_name ? builtin_name : "(null)");
-	lub_dump_printf("shebang : %s\n",
-		this->shebang ? this->shebang : "(null)");
+		this->builtin ? clish_sym__get_name(this->builtin) : LUB_DUMP_NULL );
+	lub_dump_printf("shebang : %s\n", LUB_DUMP_STR(this->shebang));
 
 	lub_dump_undent();
 }

+ 13 - 11
clish/command/command_dump.c

@@ -14,17 +14,19 @@ void clish_command_dump(const clish_command_t * this)
 
 	lub_dump_printf("command(%p)\n", this);
 	lub_dump_indent();
-	lub_dump_printf("name        : %s\n", this->name);
-	lub_dump_printf("text        : %s\n", this->text);
-	lub_dump_printf("link        : %s\n",
-		this->link ? clish_command__get_name(this->link) : "(null)");
-	lub_dump_printf("alias       : %s\n", this->alias);
-	lub_dump_printf("alias_view  : %s\n",
-		this->alias_view ? clish_view__get_name(this->alias_view) : "(null)");
-	lub_dump_printf("paramc      : %d\n", clish_paramv__get_count(this->paramv));
-	lub_dump_printf("detail      : %s\n",
-			this->detail ? this->detail : "(null)");
-	lub_dump_printf("access      : %s\n", this->access);
+	lub_dump_printf("name       : %s\n", this->name);
+	lub_dump_printf("text       : %s\n", this->text);
+	lub_dump_printf("link       : %s\n",
+		this->link ?
+		clish_command__get_name(this->link) : LUB_DUMP_NULL);
+	lub_dump_printf("alias      : %s\n", LUB_DUMP_STR(this->alias));
+	lub_dump_printf("alias_view : %s\n",
+		this->alias_view ?
+		clish_view__get_name(this->alias_view) : LUB_DUMP_NULL);
+	lub_dump_printf("paramc     : %d\n",
+		clish_paramv__get_count(this->paramv));
+	lub_dump_printf("detail     : %s\n", LUB_DUMP_STR(this->detail));
+	lub_dump_printf("access     : %s\n", LUB_DUMP_STR(this->access));
 	clish_action_dump(this->action);
 	clish_config_dump(this->config);
 

+ 1 - 1
clish/hotkey/hotkey_dump.c

@@ -13,7 +13,7 @@ void clish_hotkey_dump(const clish_hotkey_t *this)
 
 	lub_dump_indent();
 	lub_dump_printf("key : %d\n", this->code);
-	lub_dump_printf("cmd : %s\n", this->cmd);
+	lub_dump_printf("cmd : %s\n", LUB_DUMP_STR(this->cmd));
 	lub_dump_undent();
 }
 

+ 7 - 12
clish/nspace/nspace_dump.c

@@ -13,18 +13,13 @@ void clish_nspace_dump(const clish_nspace_t * this)
 
 	lub_dump_indent();
 	lub_dump_printf("view         : %s\n",
-			clish_view__get_name(this->view));
-	lub_dump_printf("prefix       : %s\n",
-			this->prefix ? this->prefix : "(null)");
-	lub_dump_printf("access       : %s\n",
-			this->access ? this->access : "(null)");
-	lub_dump_printf("help         : %s\n", this->help ? "true" : "false");
-	lub_dump_printf("completion   : %s\n",
-			this->completion ? "true" : "false");
-	lub_dump_printf("context_help : %s\n",
-			this->context_help ? "true" : "false");
-	lub_dump_printf("inherit      : %s\n",
-			this->inherit ? "true" : "false");
+		clish_view__get_name(this->view));
+	lub_dump_printf("prefix       : %s\n", LUB_DUMP_STR(this->prefix));
+	lub_dump_printf("access       : %s\n", LUB_DUMP_STR(this->access));
+	lub_dump_printf("help         : %s\n", LUB_DUMP_BOOL(this->help));
+	lub_dump_printf("completion   : %s\n", LUB_DUMP_BOOL(this->completion));
+	lub_dump_printf("context_help : %s\n", LUB_DUMP_BOOL(this->context_help));
+	lub_dump_printf("inherit      : %s\n", LUB_DUMP_BOOL(this->inherit));
 	lub_dump_undent();
 }
 

+ 8 - 11
clish/param/param_dump.c

@@ -14,12 +14,11 @@ void clish_param_dump(const clish_param_t * this)
 	lub_dump_printf("param(%p)\n", this);
 
 	lub_dump_indent();
-	lub_dump_printf("name       : %s\n", this->name);
-	lub_dump_printf("text       : %s\n", this->text);
-	lub_dump_printf("value      : %s\n", this->value);
+	lub_dump_printf("name       : %s\n", LUB_DUMP_STR(this->name));
+	lub_dump_printf("text       : %s\n", LUB_DUMP_STR(this->text));
+	lub_dump_printf("value      : %s\n", LUB_DUMP_STR(this->value));
 	lub_dump_printf("ptype      : %s\n", clish_ptype__get_name(this->ptype));
-	lub_dump_printf("default    : %s\n",
-		this->defval ? this->defval : "(null)");
+	lub_dump_printf("default    : %s\n", LUB_DUMP_STR(this->defval));
 	switch (this->mode) {
 	case CLISH_PARAM_COMMON:
 		mode = "COMMON";
@@ -36,12 +35,10 @@ void clish_param_dump(const clish_param_t * this)
 	}
 	lub_dump_printf("mode       : %s\n", mode);
 	lub_dump_printf("paramc     : %d\n", clish_paramv__get_count(this->paramv));
-	lub_dump_printf("optional   : %s\n",
-		this->optional ? "true" : "false");
-	lub_dump_printf("hidden     : %s\n",
-		this->hidden ? "true" : "false");
-	lub_dump_printf("test       : %s\n", this->test);
-	lub_dump_printf("completion : %s\n", this->completion);
+	lub_dump_printf("optional   : %s\n", LUB_DUMP_BOOL(this->optional));
+	lub_dump_printf("hidden     : %s\n", LUB_DUMP_BOOL(this->hidden));
+	lub_dump_printf("test       : %s\n", LUB_DUMP_STR(this->test));
+	lub_dump_printf("completion : %s\n", LUB_DUMP_STR(this->completion));
 
 	/* Get each parameter to dump their details */
 	for (i = 0; i < clish_paramv__get_count(this->paramv); i++) {

+ 6 - 7
clish/plugin/plugin_dump.c

@@ -16,8 +16,8 @@ void clish_sym_dump(const clish_sym_t *this)
 	lub_dump_printf("sym(%p)\n", this);
 
 	lub_dump_indent();
-	lub_dump_printf("name      : %s\n", this->name);
-	lub_dump_printf("func      : %p\n", this->func);
+	lub_dump_printf("name      : %s\n", LUB_DUMP_STR(this->name));
+	lub_dump_printf("func      : %p\n", LUB_DUMP_STR(this->func));
 	switch (this->type) {
 	case CLISH_SYM_TYPE_NONE:
 		type = "none";
@@ -39,8 +39,7 @@ void clish_sym_dump(const clish_sym_t *this)
 		break;
 	}
 	lub_dump_printf("type      : %s\n", type);
-	lub_dump_printf("permanent : %s\n",
-		this->permanent ? "true" : "false");
+	lub_dump_printf("permanent : %s\n", LUB_DUMP_BOOL(this->permanent));
 	lub_dump_printf("plugin    : %p\n", this->plugin);
 	lub_dump_undent();
 }
@@ -53,9 +52,9 @@ void clish_plugin_dump(const clish_plugin_t *this)
 
 	lub_dump_printf("plugin(%p)\n", this);
 	lub_dump_indent();
-	lub_dump_printf("name  : %s\n", this->name);
-	lub_dump_printf("alias : %s\n", this->alias);
-	lub_dump_printf("conf  : %s\n", this->conf);
+	lub_dump_printf("name  : %s\n", LUB_DUMP_STR(this->name));
+	lub_dump_printf("alias : %s\n", LUB_DUMP_STR(this->alias));
+	lub_dump_printf("conf  : %s\n", LUB_DUMP_STR(this->conf));
 	lub_dump_printf("dlhan : %p\n", this->dlhan);
 	lub_dump_printf("init  : %p\n", this->init);
 	lub_dump_printf("fini  : %p\n", this->fini);

+ 1 - 1
clish/ptype/ptype_dump.c

@@ -13,7 +13,7 @@ void clish_ptype_dump(clish_ptype_t * this)
 	lub_dump_indent();
 	lub_dump_printf("name       : %s\n", clish_ptype__get_name(this));
 	lub_dump_printf("text       : %s\n", clish_ptype__get_text(this));
-	lub_dump_printf("pattern    : %s\n", this->pattern);
+	lub_dump_printf("pattern    : %s\n", LUB_DUMP_STR(this->pattern));
 	lub_dump_printf("method     : %s\n",
 		clish_ptype_method__get_name(this->method));
 	lub_dump_printf("postprocess: %s\n",

+ 1 - 1
clish/shell/shell_dump.c

@@ -15,7 +15,7 @@ void clish_shell_dump(clish_shell_t * this)
 	lub_bintree_iterator_t iter;
 
 	lub_dump_printf("shell(%p)\n", this);
-	lub_dump_printf("OVERVIEW:\n%s", this->overview);
+	lub_dump_printf("OVERVIEW:\n%s\n", LUB_DUMP_STR(this->overview));
 	lub_dump_indent();
 
 	v = lub_bintree_findfirst(&this->view_tree);

+ 3 - 4
clish/var/var_dump.c

@@ -14,10 +14,9 @@ void clish_var_dump(const clish_var_t *this)
 	lub_dump_printf("var(%p)\n", this);
 	lub_dump_indent();
 
-	lub_dump_printf("name     : %s\n", this->name);
-	lub_dump_printf("dynamic  : %s\n",
-		this->dynamic ? "true" : "false");
-	lub_dump_printf("value    : %s\n", this->value);
+	lub_dump_printf("name     : %s\n", LUB_DUMP_STR(this->name));
+	lub_dump_printf("dynamic  : %s\n", LUB_DUMP_BOOL(this->dynamic));
+	lub_dump_printf("value    : %s\n", LUB_DUMP_STR(this->value));
 	clish_action_dump(this->action);
 
 	lub_dump_undent();

+ 4 - 0
lub/dump.h

@@ -14,6 +14,10 @@ easy.
 #ifndef _lub_dump_h
 #define _lub_dump_h
 
+#define LUB_DUMP_NULL "(null)"
+#define LUB_DUMP_STR(str) ( str ? str : LUB_DUMP_NULL )
+#define LUB_DUMP_BOOL(val) ( val ? "true" : "false" )
+
 #include <stdarg.h>
 /*=====================================
  * DUMP INTERFACE