From f89a65ff2f094aea64cb8283c4e2887b6881d3a2 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 12 Jun 2018 02:03:07 -0700 Subject: [PATCH] SCP: Revert pre-insertion of %n to be done during normal expansion. --- scp.c | 118 ++++++++++++++++++++++------------------------------------ 1 file changed, 45 insertions(+), 73 deletions(-) diff --git a/scp.c b/scp.c index fd6b5167..1faa267f 100644 --- a/scp.c +++ b/scp.c @@ -581,7 +581,7 @@ static int32 sim_show_message = 1; /* the message display s static int32 sim_on_inherit = 0; /* the inherit status of on state and conditions when executing do files */ static int32 sim_do_depth = 0; static t_bool sim_cmd_echoed = FALSE; /* Command was emitted already prior to message output */ - +static char **sim_exp_argv = NULL; static int32 sim_on_check[MAX_DO_NEST_LVL+1]; static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+2]; #define ON_SIGINT_ACTION (SCPE_MAX_ERR+1) @@ -3778,79 +3778,19 @@ return ap; Omitted parameters result in null-string substitutions. */ -static void -_sub_args (char *instr, char *tmpbuf, size_t str_size, char *do_arg[]) -{ -char *ip, *op, *ap, *oend = tmpbuf + str_size - 2; -int i; -char rbuf[CBUFSIZE]; - -for (ip = instr, op = tmpbuf; *ip && (op < oend); ) { - if ((ip [0] == '\\') && /* literal escape? */ - ((ip [1] == '%') || (ip [1] == '\\'))) { /* and followed by '%' or '\'? */ - *op++ = *ip++; /* copy \ */ - *op++ = *ip++; /* copy escaped char */ - } - else { - if ((*ip == '%') && /* %n = sub */ - (sim_isdigit(ip[1]) || (ip[1] == '*'))) { - if ((ip[1] >= '0') && (ip[1] <= '9')) { - ap = do_arg[ip[1] - '0']; - for (i=0; i sim_sub_instr_size) { @@ -3891,14 +3831,46 @@ for (; *ip && (op < oend); ) { ip++; /* skip one */ *op++ = *ip++; /* copy insert % */ } - else { + else if ((*ip == '%') && - (sim_isalpha(ip[1]) || (ip[1] == '_'))) { /* sub env or special? */ - get_glyph_nc (ip+1, gbuf, '%'); /* get the literal name */ - ap = _sim_get_env_special (gbuf, rbuf, sizeof (rbuf)); - ip += 1 + strlen (gbuf); - if (*ip == '%') - ++ip; + (sim_isalnum(ip[1]) || (ip[1] == '*') || (ip[1] == '_'))) {/* sub? */ + if ((ip[1] >= '0') && (ip[1] <= ('9'))) { /* %n = sub */ + ap = do_arg[ip[1] - '0']; + for (i=0; i