From patchwork Sun Jan 3 09:08:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 10201 Received: (qmail 59729 invoked by alias); 3 Jan 2016 09:08:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 59657 invoked by uid 89); 3 Jan 2016 09:08:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sig, INTERNAL, 729, 647 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 03 Jan 2016 09:08:43 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 287E1340139 for ; Sun, 3 Jan 2016 09:08:41 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: nrun: use lbasename [committed] Date: Sun, 3 Jan 2016 04:08:39 -0500 Message-Id: <1451812119-14946-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes --- sim/common/ChangeLog | 6 ++++++ sim/common/nrun.c | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index d931834..2e444d1 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,5 +1,11 @@ 2016-01-03 Mike Frysinger + * nrun.c (myname): Mark const. + (main): Mark name const. Replace myname parsing loop with a + call to lbasename. + +2016-01-03 Mike Frysinger + (CONFIG_CFLAGS): Delte $(SIM_HOSTENDIAN). * acinclude.m4 (SIM_AC_COMMON): Call AC_C_BIGENDIAN. (SIM_AC_OPTION_HOSTENDIAN): Delete. diff --git a/sim/common/nrun.c b/sim/common/nrun.c index 2e47715..94ba35d 100644 --- a/sim/common/nrun.c +++ b/sim/common/nrun.c @@ -47,7 +47,7 @@ static void usage (void); extern host_callback default_callback; -static char *myname; +static const char *myname; static SIM_DESC sd; @@ -64,7 +64,7 @@ cntrl_c (int sig) int main (int argc, char **argv) { - char *name; + const char *name; char **prog_argv = NULL; struct bfd *prog_bfd; enum sim_stop reason; @@ -72,9 +72,7 @@ main (int argc, char **argv) int single_step = 0; RETSIGTYPE (*prev_sigint) (); - myname = argv[0] + strlen (argv[0]); - while (myname > argv[0] && myname[-1] != '/') - --myname; + myname = lbasename (argv[0]); /* INTERNAL: When MYNAME is `step', single step the simulator instead of allowing it to run free. The sole purpose of this