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