From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6231 invoked by alias); 27 Apr 2005 18:04:26 -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 6098 invoked from network); 27 Apr 2005 18:04:13 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 27 Apr 2005 18:04:13 -0000 Received: from drow by nevyn.them.org with local (Exim 4.50 #1 (Debian)) id 1DQqtO-000597-9H; Wed, 27 Apr 2005 14:04:10 -0400 Date: Wed, 27 Apr 2005 18:04:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: bug-gdb@rich-paul.net, bug-gdb@gnu.org, gdb-patches@sources.redhat.com Subject: Re: [RFA] Fix file name generation in edit_command (was: Ver 6.3 edit command failing) Message-ID: <20050427180410.GA19592@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , bug-gdb@rich-paul.net, bug-gdb@gnu.org, gdb-patches@sources.redhat.com References: <01c54b35$Blat.v2.4$c3f52520@zahav.net.il> <20050427143620.GA1686@nevyn.them.org> <01c54b40$Blat.v2.4$be3bafe0@zahav.net.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01c54b40$Blat.v2.4$be3bafe0@zahav.net.il> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-04/txt/msg00371.txt.bz2 On Wed, Apr 27, 2005 at 06:48:46PM +0300, Eli Zaretskii wrote: > Thanks for the tip. Here's the revised patch: The rest of this is mostly stylistic; a few comments... > + /* If we don't already know the full absolute file name of the > + source file, find it now. */ > + if (NULL == sal.symtab->fullname) > + { > + fn = symtab_to_fullname (sal.symtab); > + if (NULL == fn) > + fn = "unknown"; > + } > + else > + fn = sal.symtab->fullname; > + > + /* $EDITOR blank +NN blank file \0 */ > + cmdlen = strlen(editor) + 1 + log10 + 2 + strlen(fn) + 1; > p = xmalloc(cmdlen); > - sprintf(p,"%s +%d %s%s",editor,sal.line, > - (NULL == sal.symtab->dirname ? "./" : > - (NULL != sal.symtab->filename && *(sal.symtab->filename) != '/') ? > - sal.symtab->dirname : ""), > - (NULL == sal.symtab->filename ? "unknown" : sal.symtab->filename) > - ); > + sprintf (p, "%s +%d %s", editor, sal.line, fn); It strikes me as odd that you can use "edit" if GDB doesn't know where the source file is. I realize this is a pre-existing condition, but... Also, symtab_to_fullname includes the cached fullname check. So what's your opinion of boiling the whole thing down to: fn = symtab_to_fullname (sal.symtab); if (fn == NULL) error (_("Could not find file \"%s\""), sal.symtab->filename); p = xstrprintf ("%s +%d %s", editor, sal.line, fn); Mark, can I have those bonus points? :-) -- Daniel Jacobowitz CodeSourcery, LLC