diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-18 17:24:05 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-18 17:24:05 (GMT) |
| commit | e5463e8ec8f8677f98b77331a980010aac013b33 (patch) | |
| tree | 94ee36a735f6c211d16b65f62dd4e6a4f733db55 | |
| parent | 80630f4ec9d479d7a28d3379a9e19fe08187f250 (diff) | |
| parent | bddf73771484f93d6b4ba9048b6b4b9f90dc8ee1 (diff) | |
| download | tcl-e5463e8ec8f8677f98b77331a980010aac013b33.zip tcl-e5463e8ec8f8677f98b77331a980010aac013b33.tar.gz tcl-e5463e8ec8f8677f98b77331a980010aac013b33.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.h | 6 | ||||
| -rw-r--r-- | generic/tclStubLib.c | 25 |
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; } /* |
