From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13170 invoked by alias); 2 Apr 2003 16:15:57 -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 13160 invoked from network); 2 Apr 2003 16:15:55 -0000 Received: from unknown (HELO white) (68.14.146.65) by sources.redhat.com with SMTP; 2 Apr 2003 16:15:55 -0000 Received: from bob by white with local (Exim 3.35 #1 (Debian)) id 190ku2-0003V1-00; Wed, 02 Apr 2003 11:15:54 -0500 Date: Wed, 02 Apr 2003 16:15:00 -0000 From: Bob Rossi To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: Adding -file-list-exec-source-file command to GDB/MI Message-ID: <20030402161554.GB13251@white> Mail-Followup-To: Andrew Cagney , gdb-patches@sources.redhat.com References: <20030329004109.GA7487@white> <3E87D445.70609@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E87D445.70609@redhat.com> User-Agent: Mutt/1.3.28i X-SW-Source: 2003-04/txt/msg00029.txt.bz2 > >enum mi_cmd_result > >mi_cmd_file_list_exec_source_file(char *command, char **argv, int argc) > >{ > > struct symtab_and_line st; > > See: > http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=783 > > Even though there are no arguments it will want to discard any "--". A > mi_getopt() call to strip off any leading "--". I think you'll want to > tweak that function so that calling it is easier - allow NULL OPT and > OPTARG? Ok, I've got all the changes down but this one. Instead of changing mi_getopt, I wrote a wrapper function called extern int mi_valid_noargs (const char *prefix, int argc, char **argv); and put it in mi_getopt.[ch]. This function basically returns 1 if the arguments are valid for a function that takes no arguments, and 0 otherwise. What do you think? The reason I like this solution is because the caller doesn't need to concern itself with mi_getopt. So if the interface ever changes to mi_getopt, there will be less spots to fix. Also, It keeps the client smaller and less confusing. Bob Rossi The body looks something like this. extern int mi_valid_noargs(const char *prefix, int argc, char **argv) { int optind = 0; char *optarg; static struct mi_opt opts[] = { 0 }; int opt = mi_getopt(prefix, argc, argv, opts, &optind, &optarg); /* The end of the list was reached first try */ if ( opt == -1 ) return 1; else return 0; }