summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMartin Hunt <hunt@redhat.com>2002-07-03 17:35:21 +0000
committerMartin Hunt <hunt@redhat.com>2002-07-03 17:35:21 +0000
commitf13f42aac8ab611e14937f0c6135e945b13023e0 (patch)
tree62ba2efb26df4c49d41e7dec2c71f685df5e3fc7 /gdb
parent5d8c44f502d502221faff4038b800bc0ee4c4fc5 (diff)
downloadgdb-f13f42aac8ab611e14937f0c6135e945b13023e0.tar.gz
2002-07-03 Martin M. Hunt <hunt@redhat.com>
* top.c (execute_command): Use cmd_func() and cmd_func_p(). * cli/cli-decode.c (cmd_func_p): New function. (cmd_func): New function. * command.h: Add cmd_func() and cmd_func_p().
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/cli/cli-decode.c20
-rw-r--r--gdb/command.h6
-rw-r--r--gdb/top.c4
4 files changed, 37 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2b5cb26c7d6..44d27b535f8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2002-07-03 Martin M. Hunt <hunt@redhat.com>
+
+ * top.c (execute_command): Use cmd_func() and cmd_func_p().
+
+ * cli/cli-decode.c (cmd_func_p): New function.
+ (cmd_func): New function.
+
+ * command.h: Add cmd_func() and cmd_func_p().
+
2002-07-03 Grace Sainsbury <graces@redhat.com>
* config/mcore/tm-mcore.h (GDB_MULTI_ARCH): Add macro. Set to 0.
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 098c13a1989..84e445ee980 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1505,3 +1505,23 @@ complete_on_enum (const char *enumlist[],
return matchlist;
}
+
+/* check function pointer */
+int
+cmd_func_p (struct cmd_list_element *cmd)
+{
+ return (cmd->func != NULL);
+}
+
+
+/* call the command function */
+void
+cmd_func (struct cmd_list_element *cmd, char *args, int from_tty)
+{
+ if (cmd_func_p (cmd))
+ (*cmd->func) (cmd, args, from_tty);
+ else
+ error ("Invalid command");
+}
+
+
diff --git a/gdb/command.h b/gdb/command.h
index 9aceef6446a..96c99abcaba 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -280,4 +280,10 @@ extern void dont_repeat (void);
extern void not_just_help_class_command (char *, int);
+/* check function pointer */
+extern int cmd_func_p (struct cmd_list_element *cmd);
+
+/* call the command function */
+extern void cmd_func (struct cmd_list_element *cmd, char *args, int from_tty);
+
#endif /* !defined (COMMAND_H) */
diff --git a/gdb/top.c b/gdb/top.c
index 4749c381809..4203f08b616 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -703,12 +703,12 @@ execute_command (char *p, int from_tty)
execute_user_command (c, arg);
else if (c->type == set_cmd || c->type == show_cmd)
do_setshow_command (arg, from_tty & caution, c);
- else if (c->func == NULL)
+ else if (!cmd_func_p (c))
error ("That is not a command, just a help topic.");
else if (call_command_hook)
call_command_hook (c, arg, from_tty & caution);
else
- (*c->func) (c, arg, from_tty & caution);
+ cmd_func (c, arg, from_tty & caution);
/* If this command has been post-hooked, run the hook last. */
execute_cmd_post_hook (c);