diff mbox

sim: nrun: use lbasename [committed]

Message ID 1451812119-14946-1-git-send-email-vapier@gentoo.org
State Committed
Headers show

Commit Message

Mike Frysinger Jan. 3, 2016, 9:08 a.m. UTC
---
 sim/common/ChangeLog | 6 ++++++
 sim/common/nrun.c    | 8 +++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
diff mbox

Patch

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  <vapier@gentoo.org>
 
+	* nrun.c (myname): Mark const.
+	(main): Mark name const.  Replace myname parsing loop with a
+	call to lbasename.
+
+2016-01-03  Mike Frysinger  <vapier@gentoo.org>
+
 	(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