34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
+
-
+
-
+
-
-
+
+
|
static const TclStubs *
HasStubSupport(
Tcl_Interp *interp,
int magic)
{
Interp *iPtr = (Interp *) interp;
if (iPtr->stubTable && iPtr->stubTable->magic == magic
if (iPtr->stubTable && iPtr->stubTable->magic == magic) {
&& iPtr->stubTable->magic == TCL_STUB_MAGIC) {
return iPtr->stubTable;
}
iPtr->legacyResult
iPtr->result = (char *) "interpreter uses an incompatible stubs mechanism";
iPtr->freeProc = TCL_STATIC;
= "interpreter uses an incompatible stubs mechanism";
iPtr->legacyFreeProc = 0; /* TCL_STATIC */
return NULL;
}
/*
* Use our own isdigit to avoid linking to libc on windows
*/
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
-
-
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
-
+
-
+
-
+
|
TclInitStubs(
Tcl_Interp *interp,
const char *version,
int exact,
const char *tclversion,
int magic)
{
const char *p;
char *q;
char major[TCL_INTEGER_SPACE];
const char *actualVersion = NULL;
ClientData pkgData = NULL;
Interp *iPtr = (Interp *) interp;
const TclStubs *stubsPtr;
/*
* We can't optimize this check by caching tclStubsPtr because that
* prevents apps from being able to load/unload Tcl dynamically multiple
* times. [Bug 615304]
*/
tclStubsPtr = HasStubSupport(interp, magic);
if (!tclStubsPtr) {
stubsPtr = HasStubSupport(interp, magic);
if (!stubsPtr) {
return NULL;
}
/*
* Check that the [load]ing interp and [load]ed extension were compiled
* against headers from the same major version of Tcl. If not, they
* will not agree on the layout of the stubs and will crash. Report
* the error instead of crashing.
*/
p = tclversion;
q = major;
while (isDigit(*p)) {
*q++ = *p++;
if (q-major > TCL_INTEGER_SPACE) {
iPtr->result = (char *) "major version overflow";
iPtr->freeProc = TCL_STATIC;
return NULL;
}
}
*q = '\0';
if (NULL == Tcl_PkgRequireEx(interp, "Tcl", major, 0, NULL)) {
return NULL;
}
/*
* Check satisfaction of the requirement requested by the caller.
*/
actualVersion = Tcl_PkgRequireEx(interp, "Tcl", version, 0, &pkgData);
actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, NULL);
if (actualVersion == NULL) {
return NULL;
}
if (exact) {
const char *p = version;
int count = 0;
p = version;
while (*p) {
count += !isDigit(*p++);
}
if (count == 1) {
q = actualVersion;
const char *q = actualVersion;
p = version;
while (*p && (*p == *q)) {
p++; q++;
}
if (*p || isDigit(*q)) {
/* Construct error message */
Tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL);
stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL);
return NULL;
}
} else {
actualVersion = Tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL);
actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL);
if (actualVersion == NULL) {
return NULL;
}
}
}
tclStubsPtr = (TclStubs *) pkgData;
tclStubsPtr = stubsPtr;
if (tclStubsPtr->hooks) {
tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
} else {
tclPlatStubsPtr = NULL;
|