From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17350 invoked by alias); 2 Apr 2003 16:27:20 -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 17343 invoked from network); 2 Apr 2003 16:27:20 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 2 Apr 2003 16:27:20 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id AC56E2B23; Wed, 2 Apr 2003 11:27:18 -0500 (EST) Message-ID: <3E8B0F66.8070403@redhat.com> Date: Wed, 02 Apr 2003 16:27:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bob Rossi Cc: gdb-patches@sources.redhat.com Subject: Re: Adding -file-list-exec-source-file command to GDB/MI References: <20030329004109.GA7487@white> <3E87D445.70609@redhat.com> <20030402161554.GB13251@white> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-04/txt/msg00030.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. Ah, yes and yep. You'll need to GNUtify the coding style :-) > 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; > } >