summaryrefslogtreecommitdiffstats
path: root/generic/tclStubLib.c
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 /generic/tclStubLib.c
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!)
Diffstat (limited to 'generic/tclStubLib.c')
-rw-r--r--generic/tclStubLib.c25
1 files changed, 18 insertions, 7 deletions
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;
}
/*