This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] sim: nrun: use lbasename
- From: Michael Frysinger <vapier at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 3 Jan 2016 09:08:44 -0000
- Subject: [binutils-gdb] sim: nrun: use lbasename
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aba6f46b235a3a139c04d5ed6a3310125aa9c982
commit aba6f46b235a3a139c04d5ed6a3310125aa9c982
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sun Jan 3 01:44:44 2016 -0500
sim: nrun: use lbasename
Diff:
---
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 <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