* [RFA] add cmd_func() and cmd_func_p()
@ 2002-07-02 15:03 Martin M. Hunt
2002-07-03 10:09 ` Andrew Cagney
0 siblings, 1 reply; 2+ messages in thread
From: Martin M. Hunt @ 2002-07-02 15:03 UTC (permalink / raw)
To: gdb-patches
These functions take another step towards making the command
struct more opaque and more portable. They are required for
an Insight fix, too.
--
Martin Hunt
GDB Engineer
Red Hat, Inc.
2002-07-02 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().
Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.34
diff -u -u -r1.34 command.h
--- command.h 26 Jun 2002 20:58:16 -0000 1.34
+++ command.h 2 Jul 2002 21:53:50 -0000
@@ -280,4 +280,10 @@
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) */
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.62
diff -u -u -r1.62 top.c
--- top.c 23 Apr 2002 03:00:57 -0000 1.62
+++ top.c 2 Jul 2002 21:53:51 -0000
@@ -703,12 +703,12 @@
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);
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.26
diff -u -u -r1.26 cli-decode.c
--- cli/cli-decode.c 26 Jun 2002 20:58:17 -0000 1.26
+++ cli/cli-decode.c 2 Jul 2002 21:53:51 -0000
@@ -1505,3 +1505,23 @@
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");
+}
+
+
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFA] add cmd_func() and cmd_func_p()
2002-07-02 15:03 [RFA] add cmd_func() and cmd_func_p() Martin M. Hunt
@ 2002-07-03 10:09 ` Andrew Cagney
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2002-07-03 10:09 UTC (permalink / raw)
To: Martin M. Hunt; +Cc: gdb-patches
> 2002-07-02 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().
>
Yes, definitly.
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-07-03 15:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-02 15:03 [RFA] add cmd_func() and cmd_func_p() Martin M. Hunt
2002-07-03 10:09 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox