From aba6f46b235a3a139c04d5ed6a3310125aa9c982 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 3 Jan 2016 01:44:44 -0500 Subject: [PATCH] sim: nrun: use lbasename --- 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 -- 2.7.4