summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tcl.h6
-rw-r--r--generic/tclStubLib.c25
2 files changed, 20 insertions, 11 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 9ea2e90..c18b251 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -136,6 +136,7 @@ extern "C" {
*/
#include <stdio.h>
+#include <stddef.h>
/*
*----------------------------------------------------------------------------
@@ -2274,12 +2275,9 @@ typedef int (Tcl_NRPostProc) (ClientData data[], Tcl_Interp *interp,
*----------------------------------------------------------------------------
* The following constant is used to test for older versions of Tcl in the
* stubs tables.
- *
- * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different
- * value since the stubs tables don't match.
*/
-#define TCL_STUB_MAGIC ((int) 0xFCA3BACF)
+#define TCL_STUB_MAGIC ((int) 0xFCA3BACB + sizeof(size_t))
/*
* The following function is required to be defined in all stubs aware
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index f569820..bd8f6e7 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -38,14 +38,25 @@ HasStubSupport(
{
Interp *iPtr = (Interp *) interp;
- if (iPtr->stubTable && (iPtr->stubTable->magic == TCL_STUB_MAGIC)) {
- return iPtr->stubTable;
+ if (!iPtr->stubTable) {
+ /* No stub table at all? Nothing we can do. */
+ return NULL;
}
-
- iPtr->result =
- (char *)"This interpreter does not support stubs-enabled extensions.";
- iPtr->freeProc = TCL_STATIC;
- return NULL;
+ if (iPtr->stubTable->magic != TCL_STUB_MAGIC) {
+ /*
+ * The iPtr->stubTable entry from Tcl_Interp and the
+ * Tcl_NewStringObj() and Tcl_SetObjResult() entries
+ * in the stub table cannot change in Tcl 9 compared
+ * to Tcl 8.x. Otherwise the lines below won't work.
+ * TODO: add a test case for that.
+ */
+ iPtr->stubTable->tcl_SetObjResult(interp,
+ iPtr->stubTable->tcl_NewStringObj(
+ "This extension is compiled for Tcl 9.x",
+ TCL_NOSIZE));
+ return NULL;
+ }
+ return iPtr->stubTable;
}
/*