fix: three correctness fixes before PR

tclmagic.c: remove stray /*-----*/ line left over from a previous edit
that left a duplicate comment opener before TclmagicRegisterCommands.

magicWasm.c: move TxSetPoint inside the #else (non-TCL) branch of
magic_wasm_source_file and restore its explanation comment. TxSetPoint
routes TxDispatch commands to the layout window; it is irrelevant and
misleading in the Tcl_EvalFile path.

magic/Makefile: guard the TCL linker flags in the magic.js link rule
with ifneq (${TCL_LIB_DIR},). When building the non-TCL WASM variant
TCL_LIB_DIR is empty, so the unconditional -L${TCL_LIB_DIR} -ltclstub
expanded to a bare -L flag and a missing library, breaking the notcl
build.
This commit is contained in:
Intubun 2026-05-21 14:20:39 +02:00
parent fc3d8cf352
commit 7e26b59f38
3 changed files with 14 additions and 9 deletions

View File

@ -52,15 +52,18 @@ magicWasm.o: magicWasm.c
${RM} magicWasm.o ${RM} magicWasm.o
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS_NOSTUB} -c magicWasm.c ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS_NOSTUB} -c magicWasm.c
# Pull in BOTH the main TCL archive (LIB_SPECS_NOSTUB → -ltcl9.x) and the
# stub bootstrap archive (-L${TCL_LIB_DIR} -ltclstub). Magic's source uses
# USE_TCL_STUBS macros, so tclStubsPtr (defined in libtclstub.a) and
# Tcl_InitStubs must be present in the same binary as the actual TCL
# implementation from libtcl9.x.a.
magic.js: lib${MODULE}.o ${EXTRA_LIBS} magic.js: lib${MODULE}.o ${EXTRA_LIBS}
@echo --- building main magic WASM @echo --- building main magic WASM
${RM} magic.js magic.wasm ${RM} magic.js magic.wasm
ifneq (${TCL_LIB_DIR},)
# TCL variant: pull in the main TCL archive (LIB_SPECS_NOSTUB → -ltcl9.x) and
# the stub-bootstrap archive (-ltclstub). Both are required: magic's objects
# use USE_TCL_STUBS macros (resolved by tclStubsPtr from libtclstub.a), and
# tclStubsPtr itself must point into the real TCL implementation (libtcl9.x.a).
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS} ${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} -ltclstub ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS} ${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} -ltclstub
else
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS}
endif
endif endif
main: magic proto.magicrc main: magic proto.magicrc

View File

@ -157,9 +157,6 @@ magic_wasm_source_file(const char *path)
if ((path == NULL) || (*path == '\0')) if ((path == NULL) || (*path == '\0'))
return -1; return -1;
TxSetPoint(GrScreenRect.r_xtop / 2, GrScreenRect.r_ytop / 2,
WIND_UNKNOWN_WINDOW);
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
/* In wrapper mode the file contains Tcl; evaluate it through the /* In wrapper mode the file contains Tcl; evaluate it through the
* Tcl interpreter so that magic:: commands are dispatched via * Tcl interpreter so that magic:: commands are dispatched via
@ -176,6 +173,12 @@ magic_wasm_source_file(const char *path)
TxError("Unable to open command file \"%s\".\n", path); TxError("Unable to open command file \"%s\".\n", path);
return -1; return -1;
} }
/* Set the current point to the center of the screen so that
* WindSendCommand routes all commands from the file to the layout
* window client. Without this, commands arrive with point (0,0)
* and end up in the border/windClient context where most are unknown. */
TxSetPoint(GrScreenRect.r_xtop / 2, GrScreenRect.r_ytop / 2,
WIND_UNKNOWN_WINDOW);
TxDispatch(f); TxDispatch(f);
fclose(f); fclose(f);
return 0; return 0;

View File

@ -656,7 +656,6 @@ process_rlimit_startup_check(void)
#endif /* HAVE_GETRLIMIT */ #endif /* HAVE_GETRLIMIT */
} }
/*------------------------------------------------------*/
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
/* Register magic:: commands with the Tcl interpreter. */ /* Register magic:: commands with the Tcl interpreter. */
/* Called after Magic's C subsystems are fully */ /* Called after Magic's C subsystems are fully */