From: "Martin M. Hunt" <hunt@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] add cmd_func() and cmd_func_p()
Date: Tue, 02 Jul 2002 15:03:00 -0000 [thread overview]
Message-ID: <200207021456.42204.hunt@redhat.com> (raw)
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");
+}
+
+
next reply other threads:[~2002-07-02 21:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-02 15:03 Martin M. Hunt [this message]
2002-07-03 10:09 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200207021456.42204.hunt@redhat.com \
--to=hunt@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox