diff options
author | Steve Bennett <steveb@workware.net.au> | 2023-07-13 08:29:37 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2023-07-13 08:32:17 +1000 |
commit | 067a64f3ffccf38cfadbfe0f906d59634f869352 (patch) | |
tree | df9d9d94a851128ace22d661313bced469c204b0 | |
parent | c7c8f9b13436861037dbf1d5d57937207f47a153 (diff) | |
download | jimtcl-067a64f3ffccf38cfadbfe0f906d59634f869352.zip jimtcl-067a64f3ffccf38cfadbfe0f906d59634f869352.tar.gz jimtcl-067a64f3ffccf38cfadbfe0f906d59634f869352.tar.bz2 |
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 <steveb@workware.net.au>
-rw-r--r-- | jim.c | 19 | ||||
-rwxr-xr-x | make-bootstrap-jim | 2 |
2 files changed, 13 insertions, 8 deletions
@@ -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 <stdio.h> #include <stdlib.h> @@ -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:) diff --git a/make-bootstrap-jim b/make-bootstrap-jim index 0711e1d..67ac71b 100755 --- a/make-bootstrap-jim +++ b/make-bootstrap-jim @@ -49,7 +49,7 @@ allexts="bootstrap aio readdir regexp file glob exec posix clock array stdlib tc echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */" # define some core features -for i in JIM_TCL_COMPAT JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do +for i in JIM_TCL_COMPAT JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF JIM_TINY _JIMAUTOCONF_H; do echo "#define $i" done echo '#define TCL_LIBRARY "."' |