From d12ae2a3f39f21ee5c729cba5d5f305b3be05480 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 11 Apr 2019 12:35:06 -0700 Subject: [PATCH] SCP: Allow a bare % at the end of a line for SET THROTTLE nn% Fix #678 --- scp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scp.c b/scp.c index 09d5d96d..cbab9b55 100644 --- a/scp.c +++ b/scp.c @@ -4095,7 +4095,7 @@ return ap; Token "%0" represents the command file name. - The input sequence "\%" represents a literal "%", and "\\" represents a + The input sequence "%%" represents a literal "%", and "\\" represents a literal "\". All other character combinations are rendered literally. Omitted parameters result in null-string substitutions. @@ -4202,11 +4202,16 @@ for (; *ip && (op < oend); ) { ++ip; } else { - get_glyph_nc (ip, gbuf, '%'); /* get the literal name */ - ap = _sim_get_env_special (gbuf, rbuf, sizeof (rbuf)); - ip += strlen (gbuf); - if (*ip == '%') - ++ip; + if (*ip == '\0') { /* is this a bare % at end of line? */ + *op++ = '%'; /* leave it there as a literal percent sign */ + } + else { + get_glyph_nc (ip, gbuf, '%'); /* get the literal name */ + ap = _sim_get_env_special (gbuf, rbuf, sizeof (rbuf)); + ip += strlen (gbuf); + if (*ip == '%') + ++ip; + } } } if (ap) { /* non-null arg? */