summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-11-18 17:24:05 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-11-18 17:24:05 (GMT)
commitba3714a1c6b066ad7d41fcb1dadf84ade25f1499 (patch)
tree94ee36a735f6c211d16b65f62dd4e6a4f733db55
parentfd54c8a9d81e0a3758b2029ab0d8d962a9038e14 (diff)
parent56b9df62a1c1b096f9dcd04ea18dc8b2d19fc249 (diff)
downloadtcl-ba3714a1c6b066ad7d41fcb1dadf84ade25f1499.zip
tcl-ba3714a1c6b066ad7d41fcb1dadf84ade25f1499.tar.gz
tcl-ba3714a1c6b066ad7d41fcb1dadf84ade25f1499.tar.bz2
change stub library to detect - and generate a nice error-message -
when a shared library compiled for Tcl 9.x is attempted to be loaded in Tcl 8.x. Change MAGIC value in stub tables for 64-bit builds (those surely will be incomatible!)
-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;
}
/*