Skip to content

Commit 067a64f

Browse files
committed
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 <[email protected]>
1 parent c7c8f9b commit 067a64f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

jim.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
* are those of the authors and should not be interpreted as representing
4141
* official policies, either expressed or implied, of the Jim Tcl Project.
4242
**/
43+
#ifndef JIM_TINY
4344
#define JIM_OPTIMIZATION /* comment to avoid optimizations and reduce size */
45+
#endif
4446

4547
#include <stdio.h>
4648
#include <stdlib.h>
@@ -107,7 +109,9 @@
107109
/* Maximum size of an integer */
108110
#define JIM_INTEGER_SPACE 24
109111

110-
const char *jim_tt_name(int type);
112+
#if defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND)
113+
static const char *jim_tt_name(int type);
114+
#endif
111115

112116
#ifdef JIM_DEBUG_PANIC
113117
static void JimPanicDump(int fail_condition, const char *fmt, ...);
@@ -9264,7 +9268,8 @@ static int JimParseExprOperator(struct JimParserCtx *pc)
92649268
return JIM_OK;
92659269
}
92669270

9267-
const char *jim_tt_name(int type)
9271+
#if (defined(DEBUG_SHOW_SCRIPT) || defined(DEBUG_SHOW_SCRIPT_TOKENS) || defined(JIM_DEBUG_COMMAND)) && !defined(JIM_BOOTSTRAP)
9272+
static const char *jim_tt_name(int type)
92689273
{
92699274
static const char * const tt_names[JIM_TT_EXPR_OP] =
92709275
{ "NIL", "STR", "ESC", "VAR", "ARY", "CMD", "SEP", "EOL", "EOF", "LIN", "WRD", "(((", ")))", ",,,", "INT",
@@ -9289,6 +9294,7 @@ const char *jim_tt_name(int type)
92899294
return buf;
92909295
}
92919296
}
9297+
#endif /* !JIM_BOOTSTRAP */
92929298

92939299
/* -----------------------------------------------------------------------------
92949300
* Expression Object
@@ -12471,15 +12477,14 @@ static int Jim_ForCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv
1247112477
while (boolean && (retval == JIM_OK || retval == JIM_CONTINUE)) {
1247212478
/* Body */
1247312479
retval = Jim_EvalObj(interp, argv[4]);
12474-
12480+
if (JimCheckLoopRetcode(interp, retval)) {
12481+
immediate++;
12482+
break;
12483+
}
1247512484
if (retval == JIM_OK || retval == JIM_CONTINUE) {
1247612485
/* increment */
1247712486
JIM_IF_OPTIM(evalnext:)
1247812487
retval = Jim_EvalObj(interp, argv[3]);
12479-
if (JimCheckLoopRetcode(interp, retval)) {
12480-
immediate++;
12481-
goto out;
12482-
}
1248312488
if (retval == JIM_OK || retval == JIM_CONTINUE) {
1248412489
/* test */
1248512490
JIM_IF_OPTIM(testcond:)

make-bootstrap-jim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ allexts="bootstrap aio readdir regexp file glob exec posix clock array stdlib tc
4949
echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */"
5050

5151
# define some core features
52-
for i in JIM_TCL_COMPAT JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do
52+
for i in JIM_TCL_COMPAT JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF JIM_TINY _JIMAUTOCONF_H; do
5353
echo "#define $i"
5454
done
5555
echo '#define TCL_LIBRARY "."'

0 commit comments

Comments
 (0)