Skip to content

Commit d161274

Browse files
committed
subst: don't ignore vars after first failed var
If $ is followed by something that isn't a variable name, previously all subsequent variables were being ignored. Fixes #296 Signed-off-by: Steve Bennett <[email protected]>
1 parent 67e32c8 commit d161274

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

jim.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
/* Maximum size of an integer */
110110
#define JIM_INTEGER_SPACE 24
111111

112-
#if defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND)
112+
#if defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND) || defined(DEBUG_SHOW_SUBST)
113113
static const char *jim_tt_name(int type);
114114
#endif
115115

@@ -9273,7 +9273,7 @@ static int JimParseExprOperator(struct JimParserCtx *pc)
92739273
return JIM_OK;
92749274
}
92759275

9276-
#if (defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND)) && !defined(JIM_BOOTSTRAP)
9276+
#if (defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND) || defined(DEBUG_SHOW_SUBST)) && !defined(JIM_BOOTSTRAP)
92779277
static const char *jim_tt_name(int type)
92789278
{
92799279
static const char * const tt_names[JIM_TT_EXPR_OP] =
@@ -11736,7 +11736,9 @@ static void JimParseSubst(struct JimParserCtx *pc, int flags)
1173611736
}
1173711737
/* Not a var, so treat as a string */
1173811738
pc->tstart = pc->p;
11739-
flags |= JIM_SUBST_NOVAR;
11739+
/* Skip this $ */
11740+
pc->p++;
11741+
pc->len--;
1174011742
}
1174111743
while (pc->len) {
1174211744
if (*pc->p == '$' && !(flags & JIM_SUBST_NOVAR)) {

tests/subst.test

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ test subst-12.3 {variable inside [] with -noc} {
176176
subst -noc {x[join $a]y}
177177
} {x[join 1]y}
178178

179+
test subst-12.4 {variable after not variable} {
180+
set a 1
181+
subst -noc {$\[ $a}
182+
} {$[ 1}
183+
179184

180185
# cleanup
181186
testreport

0 commit comments

Comments
 (0)