From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20545 invoked by alias); 2 Jul 2002 21:57:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 20534 invoked from network); 2 Jul 2002 21:57:17 -0000 Received: from unknown (HELO potter.sfbay.redhat.com) (205.180.83.107) by sources.redhat.com with SMTP; 2 Jul 2002 21:57:17 -0000 Received: from localhost.localdomain (remus.sfbay.redhat.com [172.16.27.252]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g62LwQQ17935 for ; Tue, 2 Jul 2002 14:58:26 -0700 Content-Type: text/plain; charset="us-ascii" From: "Martin M. Hunt" Organization: Red Hat Inc To: gdb-patches@sources.redhat.com Subject: [RFA] add cmd_func() and cmd_func_p() Date: Tue, 02 Jul 2002 15:03:00 -0000 User-Agent: KMail/1.4.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200207021456.42204.hunt@redhat.com> X-SW-Source: 2002-07/txt/msg00049.txt.bz2 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 * 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"); +} + +