From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27278 invoked by alias); 28 Jul 2008 15:50:30 -0000 Received: (qmail 27266 invoked by uid 22791); 28 Jul 2008 15:50:29 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 28 Jul 2008 15:50:11 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6SFo9bc006446 for ; Mon, 28 Jul 2008 11:50:09 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6SFo8JR001059; Mon, 28 Jul 2008 11:50:08 -0400 Received: from opsy.redhat.com (vpn-10-11.bos.redhat.com [10.16.10.11]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6SFo8QV017008; Mon, 28 Jul 2008 11:50:08 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id AD71B3784E1; Mon, 28 Jul 2008 09:50:07 -0600 (MDT) To: gdb-patches@sourceware.org Subject: RFA: clean up edit_command From: Tom Tromey Reply-To: Tom Tromey X-Attribution: Tom Date: Mon, 28 Jul 2008 15:50:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00518.txt.bz2 I noticed some weird code in edit_command yesterday. Ordinarily I do not like to mix code changes and formatting fixes, but in this case, I think it is warranted... the code change here is just removing a dead loop. The formatting fixes are the usual: bad brace style, bad indentation, wrong comment style, spacing missing before "("... this function had them all :) Built and regtested on the GCC compile farm (x86-64). Ok? Tom 2008-07-28 Tom Tromey * cli/cli-cmds.c (edit_command): Remove unused variables. Delete dead code. Fix indentation. diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 8dc178e..16fbf3d 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -615,12 +615,11 @@ edit_command (char *arg, int from_tty) struct symtab_and_line sal; struct symbol *sym; char *arg1; - int cmdlen, log10; - unsigned m; + int cmdlen; char *editor; char *p, *fn; - /* Pull in the current default source line if necessary */ + /* Pull in the current default source line if necessary. */ if (arg == 0) { set_default_source_symtab_and_line (); @@ -638,17 +637,22 @@ edit_command (char *arg, int from_tty) else { - /* Now should only be one argument -- decode it in SAL */ + /* Now should only be one argument -- decode it in SAL. */ arg1 = arg; sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0); - if (! sals.nelts) return; /* C++ */ - if (sals.nelts > 1) { - ambiguous_line_spec (&sals); - xfree (sals.sals); - return; - } + if (! sals.nelts) + { + /* C++ */ + return; + } + if (sals.nelts > 1) + { + ambiguous_line_spec (&sals); + xfree (sals.sals); + return; + } sal = sals.sals[0]; xfree (sals.sals); @@ -656,7 +660,7 @@ edit_command (char *arg, int from_tty) if (*arg1) error (_("Junk at end of line specification.")); - /* if line was specified by address, + /* If line was specified by address, first print exactly which line, and which file. In this case, sal.symtab == 0 means address is outside of all known source files, not that user failed to give a filename. */ @@ -686,10 +690,6 @@ edit_command (char *arg, int from_tty) if ((editor = (char *) getenv ("EDITOR")) == NULL) editor = "/bin/ex"; - /* Approximate base-10 log of line to 1 unit for digit count */ - for(log10=32, m=0x80000000; !(sal.line & m) && log10>0; log10--, m=m>>1); - log10 = 1 + (int)((log10 + (0 == ((m-1) & sal.line)))/3.32192809); - /* If we don't already know the full absolute file name of the source file, find it now. */ if (!sal.symtab->fullname) @@ -704,8 +704,8 @@ edit_command (char *arg, int from_tty) /* Quote the file name, in case it has whitespace or other special characters. */ p = xstrprintf ("%s +%d \"%s\"", editor, sal.line, fn); - shell_escape(p, from_tty); - xfree(p); + shell_escape (p, from_tty); + xfree (p); } static void