summaryrefslogtreecommitdiffstats
path: root/generic/tclTest.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-03-21 13:55:11 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-03-21 13:55:11 (GMT)
commit4fc738f2566c56305c35fb6e685fb3ccccce1a07 (patch)
tree5c51da27a8473c687ab32cca8029ca2dc98d3af7 /generic/tclTest.c
parent6ee668d5c35df0f74d2e2e7b84860998ee4c0f2a (diff)
parent6cce25c5c9212f6293fa5184701fda78fb262c75 (diff)
downloadtcl-4fc738f2566c56305c35fb6e685fb3ccccce1a07.zip
tcl-4fc738f2566c56305c35fb6e685fb3ccccce1a07.tar.gz
tcl-4fc738f2566c56305c35fb6e685fb3ccccce1a07.tar.bz2
Merge 8.7. Tcl_GetStringFromObj() -> TclGetStringFromObj() (optimization)
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r--generic/tclTest.c489
1 files changed, 245 insertions, 244 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index bbadf72..c717e3a 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -688,7 +688,7 @@ Tcltest_Init(
Tcl_CreateObjCommand(interp, "testnumutfchars",
TestNumUtfCharsCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testgetunichar",
- TestGetUniCharCmd, NULL, NULL);
+ TestGetUniCharCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testfindfirst",
TestFindFirstCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testfindlast",
@@ -865,18 +865,17 @@ TestasyncCmd(
asyncPtr = (TestAsyncHandler *)Tcl_Alloc(sizeof(TestAsyncHandler));
asyncPtr->command = (char *)Tcl_Alloc(strlen(argv[2]) + 1);
strcpy(asyncPtr->command, argv[2]);
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
asyncPtr->id = nextId;
nextId++;
- asyncPtr->handler = Tcl_AsyncCreate(AsyncHandlerProc,
- INT2PTR(asyncPtr->id));
+ asyncPtr->handler = Tcl_AsyncCreate(AsyncHandlerProc, INT2PTR(asyncPtr->id));
asyncPtr->nextPtr = firstHandler;
firstHandler = asyncPtr;
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(asyncPtr->id));
} else if (strcmp(argv[1], "delete") == 0) {
if (argc == 2) {
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
while (firstHandler != NULL) {
asyncPtr = firstHandler;
firstHandler = asyncPtr->nextPtr;
@@ -884,7 +883,7 @@ TestasyncCmd(
Tcl_Free(asyncPtr->command);
Tcl_Free(asyncPtr);
}
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
return TCL_OK;
}
if (argc != 3) {
@@ -893,7 +892,7 @@ TestasyncCmd(
if (Tcl_GetInt(interp, argv[2], &id) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
for (prevPtr = NULL, asyncPtr = firstHandler; asyncPtr != NULL;
prevPtr = asyncPtr, asyncPtr = asyncPtr->nextPtr) {
if (asyncPtr->id != id) {
@@ -909,7 +908,7 @@ TestasyncCmd(
Tcl_Free(asyncPtr);
break;
}
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
} else if (strcmp(argv[1], "mark") == 0) {
if (argc != 5) {
goto wrongNumArgs;
@@ -936,7 +935,7 @@ TestasyncCmd(
if (Tcl_GetInt(interp, argv[2], &id) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_MutexLock(&asyncTestMutex);
+ Tcl_MutexLock(&asyncTestMutex);
for (asyncPtr = firstHandler; asyncPtr != NULL;
asyncPtr = asyncPtr->nextPtr) {
if (asyncPtr->id == id) {
@@ -951,7 +950,7 @@ TestasyncCmd(
break;
}
}
- Tcl_MutexUnlock(&asyncTestMutex);
+ Tcl_MutexUnlock(&asyncTestMutex);
} else {
Tcl_AppendResult(interp, "bad option \"", argv[1],
"\": must be create, delete, int, mark, or marklater", (void *)NULL);
@@ -963,7 +962,7 @@ TestasyncCmd(
static int
AsyncHandlerProc(
void *clientData, /* If of TestAsyncHandler structure.
- * in global list. */
+ * in global list. */
Tcl_Interp *interp, /* Interpreter in which command was
* executed, or NULL. */
int code) /* Current return code from command. */
@@ -976,16 +975,16 @@ AsyncHandlerProc(
Tcl_MutexLock(&asyncTestMutex);
for (asyncPtr = firstHandler; asyncPtr != NULL;
- asyncPtr = asyncPtr->nextPtr) {
- if (asyncPtr->id == id) {
- break;
- }
+ asyncPtr = asyncPtr->nextPtr) {
+ if (asyncPtr->id == id) {
+ break;
+ }
}
Tcl_MutexUnlock(&asyncTestMutex);
if (!asyncPtr) {
- /* Woops - this one was deleted between the AsyncMark and now */
- return TCL_OK;
+ /* Woops - this one was deleted between the AsyncMark and now */
+ return TCL_OK;
}
TclFormatInt(string, code);
@@ -1033,11 +1032,11 @@ AsyncThreadProc(
Tcl_Sleep(1);
Tcl_MutexLock(&asyncTestMutex);
for (asyncPtr = firstHandler; asyncPtr != NULL;
- asyncPtr = asyncPtr->nextPtr) {
- if (asyncPtr->id == id) {
- Tcl_AsyncMark(asyncPtr->handler);
- break;
- }
+ asyncPtr = asyncPtr->nextPtr) {
+ if (asyncPtr->id == id) {
+ Tcl_AsyncMark(asyncPtr->handler);
+ break;
+ }
}
Tcl_MutexUnlock(&asyncTestMutex);
Tcl_ExitThread(TCL_OK);
@@ -2103,8 +2102,10 @@ static void SpecialFree(
*------------------------------------------------------------------------
*/
typedef int
-UtfTransformFn(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_EncodingState *statePtr,
- char *dst, Tcl_Size dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr);
+UtfTransformFn(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src,
+ Tcl_Size srcLen, int flags, Tcl_EncodingState *statePtr, char *dst,
+ Tcl_Size dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr);
+
static int UtfExtWrapper(
Tcl_Interp *interp, UtfTransformFn *transformer, int objc, Tcl_Obj *const objv[])
{
@@ -2136,12 +2137,12 @@ static int UtfExtWrapper(
Tcl_WideInt wide;
if (objc < 7 || objc > 10) {
- Tcl_WrongNumArgs(interp, 2, objv,
+ Tcl_WrongNumArgs(interp, 2, objv,
"encoding srcbytes flags state dstlen ?srcreadvar? ?dstwrotevar? ?dstcharsvar?");
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (Tcl_GetEncodingFromObj(interp, objv[2], &encoding) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
/* Flags may be specified as list of integers and keywords */
@@ -2166,16 +2167,16 @@ static int UtfExtWrapper(
/* Assumes state is integer if not "" */
if (Tcl_GetWideIntFromObj(interp, objv[5], &wide) == TCL_OK) {
- encState = (Tcl_EncodingState)(size_t)wide;
- encStatePtr = &encState;
+ encState = (Tcl_EncodingState)(size_t)wide;
+ encStatePtr = &encState;
} else if (Tcl_GetCharLength(objv[5]) == 0) {
- encStatePtr = NULL;
+ encStatePtr = NULL;
} else {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[6], &dstLen) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
srcReadVar = NULL;
dstWroteVar = NULL;
@@ -2187,12 +2188,12 @@ static int UtfExtWrapper(
}
if (objc > 8) {
/* Ditto for dstWrote */
- if (Tcl_GetCharLength(objv[8])) {
- dstWroteVar = objv[8];
- }
+ if (Tcl_GetCharLength(objv[8])) {
+ dstWroteVar = objv[8];
+ }
if (objc > 9) {
- if (Tcl_GetCharLength(objv[9])) {
- dstCharsVar = objv[9];
+ if (Tcl_GetCharLength(objv[9])) {
+ dstCharsVar = objv[9];
}
}
}
@@ -2221,60 +2222,60 @@ static int UtfExtWrapper(
memmove(bufPtr + dstLen, "\xAB\xCD\xEF\xAB", 4); /* overflow detection */
bytes = Tcl_GetByteArrayFromObj(objv[3], &srcLen); /* Last! to avoid shimmering */
result = (*transformer)(interp, encoding, (const char *)bytes, srcLen, flags,
- encStatePtr, (char *) bufPtr, dstLen,
- srcReadVar ? &srcRead : NULL,
- &dstWrote,
- dstCharsVar ? &dstChars : NULL);
+ encStatePtr, (char *) bufPtr, dstLen,
+ srcReadVar ? &srcRead : NULL,
+ &dstWrote,
+ dstCharsVar ? &dstChars : NULL);
if (memcmp(bufPtr + bufLen - 4, "\xAB\xCD\xEF\xAB", 4)) {
- Tcl_SetResult(interp,
- "Tcl_ExternalToUtf wrote past output buffer",
- TCL_STATIC);
- result = TCL_ERROR;
+ Tcl_SetResult(interp,
+ "Tcl_ExternalToUtf wrote past output buffer",
+ TCL_STATIC);
+ result = TCL_ERROR;
} else if (result != TCL_ERROR) {
- Tcl_Obj *resultObjs[3];
- switch (result) {
- case TCL_OK:
- resultObjs[0] = Tcl_NewStringObj("ok", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_MULTIBYTE:
- resultObjs[0] = Tcl_NewStringObj("multibyte", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_SYNTAX:
- resultObjs[0] = Tcl_NewStringObj("syntax", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_UNKNOWN:
- resultObjs[0] = Tcl_NewStringObj("unknown", TCL_INDEX_NONE);
- break;
- case TCL_CONVERT_NOSPACE:
- resultObjs[0] = Tcl_NewStringObj("nospace", TCL_INDEX_NONE);
- break;
- default:
- resultObjs[0] = Tcl_NewIntObj(result);
- break;
- }
- result = TCL_OK;
- resultObjs[1] =
- encStatePtr ? Tcl_NewWideIntObj((Tcl_WideInt)(size_t)encState) : Tcl_NewObj();
- resultObjs[2] = Tcl_NewByteArrayObj(bufPtr, dstLen);
- if (srcReadVar) {
+ Tcl_Obj *resultObjs[3];
+ switch (result) {
+ case TCL_OK:
+ resultObjs[0] = Tcl_NewStringObj("ok", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_MULTIBYTE:
+ resultObjs[0] = Tcl_NewStringObj("multibyte", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_SYNTAX:
+ resultObjs[0] = Tcl_NewStringObj("syntax", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_UNKNOWN:
+ resultObjs[0] = Tcl_NewStringObj("unknown", TCL_INDEX_NONE);
+ break;
+ case TCL_CONVERT_NOSPACE:
+ resultObjs[0] = Tcl_NewStringObj("nospace", TCL_INDEX_NONE);
+ break;
+ default:
+ resultObjs[0] = Tcl_NewIntObj(result);
+ break;
+ }
+ result = TCL_OK;
+ resultObjs[1] =
+ encStatePtr ? Tcl_NewWideIntObj((Tcl_WideInt)(size_t)encState) : Tcl_NewObj();
+ resultObjs[2] = Tcl_NewByteArrayObj(bufPtr, dstLen);
+ if (srcReadVar) {
if (Tcl_ObjSetVar2(interp, srcReadVar, NULL, Tcl_NewIntObj(srcRead),
TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
}
}
- if (dstWroteVar) {
+ if (dstWroteVar) {
if (Tcl_ObjSetVar2(interp, dstWroteVar, NULL, Tcl_NewIntObj(dstWrote),
TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
}
}
- if (dstCharsVar) {
+ if (dstCharsVar) {
if (Tcl_ObjSetVar2(interp, dstCharsVar, NULL, Tcl_NewIntObj(dstChars),
TCL_LEAVE_ERR_MSG) == NULL) {
result = TCL_ERROR;
}
}
- Tcl_SetObjResult(interp, Tcl_NewListObj(3, resultObjs));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(3, resultObjs));
}
Tcl_Free(bufPtr);
@@ -2383,11 +2384,11 @@ TestencodingObjCmd(
Tcl_SetObjResult(interp,
Tcl_NewIntObj(Tcl_GetEncodingNulLength(encoding)));
Tcl_FreeEncoding(encoding);
- break;
+ break;
case ENC_EXTTOUTF:
- return UtfExtWrapper(interp,Tcl_ExternalToUtf,objc,objv);
+ return UtfExtWrapper(interp,Tcl_ExternalToUtf,objc,objv);
case ENC_UTFTOEXT:
- return UtfExtWrapper(interp,Tcl_UtfToExternal,objc,objv);
+ return UtfExtWrapper(interp,Tcl_UtfToExternal,objc,objv);
}
return TCL_OK;
}
@@ -3710,12 +3711,12 @@ TestlinkCmd(
static int
TestlinkarrayCmd(
TCL_UNUSED(void *),
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *LinkOption[] = {
- "update", "remove", "create", NULL
+ "update", "remove", "create", NULL
};
enum LinkOptionEnum { LINK_UPDATE, LINK_REMOVE, LINK_CREATE } optionIndex;
static const char *LinkType[] = {
@@ -6290,19 +6291,19 @@ TestChannelCmd(
}
if ((cmdName[0] == 'm') && (strncmp(cmdName, "mremove-rd", len) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "channel name required", (void *)NULL);
- return TCL_ERROR;
- }
+ if (argc != 3) {
+ Tcl_AppendResult(interp, "channel name required", (void *)NULL);
+ return TCL_ERROR;
+ }
return Tcl_RemoveChannelMode(interp, chan, TCL_READABLE);
}
if ((cmdName[0] == 'm') && (strncmp(cmdName, "mremove-wr", len) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "channel name required", (void *)NULL);
- return TCL_ERROR;
- }
+ if (argc != 3) {
+ Tcl_AppendResult(interp, "channel name required", (void *)NULL);
+ return TCL_ERROR;
+ }
return Tcl_RemoveChannelMode(interp, chan, TCL_WRITABLE);
}
@@ -6730,39 +6731,39 @@ TestSocketCmd(
len = strlen(cmdName);
if ((cmdName[0] == 't') && (strncmp(cmdName, "testflags", len) == 0)) {
- Tcl_Channel hChannel;
- int modePtr;
- int testMode;
- TcpState *statePtr;
- /* Set test value in the socket driver
- */
- /* Check for argument "channel name"
- */
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " testflags channel flags\"", (void *)NULL);
- return TCL_ERROR;
- }
- hChannel = Tcl_GetChannel(interp, argv[2], &modePtr);
- if ( NULL == hChannel ) {
- Tcl_AppendResult(interp, "unknown channel:", argv[2], (void *)NULL);
- return TCL_ERROR;
- }
- statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel);
- if ( NULL == statePtr) {
- Tcl_AppendResult(interp, "No channel instance data:", argv[2],
- (void *)NULL);
- return TCL_ERROR;
- }
- if (Tcl_GetBoolean(interp, argv[3], &testMode) != TCL_OK) {
- return TCL_ERROR;
- }
- if (testMode) {
- statePtr->flags |= TCP_ASYNC_TEST_MODE;
- } else {
- statePtr->flags &= ~TCP_ASYNC_TEST_MODE;
- }
- return TCL_OK;
+ Tcl_Channel hChannel;
+ int modePtr;
+ int testMode;
+ TcpState *statePtr;
+ /* Set test value in the socket driver
+ */
+ /* Check for argument "channel name"
+ */
+ if (argc < 4) {
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " testflags channel flags\"", (void *)NULL);
+ return TCL_ERROR;
+ }
+ hChannel = Tcl_GetChannel(interp, argv[2], &modePtr);
+ if ( NULL == hChannel ) {
+ Tcl_AppendResult(interp, "unknown channel:", argv[2], (void *)NULL);
+ return TCL_ERROR;
+ }
+ statePtr = (TcpState *)Tcl_GetChannelInstanceData(hChannel);
+ if ( NULL == statePtr) {
+ Tcl_AppendResult(interp, "No channel instance data:", argv[2],
+ (void *)NULL);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBoolean(interp, argv[3], &testMode) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (testMode) {
+ statePtr->flags |= TCP_ASYNC_TEST_MODE;
+ } else {
+ statePtr->flags &= ~TCP_ASYNC_TEST_MODE;
+ }
+ return TCL_OK;
}
Tcl_AppendResult(interp, "bad option \"", cmdName, "\": should be "
@@ -6799,20 +6800,20 @@ TestServiceModeCmd(
{
int newmode, oldmode;
if (argc > 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " ?newmode?\"", (void *)NULL);
- return TCL_ERROR;
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " ?newmode?\"", (void *)NULL);
+ return TCL_ERROR;
}
oldmode = (Tcl_GetServiceMode() != TCL_SERVICE_NONE);
if (argc == 2) {
- if (Tcl_GetInt(interp, argv[1], &newmode) == TCL_ERROR) {
- return TCL_ERROR;
- }
- if (newmode == 0) {
- Tcl_SetServiceMode(TCL_SERVICE_NONE);
- } else {
- Tcl_SetServiceMode(TCL_SERVICE_ALL);
- }
+ if (Tcl_GetInt(interp, argv[1], &newmode) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (newmode == 0) {
+ Tcl_SetServiceMode(TCL_SERVICE_NONE);
+ } else {
+ Tcl_SetServiceMode(TCL_SERVICE_ALL);
+ }
}
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(oldmode));
return TCL_OK;
@@ -7893,20 +7894,20 @@ NREUnwind_callback(
void *cStackPtr = TclGetCStackPtr();
if (data[0] == INT2PTR(-1)) {
- Tcl_NRAddCallback(interp, NREUnwind_callback, cStackPtr, INT2PTR(-1),
- INT2PTR(-1), NULL);
+ Tcl_NRAddCallback(interp, NREUnwind_callback, cStackPtr, INT2PTR(-1),
+ INT2PTR(-1), NULL);
} else if (data[1] == INT2PTR(-1)) {
- Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], cStackPtr,
- INT2PTR(-1), NULL);
+ Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], cStackPtr,
+ INT2PTR(-1), NULL);
} else if (data[2] == INT2PTR(-1)) {
- Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], data[1],
- cStackPtr, NULL);
+ Tcl_NRAddCallback(interp, NREUnwind_callback, data[0], data[1],
+ cStackPtr, NULL);
} else {
- Tcl_Obj *idata[3];
- idata[0] = Tcl_NewWideIntObj(((char *) data[1] - (char *) data[0]));
- idata[1] = Tcl_NewWideIntObj(((char *) data[2] - (char *) data[0]));
- idata[2] = Tcl_NewWideIntObj(((char *) cStackPtr - (char *) data[0]));
- Tcl_SetObjResult(interp, Tcl_NewListObj(3, idata));
+ Tcl_Obj *idata[3];
+ idata[0] = Tcl_NewWideIntObj(((char *) data[1] - (char *) data[0]));
+ idata[1] = Tcl_NewWideIntObj(((char *) data[2] - (char *) data[0]));
+ idata[2] = Tcl_NewWideIntObj(((char *) cStackPtr - (char *) data[0]));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(3, idata));
}
return TCL_OK;
}
@@ -7924,7 +7925,7 @@ TestNREUnwind(
*/
Tcl_NRAddCallback(interp, NREUnwind_callback, INT2PTR(-1), INT2PTR(-1),
- INT2PTR(-1), NULL);
+ INT2PTR(-1), NULL);
return TCL_OK;
}
@@ -8288,13 +8289,13 @@ TestparseargsCmd(
Tcl_Size count = objc;
Tcl_Obj **remObjv, *result[3];
const Tcl_ArgvInfo argTable[] = {
- {TCL_ARGV_CONSTANT, "-bool", INT2PTR(1), &foo, "booltest", NULL},
- TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
+ {TCL_ARGV_CONSTANT, "-bool", INT2PTR(1), &foo, "booltest", NULL},
+ TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
};
foo = 0;
if (Tcl_ParseArgsObjv(interp, argTable, &count, objv, &remObjv)!=TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
result[0] = Tcl_NewWideIntObj(foo);
result[1] = Tcl_NewWideIntObj(count);
@@ -8319,7 +8320,7 @@ InterpCmdResolver(
Interp *iPtr = (Interp *) interp;
CallFrame *varFramePtr = iPtr->varFramePtr;
Proc *procPtr = (varFramePtr->isProcCallFrame & FRAME_IS_PROC) ?
- varFramePtr->procPtr : NULL;
+ varFramePtr->procPtr : NULL;
Namespace *callerNsPtr = varFramePtr->nsPtr;
Tcl_Command resolvedCmdPtr = NULL;
@@ -8329,74 +8330,74 @@ InterpCmdResolver(
* B) the caller's namespace is "ctx1" or "ctx2"
*/
if ( (name[0] == 'z') && (name[1] == '\0') ) {
- Namespace *ns2NsPtr = (Namespace *) Tcl_FindNamespace(interp, "::ns2", NULL, 0);
-
- if (procPtr != NULL
- && ((procPtr->cmdPtr->nsPtr == iPtr->globalNsPtr)
- || (ns2NsPtr != NULL && procPtr->cmdPtr->nsPtr == ns2NsPtr)
- )
- ) {
- /*
- * Case A)
- *
- * - The context, in which this resolver becomes active, is
- * determined by the name of the caller proc, which has to be
- * named "x".
- *
- * - To determine the name of the caller proc, the proc is taken
- * from the topmost stack frame.
- *
- * - Note that the context is NOT provided during byte-code
- * compilation (e.g. in TclProcCompileProc)
- *
- * When these conditions hold, this function resolves the
- * passed-in cmd literal into a cmd "y", which is taken from the
- * the global namespace (for simplicity).
- */
-
- const char *callingCmdName =
- Tcl_GetCommandName(interp, (Tcl_Command) procPtr->cmdPtr);
-
- if ( callingCmdName[0] == 'x' && callingCmdName[1] == '\0' ) {
- resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
- }
- } else if (callerNsPtr != NULL) {
- /*
- * Case B)
- *
- * - The context, in which this resolver becomes active, is
- * determined by the name of the parent namespace, which has
- * to be named "ctx1" or "ctx2".
- *
- * - To determine the name of the parent namesace, it is taken
- * from the 2nd highest stack frame.
- *
- * - Note that the context can be provided during byte-code
- * compilation (e.g. in TclProcCompileProc)
- *
- * When these conditions hold, this function resolves the
- * passed-in cmd literal into a cmd "y" or "Y" depending on the
- * context. The resolved procs are taken from the the global
- * namespace (for simplicity).
- */
-
- CallFrame *parentFramePtr = varFramePtr->callerPtr;
- const char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
-
- if (strcmp(context, "ctx1") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
- resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
- /* fprintf(stderr, "... y ==> %p\n", resolvedCmdPtr);*/
-
- } else if (strcmp(context, "ctx2") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
- resolvedCmdPtr = Tcl_FindCommand(interp, "Y", NULL, TCL_GLOBAL_ONLY);
- /*fprintf(stderr, "... Y ==> %p\n", resolvedCmdPtr);*/
- }
- }
-
- if (resolvedCmdPtr != NULL) {
- *rPtr = resolvedCmdPtr;
- return TCL_OK;
- }
+ Namespace *ns2NsPtr = (Namespace *) Tcl_FindNamespace(interp, "::ns2", NULL, 0);
+
+ if (procPtr != NULL
+ && ((procPtr->cmdPtr->nsPtr == iPtr->globalNsPtr)
+ || (ns2NsPtr != NULL && procPtr->cmdPtr->nsPtr == ns2NsPtr)
+ )
+ ) {
+ /*
+ * Case A)
+ *
+ * - The context, in which this resolver becomes active, is
+ * determined by the name of the caller proc, which has to be
+ * named "x".
+ *
+ * - To determine the name of the caller proc, the proc is taken
+ * from the topmost stack frame.
+ *
+ * - Note that the context is NOT provided during byte-code
+ * compilation (e.g. in TclProcCompileProc)
+ *
+ * When these conditions hold, this function resolves the
+ * passed-in cmd literal into a cmd "y", which is taken from the
+ * the global namespace (for simplicity).
+ */
+
+ const char *callingCmdName =
+ Tcl_GetCommandName(interp, (Tcl_Command) procPtr->cmdPtr);
+
+ if ( callingCmdName[0] == 'x' && callingCmdName[1] == '\0' ) {
+ resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
+ }
+ } else if (callerNsPtr != NULL) {
+ /*
+ * Case B)
+ *
+ * - The context, in which this resolver becomes active, is
+ * determined by the name of the parent namespace, which has
+ * to be named "ctx1" or "ctx2".
+ *
+ * - To determine the name of the parent namesace, it is taken
+ * from the 2nd highest stack frame.
+ *
+ * - Note that the context can be provided during byte-code
+ * compilation (e.g. in TclProcCompileProc)
+ *
+ * When these conditions hold, this function resolves the
+ * passed-in cmd literal into a cmd "y" or "Y" depending on the
+ * context. The resolved procs are taken from the the global
+ * namespace (for simplicity).
+ */
+
+ CallFrame *parentFramePtr = varFramePtr->callerPtr;
+ const char *context = parentFramePtr != NULL ? parentFramePtr->nsPtr->name : "(NULL)";
+
+ if (strcmp(context, "ctx1") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
+ resolvedCmdPtr = Tcl_FindCommand(interp, "y", NULL, TCL_GLOBAL_ONLY);
+ /* fprintf(stderr, "... y ==> %p\n", resolvedCmdPtr);*/
+
+ } else if (strcmp(context, "ctx2") == 0 && (name[0] == 'z') && (name[1] == '\0')) {
+ resolvedCmdPtr = Tcl_FindCommand(interp, "Y", NULL, TCL_GLOBAL_ONLY);
+ /*fprintf(stderr, "... Y ==> %p\n", resolvedCmdPtr);*/
+ }
+ }
+
+ if (resolvedCmdPtr != NULL) {
+ *rPtr = resolvedCmdPtr;
+ return TCL_OK;
+ }
}
return TCL_CONTINUE;
}
@@ -8427,9 +8428,9 @@ HashVarFree(
Tcl_Var var)
{
if (VarHashRefCount(var) < 2) {
- Tcl_Free(var);
+ Tcl_Free(var);
} else {
- VarHashRefCount(var)--;
+ VarHashRefCount(var)--;
}
}
@@ -8441,7 +8442,7 @@ MyCompiledVarFree(
Tcl_DecrRefCount(resVarInfo->nameObj);
if (resVarInfo->var) {
- HashVarFree(resVarInfo->var);
+ HashVarFree(resVarInfo->var);
}
Tcl_Free(vInfoPtr);
}
@@ -8461,27 +8462,27 @@ MyCompiledVarFetch(
Tcl_HashEntry *hPtr;
if (var != NULL) {
- if (!(((Var *) var)->flags & VAR_DEAD_HASH)) {
- /*
- * The cached variable is valid, return it.
- */
+ if (!(((Var *) var)->flags & VAR_DEAD_HASH)) {
+ /*
+ * The cached variable is valid, return it.
+ */
- return var;
- }
+ return var;
+ }
- /*
- * The variable is not valid anymore. Clean it up.
- */
+ /*
+ * The variable is not valid anymore. Clean it up.
+ */
- HashVarFree(var);
+ HashVarFree(var);
}
hPtr = Tcl_CreateHashEntry((Tcl_HashTable *) &iPtr->globalNsPtr->varTable,
- resVarInfo->nameObj, &isNewVar);
+ resVarInfo->nameObj, &isNewVar);
if (hPtr) {
- var = (Tcl_Var) TclVarHashGetValue(hPtr);
+ var = (Tcl_Var) TclVarHashGetValue(hPtr);
} else {
- var = NULL;
+ var = NULL;
}
resVarInfo->var = var;
@@ -8524,7 +8525,7 @@ TestInterpResolverCmd(
Tcl_Obj *const objv[])
{
static const char *const table[] = {
- "down", "up", NULL
+ "down", "up", NULL
};
int idx;
#define RESOLVER_KEY "testInterpResolver"
@@ -8541,20 +8542,20 @@ TestInterpResolverCmd(
}
}
if (Tcl_GetIndexFromObj(interp, objv[1], table, "operation", TCL_EXACT,
- &idx) != TCL_OK) {
- return TCL_ERROR;
+ &idx) != TCL_OK) {
+ return TCL_ERROR;
}
switch (idx) {
case 1: /* up */
- Tcl_AddInterpResolvers(interp, RESOLVER_KEY, InterpCmdResolver,
- InterpVarResolver, InterpCompiledVarResolver);
- break;
+ Tcl_AddInterpResolvers(interp, RESOLVER_KEY, InterpCmdResolver,
+ InterpVarResolver, InterpCompiledVarResolver);
+ break;
case 0: /*down*/
- if (!Tcl_RemoveInterpResolvers(interp, RESOLVER_KEY)) {
- Tcl_AppendResult(interp, "could not remove the resolver scheme",
- (void *)NULL);
- return TCL_ERROR;
- }
+ if (!Tcl_RemoveInterpResolvers(interp, RESOLVER_KEY)) {
+ Tcl_AppendResult(interp, "could not remove the resolver scheme",
+ (void *)NULL);
+ return TCL_ERROR;
+ }
}
return TCL_OK;
}