From b935a2dafc50db7eef328aa2444487b50c911015 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 20 Jun 2016 11:54:28 -0700 Subject: [PATCH] SCP: Make sure SIM_BIN_NAME environment variable is always defined. Previously it would only be defined in certain instances and after processing some combinations of startup files. --- scp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scp.c b/scp.c index d0d559c9..28a218d4 100644 --- a/scp.c +++ b/scp.c @@ -1974,7 +1974,20 @@ if (!sim_quiet) { } if (sim_dflt_dev == NULL) /* if no default */ sim_dflt_dev = sim_devices[0]; +if (*argv[0]) { /* sim name arg? */ + char *np; /* "path.ini" */ + strncpy (nbuf, argv[0], PATH_MAX + 1); /* copy sim name */ + if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */ + *np = 0; + np = strrchr (nbuf, '/'); /* stript path and try again in cwd */ + if (np == NULL) + np = strrchr (nbuf, '\\'); /* windows path separator */ + if (np == NULL) + np = strrchr (nbuf, ']'); /* VMS path separator */ + if (np != NULL) + setenv ("SIM_BIN_NAME", np, 1); /* Publish simulator binary name */ + } sim_argv = argv; cptr = getenv("HOME"); if (cptr == NULL) { @@ -2006,12 +2019,8 @@ else if (*argv[0]) { /* sim name arg? */ if (np == NULL) np = strrchr (nbuf, ']'); /* VMS path separator */ if (np != NULL) { - char *sim_bin_name = np; /* Save name pointer */ - *np = '"'; stat = do_cmd (-1, np) & ~SCPE_NOMESSAGE; /* proc default cmd file */ - np[strlen (np) - 4] = '\0'; /* strip .ini" */ - setenv ("SIM_BIN_NAME", sim_bin_name+1, 1); /* Publish simulator binary name */ } } }