From 067a64f3ffccf38cfadbfe0f906d59634f869352 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 13 Jul 2023 08:29:37 +1000 Subject: core: Fix 'for' with JIM_OPTIMIZATION disabled And allow -DJIM_TINY to disable optimisation, and use that with bootstrap jimsh. Fixes #273 Signed-off-by: Steve Bennett --- jim.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'jim.c') diff --git a/jim.c b/jim.c index 30fc067..d8682e4 100644 --- a/jim.c +++ b/jim.c @@ -40,7 +40,9 @@ * are those of the authors and should not be interpreted as representing * official policies, either expressed or implied, of the Jim Tcl Project. **/ +#ifndef JIM_TINY #define JIM_OPTIMIZATION /* comment to avoid optimizations and reduce size */ +#endif #include #include @@ -107,7 +109,9 @@ /* Maximum size of an integer */ #define JIM_INTEGER_SPACE 24 -const char *jim_tt_name(int type); +#if defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND) +static const char *jim_tt_name(int type); +#endif #ifdef JIM_DEBUG_PANIC static void JimPanicDump(int fail_condition, const char *fmt, ...); @@ -9264,7 +9268,8 @@ static int JimParseExprOperator(struct JimParserCtx *pc) return JIM_OK; } -const char *jim_tt_name(int type) +#if (defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND)) && !defined(JIM_BOOTSTRAP) +static const char *jim_tt_name(int type) { static const char * const tt_names[JIM_TT_EXPR_OP] = { "NIL", "STR", "ESC", "VAR", "ARY", "CMD", "SEP", "EOL", "EOF", "LIN", "WRD", "(((", ")))", ",,,", "INT", @@ -9289,6 +9294,7 @@ const char *jim_tt_name(int type) return buf; } } +#endif /* !JIM_BOOTSTRAP */ /* ----------------------------------------------------------------------------- * Expression Object @@ -12471,15 +12477,14 @@ static int Jim_ForCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv while (boolean && (retval == JIM_OK || retval == JIM_CONTINUE)) { /* Body */ retval = Jim_EvalObj(interp, argv[4]); - + if (JimCheckLoopRetcode(interp, retval)) { + immediate++; + break; + } if (retval == JIM_OK || retval == JIM_CONTINUE) { /* increment */ JIM_IF_OPTIM(evalnext:) retval = Jim_EvalObj(interp, argv[3]); - if (JimCheckLoopRetcode(interp, retval)) { - immediate++; - goto out; - } if (retval == JIM_OK || retval == JIM_CONTINUE) { /* test */ JIM_IF_OPTIM(testcond:) -- cgit v1.1