summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-06-27 10:22:30 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-06-27 10:22:30 (GMT)
commita7534bc7ed966b9b399e86be1c6cc2004baf379c (patch)
treef45973080c93357d9df8c61ea5f4f9ca2b039451
parent179f28ba4605cb66cd358eb8d6d57b42e7bf5bb9 (diff)
downloadtcl-a7534bc7ed966b9b399e86be1c6cc2004baf379c.zip
tcl-a7534bc7ed966b9b399e86be1c6cc2004baf379c.tar.gz
tcl-a7534bc7ed966b9b399e86be1c6cc2004baf379c.tar.bz2
Make TCL_MAJOR_VERSION/TCL_MINOR_VERSION/TCL_STUB_MAGIC available to Tcl_InitStubs() arguments. Useful for debugging and detection of stub incompatibilities (e.g. for Tcl9)
-rw-r--r--generic/tcl.h19
-rw-r--r--generic/tclPkg.c2
-rw-r--r--generic/tclStubLib.c20
3 files changed, 19 insertions, 22 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index be40368..6061ea8 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -2377,9 +2377,6 @@ 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)
@@ -2392,17 +2389,19 @@ typedef int (Tcl_NRPostProc) (ClientData data[], Tcl_Interp *interp,
*/
const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version,
- int exact);
+ int exact, int magic);
const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
const char *version, int epoch, int revision);
-/*
- * When not using stubs, make it a macro.
- */
-
-#ifndef USE_TCL_STUBS
+#ifdef USE_TCL_STUBS
+#define Tcl_InitStubs(interp, version, exact) \
+ (Tcl_InitStubs)(interp, version, \
+ (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16), \
+ TCL_STUB_MAGIC)
+#else
#define Tcl_InitStubs(interp, version, exact) \
- Tcl_PkgInitStubsCheck(interp, version, exact)
+ Tcl_PkgInitStubsCheck(interp, version, \
+ (exact)|(TCL_MAJOR_VERSION<<8)|(TCL_MINOR_VERSION<<16))
#endif
/*
diff --git a/generic/tclPkg.c b/generic/tclPkg.c
index f6e8b20..86777a8 100644
--- a/generic/tclPkg.c
+++ b/generic/tclPkg.c
@@ -1895,7 +1895,7 @@ Tcl_PkgInitStubsCheck(
{
const char *actualVersion = Tcl_PkgPresent(interp, "Tcl", version, 0);
- if (exact && actualVersion) {
+ if ((exact&1) && actualVersion) {
const char *p = version;
int count = 0;
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index 859cbf9..afabdca 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -24,13 +24,10 @@ const TclIntStubs *tclIntStubsPtr = NULL;
const TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
/*
- * Use our own isDigit to avoid linking to libc on windows
+ * Use our own ISDIGIT to avoid linking to libc on windows
*/
-static int isDigit(const int c)
-{
- return (c >= '0' && c <= '9');
-}
+#define ISDIGIT(c) (((unsigned)((c)-'0')) <= 9)
/*
*----------------------------------------------------------------------
@@ -54,7 +51,8 @@ MODULE_SCOPE const char *
Tcl_InitStubs(
Tcl_Interp *interp,
const char *version,
- int exact)
+ int exact,
+ int magic)
{
Interp *iPtr = (Interp *) interp;
const char *actualVersion = NULL;
@@ -67,8 +65,8 @@ Tcl_InitStubs(
* times. [Bug 615304]
*/
- if (!stubsPtr || (stubsPtr->magic != TCL_STUB_MAGIC)) {
- iPtr->result = "interpreter uses an incompatible stubs mechanism";
+ if (!stubsPtr || (stubsPtr->magic != (((exact&0xff00) >= 0x900) ? magic : TCL_STUB_MAGIC))) {
+ iPtr->result = (char *)"interpreter uses an incompatible stubs mechanism";
iPtr->freeProc = TCL_STATIC;
return NULL;
}
@@ -77,12 +75,12 @@ Tcl_InitStubs(
if (actualVersion == NULL) {
return NULL;
}
- if (exact) {
+ if (exact&1) {
const char *p = version;
int count = 0;
while (*p) {
- count += !isDigit(*p++);
+ count += !ISDIGIT(*p++);
}
if (count == 1) {
const char *q = actualVersion;
@@ -91,7 +89,7 @@ Tcl_InitStubs(
while (*p && (*p == *q)) {
p++; q++;
}
- if (*p || isDigit(*q)) {
+ if (*p || ISDIGIT(*q)) {
/* Construct error message */
stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL);
return NULL;