summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2024-05-10 13:45:45 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2024-05-10 13:45:45 (GMT)
commit0e940ad7b41791eecc3a45c97467253b1770d153 (patch)
treedce8916f64c2bd1f100b2df54ea2d32e34f26904
parent02755b365081ad57922ae36100a59aef2d823c06 (diff)
downloadtcl-0e940ad7b41791eecc3a45c97467253b1770d153.zip
tcl-0e940ad7b41791eecc3a45c97467253b1770d153.tar.gz
tcl-0e940ad7b41791eecc3a45c97467253b1770d153.tar.bz2
Code style fixes
Mostly whitespace fixing really
-rw-r--r--generic/tclAlloc.c31
-rw-r--r--generic/tclBasic.c1396
2 files changed, 724 insertions, 703 deletions
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c
index 3c4fac3..b52d1b3 100644
--- a/generic/tclAlloc.c
+++ b/generic/tclAlloc.c
@@ -47,17 +47,18 @@ typedef size_t caddr_t;
*/
union overhead {
- union overhead *next; /* when free */
- unsigned char padding[TCL_ALLOCALIGN]; /* align struct to TCL_ALLOCALIGN bytes */
+ union overhead *next; /* when free */
+ unsigned char padding[TCL_ALLOCALIGN];
+ /* align struct to TCL_ALLOCALIGN bytes */
struct {
- unsigned char magic0; /* magic number */
- unsigned char index; /* bucket # */
- unsigned char unused; /* unused */
- unsigned char magic1; /* other magic number */
+ unsigned char magic0; /* magic number */
+ unsigned char index; /* bucket # */
+ unsigned char unused; /* unused */
+ unsigned char magic1; /* other magic number */
#ifndef NDEBUG
- unsigned short rmagic; /* range magic number */
+ unsigned short rmagic; /* range magic number */
size_t size; /* actual block size */
- unsigned short unused2; /* padding to 8-byte align */
+ unsigned short unused2; /* padding to 8-byte align */
#endif
} ovu;
#define overMagic0 ovu.magic0
@@ -67,7 +68,6 @@ union overhead {
#define realBlockSize ovu.size
};
-
#define MAGIC 0xEF /* magic # on accounting info */
#define RMAGIC 0x5555 /* magic # on range info */
@@ -92,7 +92,8 @@ union overhead {
* precedes the data area returned to the user.
*/
-#define MINBLOCK ((sizeof(union overhead) + (TCL_ALLOCALIGN-1)) & ~(TCL_ALLOCALIGN-1))
+#define MINBLOCK \
+ ((sizeof(union overhead) + (TCL_ALLOCALIGN-1)) & ~(TCL_ALLOCALIGN-1))
#define NBUCKETS (13 - (MINBLOCK >> 4))
#define MAXMALLOC ((size_t)1 << (NBUCKETS+2))
static union overhead *nextf[NBUCKETS];
@@ -251,7 +252,7 @@ TclFinalizeAllocSubsystem(void)
void *
TclpAlloc(
- size_t numBytes) /* Number of bytes to allocate. */
+ size_t numBytes) /* Number of bytes to allocate. */
{
union overhead *overPtr;
size_t bucket;
@@ -385,10 +386,10 @@ TclpAlloc(
static void
MoreCore(
- size_t bucket) /* What bucket to allocate to. */
+ size_t bucket) /* What bucket to allocate to. */
{
union overhead *overPtr;
- size_t size; /* size of desired block */
+ size_t size; /* size of desired block */
size_t amount; /* amount to allocate */
size_t numBlocks; /* how many blocks we get */
struct block *blockPtr;
@@ -511,7 +512,7 @@ TclpFree(
void *
TclpRealloc(
void *oldPtr, /* Pointer to alloc'ed block. */
- size_t numBytes) /* New size of memory. */
+ size_t numBytes) /* New size of memory. */
{
int i;
union overhead *overPtr;
@@ -743,7 +744,7 @@ TclpFree(
void *
TclpRealloc(
void *oldPtr, /* Pointer to alloced block. */
- size_t numBytes) /* New size of memory. */
+ size_t numBytes) /* New size of memory. */
{
return realloc(oldPtr, numBytes);
}
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 3faa201..ed1ad58 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -63,7 +63,6 @@
/* actually there is no fallback to builtin fpclassify */
#endif /* !TCL_FPCLASSIFY_MODE */
-
/*
* Bug 7371b6270b: to check C call stack depth, prefer an approach which is
* compatible with AddressSanitizer (ASan) use-after-return detection.
@@ -85,17 +84,17 @@ void *
TclGetCStackPtr(void)
{
#if defined( __GNUC__ ) || __has_builtin(__builtin_frame_address)
- return __builtin_frame_address(0);
+ return __builtin_frame_address(0);
#elif defined(_MSC_VER) && defined(HAVE_INTRIN_H)
- return _AddressOfReturnAddress();
+ return _AddressOfReturnAddress();
#else
- ptrdiff_t unused = 0;
- /*
- * LLVM recommends using volatile:
- * https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0-rc1/clang/lib/Basic/Stack.cpp#L31
- */
- ptrdiff_t *volatile stackLevel = &unused;
- return (void *)stackLevel;
+ ptrdiff_t unused = 0;
+ /*
+ * LLVM recommends using volatile:
+ * https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0-rc1/clang/lib/Basic/Stack.cpp#L31
+ */
+ ptrdiff_t *volatile stackLevel = &unused;
+ return (void *)stackLevel;
#endif
}
@@ -168,7 +167,7 @@ TCL_DECLARE_MUTEX(commandTypeLock);
* Static functions in this file:
*/
-static Tcl_ObjCmdProc BadEnsembleSubcommand;
+static Tcl_ObjCmdProc BadEnsembleSubcommand;
static char * CallCommandTraces(Interp *iPtr, Command *cmdPtr,
const char *oldName, const char *newName,
int flags);
@@ -193,12 +192,12 @@ static Tcl_ObjCmdProc ExprDoubleFunc;
static Tcl_ObjCmdProc ExprFloorFunc;
static Tcl_ObjCmdProc ExprIntFunc;
static Tcl_ObjCmdProc ExprIsqrtFunc;
-static Tcl_ObjCmdProc ExprIsFiniteFunc;
-static Tcl_ObjCmdProc ExprIsInfinityFunc;
-static Tcl_ObjCmdProc ExprIsNaNFunc;
-static Tcl_ObjCmdProc ExprIsNormalFunc;
-static Tcl_ObjCmdProc ExprIsSubnormalFunc;
-static Tcl_ObjCmdProc ExprIsUnorderedFunc;
+static Tcl_ObjCmdProc ExprIsFiniteFunc;
+static Tcl_ObjCmdProc ExprIsInfinityFunc;
+static Tcl_ObjCmdProc ExprIsNaNFunc;
+static Tcl_ObjCmdProc ExprIsNormalFunc;
+static Tcl_ObjCmdProc ExprIsSubnormalFunc;
+static Tcl_ObjCmdProc ExprIsUnorderedFunc;
static Tcl_ObjCmdProc ExprMaxFunc;
static Tcl_ObjCmdProc ExprMinFunc;
static Tcl_ObjCmdProc ExprRandFunc;
@@ -207,7 +206,7 @@ static Tcl_ObjCmdProc ExprSqrtFunc;
static Tcl_ObjCmdProc ExprSrandFunc;
static Tcl_ObjCmdProc ExprUnaryFunc;
static Tcl_ObjCmdProc ExprWideFunc;
-static Tcl_ObjCmdProc FloatClassifyObjCmd;
+static Tcl_ObjCmdProc FloatClassifyObjCmd;
static void MathFuncWrongNumArgs(Tcl_Interp *interp, int expected,
int actual, Tcl_Obj *const *objv);
static Tcl_NRPostProc NRCoroutineCallerCallback;
@@ -253,11 +252,11 @@ MODULE_SCOPE const TclStubs tclStubs;
* after particular kinds of [yield].
*/
-#define CORO_ACTIVATE_YIELD NULL
-#define CORO_ACTIVATE_YIELDM INT2PTR(1)
+#define CORO_ACTIVATE_YIELD NULL
+#define CORO_ACTIVATE_YIELDM INT2PTR(1)
-#define COROUTINE_ARGUMENTS_SINGLE_OPTIONAL (-1)
-#define COROUTINE_ARGUMENTS_ARBITRARY (-2)
+#define COROUTINE_ARGUMENTS_SINGLE_OPTIONAL (-1)
+#define COROUTINE_ARGUMENTS_ARBITRARY (-2)
/*
* The following structure define the commands in the Tcl core.
@@ -271,9 +270,9 @@ typedef struct {
int flags; /* Various flag bits, as defined below. */
} CmdInfo;
-#define CMD_IS_SAFE 1 /* Whether this command is part of the set of
- * commands present by default in a safe
- * interpreter. */
+#define CMD_IS_SAFE 1 /* Whether this command is part of the set of
+ * commands present by default in a safe
+ * interpreter. */
/* CMD_COMPILES_EXPANDED - Whether the compiler for this command can handle
* expansion for itself rather than needing the generic layer to take care of
* it for it. Defined in tclInt.h. */
@@ -287,13 +286,13 @@ typedef struct {
*/
typedef struct {
- const char *ensembleNsName; /* The ensemble's name within ::tcl. NULL for
- * the end of the list of commands to hide. */
- const char *commandName; /* The name of the command within the
- * ensemble. If this is NULL, we want to also
- * make the overall command be hidden, an ugly
- * hack because it is expected by security
- * policies in the wild. */
+ const char *ensembleNsName; /* The ensemble's name within ::tcl. NULL for
+ * the end of the list of commands to hide. */
+ const char *commandName; /* The name of the command within the
+ * ensemble. If this is NULL, we want to also
+ * make the overall command be hidden, an ugly
+ * hack because it is expected by security
+ * policies in the wild. */
} UnsafeEnsembleInfo;
/*
@@ -322,8 +321,8 @@ static const CmdInfo builtInCmds[] = {
{"concat", Tcl_ConcatObjCmd, TclCompileConcatCmd, NULL, CMD_IS_SAFE},
{"const", Tcl_ConstObjCmd, TclCompileConstCmd, NULL, CMD_IS_SAFE},
{"continue", Tcl_ContinueObjCmd, TclCompileContinueCmd, NULL, CMD_IS_SAFE},
- {"coroinject", NULL, NULL, TclNRCoroInjectObjCmd, CMD_IS_SAFE},
- {"coroprobe", NULL, NULL, TclNRCoroProbeObjCmd, CMD_IS_SAFE},
+ {"coroinject", NULL, NULL, TclNRCoroInjectObjCmd, CMD_IS_SAFE},
+ {"coroprobe", NULL, NULL, TclNRCoroProbeObjCmd, CMD_IS_SAFE},
{"coroutine", NULL, NULL, TclNRCoroutineObjCmd, CMD_IS_SAFE},
{"error", Tcl_ErrorObjCmd, TclCompileErrorCmd, NULL, CMD_IS_SAFE},
{"eval", Tcl_EvalObjCmd, NULL, TclNREvalObjCmd, CMD_IS_SAFE},
@@ -331,7 +330,7 @@ static const CmdInfo builtInCmds[] = {
{"for", Tcl_ForObjCmd, TclCompileForCmd, TclNRForObjCmd, CMD_IS_SAFE},
{"foreach", Tcl_ForeachObjCmd, TclCompileForeachCmd, TclNRForeachCmd, CMD_IS_SAFE},
{"format", Tcl_FormatObjCmd, TclCompileFormatCmd, NULL, CMD_IS_SAFE},
- {"fpclassify", FloatClassifyObjCmd, NULL, NULL, CMD_IS_SAFE},
+ {"fpclassify", FloatClassifyObjCmd, NULL, NULL, CMD_IS_SAFE},
{"global", Tcl_GlobalObjCmd, TclCompileGlobalCmd, NULL, CMD_IS_SAFE},
{"if", Tcl_IfObjCmd, TclCompileIfCmd, TclNRIfObjCmd, CMD_IS_SAFE},
{"incr", Tcl_IncrObjCmd, TclCompileIncrCmd, NULL, CMD_IS_SAFE},
@@ -346,12 +345,12 @@ static const CmdInfo builtInCmds[] = {
{"lmap", Tcl_LmapObjCmd, TclCompileLmapCmd, TclNRLmapCmd, CMD_IS_SAFE},
{"lpop", Tcl_LpopObjCmd, NULL, NULL, CMD_IS_SAFE},
{"lrange", Tcl_LrangeObjCmd, TclCompileLrangeCmd, NULL, CMD_IS_SAFE},
- {"lremove", Tcl_LremoveObjCmd, NULL, NULL, CMD_IS_SAFE},
+ {"lremove", Tcl_LremoveObjCmd, NULL, NULL, CMD_IS_SAFE},
{"lrepeat", Tcl_LrepeatObjCmd, NULL, NULL, CMD_IS_SAFE},
{"lreplace", Tcl_LreplaceObjCmd, TclCompileLreplaceCmd, NULL, CMD_IS_SAFE},
{"lreverse", Tcl_LreverseObjCmd, NULL, NULL, CMD_IS_SAFE},
{"lsearch", Tcl_LsearchObjCmd, NULL, NULL, CMD_IS_SAFE},
- {"lseq", Tcl_LseqObjCmd, NULL, NULL, CMD_IS_SAFE},
+ {"lseq", Tcl_LseqObjCmd, NULL, NULL, CMD_IS_SAFE},
{"lset", Tcl_LsetObjCmd, TclCompileLsetCmd, NULL, CMD_IS_SAFE},
{"lsort", Tcl_LsortObjCmd, NULL, NULL, CMD_IS_SAFE},
{"package", Tcl_PackageObjCmd, NULL, TclNRPackageObjCmd, CMD_IS_SAFE},
@@ -479,48 +478,52 @@ static const UnsafeEnsembleInfo unsafeEnsembleCommands[] = {
* Math functions. All are safe.
*/
+typedef double (BuiltinUnaryFunc)(double x);
+typedef double (BuiltinBinaryFunc)(double x, double y);
+#define BINARY_TYPECAST(fn) \
+ (BuiltinUnaryFunc *)(void *)(BuiltinBinaryFunc *) fn
typedef struct {
const char *name; /* Name of the function. The full name is
* "::tcl::mathfunc::<name>". */
Tcl_ObjCmdProc *objCmdProc; /* Function that evaluates the function */
- double (*fn)(double x); /* Real function pointer */
+ BuiltinUnaryFunc *fn; /* Real function pointer */
} BuiltinFuncDef;
static const BuiltinFuncDef BuiltinFuncTable[] = {
{ "abs", ExprAbsFunc, NULL },
{ "acos", ExprUnaryFunc, acos },
{ "asin", ExprUnaryFunc, asin },
{ "atan", ExprUnaryFunc, atan },
- { "atan2", ExprBinaryFunc, (double (*)(double))(void *)(double (*)(double, double)) atan2},
+ { "atan2", ExprBinaryFunc, BINARY_TYPECAST(atan2) },
{ "bool", ExprBoolFunc, NULL },
{ "ceil", ExprCeilFunc, NULL },
- { "cos", ExprUnaryFunc, cos },
+ { "cos", ExprUnaryFunc, cos },
{ "cosh", ExprUnaryFunc, cosh },
{ "double", ExprDoubleFunc, NULL },
{ "entier", ExprIntFunc, NULL },
- { "exp", ExprUnaryFunc, exp },
+ { "exp", ExprUnaryFunc, exp },
{ "floor", ExprFloorFunc, NULL },
- { "fmod", ExprBinaryFunc, (double (*)(double))(void *)(double (*)(double, double)) fmod},
- { "hypot", ExprBinaryFunc, (double (*)(double))(void *)(double (*)(double, double)) hypot},
+ { "fmod", ExprBinaryFunc, BINARY_TYPECAST(fmod) },
+ { "hypot", ExprBinaryFunc, BINARY_TYPECAST(hypot) },
{ "int", ExprIntFunc, NULL },
- { "isfinite", ExprIsFiniteFunc, NULL },
- { "isinf", ExprIsInfinityFunc, NULL },
- { "isnan", ExprIsNaNFunc, NULL },
- { "isnormal", ExprIsNormalFunc, NULL },
+ { "isfinite", ExprIsFiniteFunc, NULL },
+ { "isinf", ExprIsInfinityFunc, NULL },
+ { "isnan", ExprIsNaNFunc, NULL },
+ { "isnormal", ExprIsNormalFunc, NULL },
{ "isqrt", ExprIsqrtFunc, NULL },
- { "issubnormal", ExprIsSubnormalFunc, NULL, },
- { "isunordered", ExprIsUnorderedFunc, NULL, },
- { "log", ExprUnaryFunc, log },
+ { "issubnormal", ExprIsSubnormalFunc, NULL, },
+ { "isunordered", ExprIsUnorderedFunc, NULL, },
+ { "log", ExprUnaryFunc, log },
{ "log10", ExprUnaryFunc, log10 },
{ "max", ExprMaxFunc, NULL },
{ "min", ExprMinFunc, NULL },
- { "pow", ExprBinaryFunc, (double (*)(double))(void *)(double (*)(double, double)) pow},
+ { "pow", ExprBinaryFunc, BINARY_TYPECAST(pow) },
{ "rand", ExprRandFunc, NULL },
{ "round", ExprRoundFunc, NULL },
- { "sin", ExprUnaryFunc, sin },
+ { "sin", ExprUnaryFunc, sin },
{ "sinh", ExprUnaryFunc, sinh },
{ "sqrt", ExprSqrtFunc, NULL },
{ "srand", ExprSrandFunc, NULL },
- { "tan", ExprUnaryFunc, tan },
+ { "tan", ExprUnaryFunc, tan },
{ "tanh", ExprUnaryFunc, tanh },
{ "wide", ExprWideFunc, NULL },
{ NULL, NULL, NULL }
@@ -628,8 +631,8 @@ TclFinalizeEvaluation(void)
Tcl_MutexLock(&commandTypeLock);
if (commandTypeInit) {
- Tcl_DeleteHashTable(&commandTypeTable);
- commandTypeInit = 0;
+ Tcl_DeleteHashTable(&commandTypeTable);
+ commandTypeInit = 0;
}
Tcl_MutexUnlock(&commandTypeLock);
}
@@ -668,8 +671,8 @@ buildInfoObjCmd2(
char buf[80];
const char *p = strchr((char *)clientData, '.');
if (p) {
- const char *q = strchr(p+1, '.');
- const char *r = strchr(p+1, '+');
+ const char *q = strchr(p + 1, '.');
+ const char *r = strchr(p + 1, '+');
p = (q < r) ? q : r;
}
if (p) {
@@ -692,42 +695,45 @@ buildInfoObjCmd2(
if (p) {
if ((q = strchr(p, '.'))) {
char buf[80];
- memcpy(buf, p+1, q - p - 1);
+ memcpy(buf, p + 1, q - p - 1);
buf[q - p - 1] = '\0';
Tcl_AppendResult(interp, buf, (char *)NULL);
} else {
- Tcl_AppendResult(interp, p+1, (char *)NULL);
+ Tcl_AppendResult(interp, p + 1, (char *)NULL);
}
}
return TCL_OK;
} else if (len == 8 && !strcmp(arg, "compiler")) {
const char *p = strchr((char *)clientData, '.');
while (p) {
- if (!strncmp(p+1, "clang-", 6) || !strncmp(p+1, "gcc-", 4)
- || !strncmp(p+1, "icc-", 4) || !strncmp(p+1, "msvc-", 5)) {
- const char *q = strchr(p+1, '.');
+ if (!strncmp(p + 1, "clang-", 6)
+ || !strncmp(p + 1, "gcc-", 4)
+ || !strncmp(p + 1, "icc-", 4)
+ || !strncmp(p + 1, "msvc-", 5)) {
+ const char *q = strchr(p + 1, '.');
if (q) {
char buf[16];
- memcpy(buf, p+1, q - p - 1);
+ memcpy(buf, p + 1, q - p - 1);
buf[q - p - 1] = '\0';
Tcl_AppendResult(interp, buf, (char *)NULL);
} else {
- Tcl_AppendResult(interp, p+1, (char *)NULL);
+ Tcl_AppendResult(interp, p + 1, (char *)NULL);
}
return TCL_OK;
}
- p = strchr(p+1, '.');
+ p = strchr(p + 1, '.');
}
Tcl_AppendResult(interp, "0", (char *)NULL);
return TCL_OK;
}
const char *p = strchr((char *)clientData, '.');
while (p) {
- if (!strncmp(p+1, arg, len) && ((p[len+1] == '.') || (p[len+1] == '\0'))) {
+ if (!strncmp(p + 1, arg, len)
+ && ((p[len + 1] == '.') || (p[len + 1] == '\0'))) {
Tcl_AppendResult(interp, "1", (char *)NULL);
return TCL_OK;
}
- p = strchr(p+1, '.');
+ p = strchr(p + 1, '.');
}
Tcl_AppendResult(interp, "0", (char *)NULL);
return TCL_OK;
@@ -819,16 +825,16 @@ Tcl_CreateInterp(void)
#undef TclObjInterpProc
if (commandTypeInit == 0) {
- TclRegisterCommandTypeName(TclObjInterpProc, "proc");
- TclRegisterCommandTypeName(TclEnsembleImplementationCmd, "ensemble");
- TclRegisterCommandTypeName(TclAliasObjCmd, "alias");
- TclRegisterCommandTypeName(TclLocalAliasObjCmd, "alias");
- TclRegisterCommandTypeName(TclChildObjCmd, "interp");
- TclRegisterCommandTypeName(TclInvokeImportedCmd, "import");
- TclRegisterCommandTypeName(TclOOPublicObjectCmd, "object");
- TclRegisterCommandTypeName(TclOOPrivateObjectCmd, "privateObject");
- TclRegisterCommandTypeName(TclOOMyClassObjCmd, "privateClass");
- TclRegisterCommandTypeName(TclNRInterpCoroutine, "coroutine");
+ TclRegisterCommandTypeName(TclObjInterpProc, "proc");
+ TclRegisterCommandTypeName(TclEnsembleImplementationCmd, "ensemble");
+ TclRegisterCommandTypeName(TclAliasObjCmd, "alias");
+ TclRegisterCommandTypeName(TclLocalAliasObjCmd, "alias");
+ TclRegisterCommandTypeName(TclChildObjCmd, "interp");
+ TclRegisterCommandTypeName(TclInvokeImportedCmd, "import");
+ TclRegisterCommandTypeName(TclOOPublicObjectCmd, "object");
+ TclRegisterCommandTypeName(TclOOPrivateObjectCmd, "privateObject");
+ TclRegisterCommandTypeName(TclOOMyClassObjCmd, "privateClass");
+ TclRegisterCommandTypeName(TclNRInterpCoroutine, "coroutine");
}
/*
@@ -941,7 +947,7 @@ Tcl_CreateInterp(void)
iPtr->flags |= INTERP_DEBUG_FRAME;
#else
if (getenv("TCL_INTERP_DEBUG_FRAME") != NULL) {
- iPtr->flags |= INTERP_DEBUG_FRAME;
+ iPtr->flags |= INTERP_DEBUG_FRAME;
}
#endif
@@ -967,7 +973,7 @@ Tcl_CreateInterp(void)
*/
/* This is needed to satisfy GCC 3.3's strict aliasing rules */
- framePtr = (CallFrame *)Tcl_Alloc(sizeof(CallFrame));
+ framePtr = (CallFrame *) Tcl_Alloc(sizeof(CallFrame));
(void) Tcl_PushCallFrame(interp, (Tcl_CallFrame *) framePtr,
(Tcl_Namespace *) iPtr->globalNsPtr, /*isProcCallFrame*/ 0);
framePtr->objc = 0;
@@ -997,7 +1003,7 @@ Tcl_CreateInterp(void)
TclNewObj(iPtr->asyncCancelMsg);
- cancelInfo = (CancelInfo *)Tcl_Alloc(sizeof(CancelInfo));
+ cancelInfo = (CancelInfo *) Tcl_Alloc(sizeof(CancelInfo));
cancelInfo->interp = interp;
iPtr->asyncCancel = Tcl_AsyncCreate(CancelEvalProc, cancelInfo);
@@ -1061,7 +1067,7 @@ Tcl_CreateInterp(void)
*/
#if TCL_THREADS && defined(USE_THREAD_ALLOC)
- iPtr->allocCache = (AllocCache *)TclpGetAllocCache();
+ iPtr->allocCache = (AllocCache *) TclpGetAllocCache();
#else
iPtr->allocCache = NULL;
#endif
@@ -1085,7 +1091,7 @@ Tcl_CreateInterp(void)
hPtr = Tcl_CreateHashEntry(&iPtr->globalNsPtr->cmdTable,
cmdInfoPtr->name, &isNew);
if (isNew) {
- cmdPtr = (Command *)Tcl_Alloc(sizeof(Command));
+ cmdPtr = (Command *) Tcl_Alloc(sizeof(Command));
cmdPtr->hPtr = hPtr;
cmdPtr->nsPtr = iPtr->globalNsPtr;
cmdPtr->refCount = 1;
@@ -1098,9 +1104,9 @@ Tcl_CreateInterp(void)
cmdPtr->deleteProc = NULL;
cmdPtr->deleteData = NULL;
cmdPtr->flags = 0;
- if (cmdInfoPtr->flags & CMD_COMPILES_EXPANDED) {
- cmdPtr->flags |= CMD_COMPILES_EXPANDED;
- }
+ if (cmdInfoPtr->flags & CMD_COMPILES_EXPANDED) {
+ cmdPtr->flags |= CMD_COMPILES_EXPANDED;
+ }
cmdPtr->importRefPtr = NULL;
cmdPtr->tracePtr = NULL;
cmdPtr->nreProc = cmdInfoPtr->nreProc;
@@ -1160,15 +1166,15 @@ Tcl_CreateInterp(void)
/* Adding the bytecode assembler command */
cmdPtr = (Command *) Tcl_NRCreateCommand(interp,
- "::tcl::unsupported::assemble", Tcl_AssembleObjCmd,
- TclNRAssembleObjCmd, NULL, NULL);
+ "::tcl::unsupported::assemble", Tcl_AssembleObjCmd,
+ TclNRAssembleObjCmd, NULL, NULL);
cmdPtr->compileProc = &TclCompileAssembleCmd;
/* Coroutine monkeybusiness */
Tcl_NRCreateCommand(interp, "::tcl::unsupported::inject", NULL,
NRInjectObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tcl::unsupported::corotype",
- CoroTypeObjCmd, NULL, NULL);
+ CoroTypeObjCmd, NULL, NULL);
/* Export unsupported commands */
nsPtr = Tcl_FindNamespace(interp, "::tcl::unsupported", NULL, 0);
@@ -1176,7 +1182,6 @@ Tcl_CreateInterp(void)
Tcl_Export(interp, nsPtr, "*", 1);
}
-
#ifdef USE_DTRACE
/*
* Register the tcl::dtrace command.
@@ -1197,7 +1202,7 @@ Tcl_CreateInterp(void)
memcpy(mathFuncName, "::tcl::mathfunc::", MATH_FUNC_PREFIX_LEN);
for (builtinFuncPtr = BuiltinFuncTable; builtinFuncPtr->name != NULL;
builtinFuncPtr++) {
- strcpy(mathFuncName+MATH_FUNC_PREFIX_LEN, builtinFuncPtr->name);
+ strcpy(mathFuncName + MATH_FUNC_PREFIX_LEN, builtinFuncPtr->name);
Tcl_CreateObjCommand(interp, mathFuncName,
builtinFuncPtr->objCmdProc, (void *)builtinFuncPtr->fn, NULL);
Tcl_Export(interp, nsPtr, builtinFuncPtr->name, 0);
@@ -1215,7 +1220,8 @@ Tcl_CreateInterp(void)
#define MATH_OP_PREFIX_LEN 15 /* == strlen("::tcl::mathop::") */
memcpy(mathFuncName, "::tcl::mathop::", MATH_OP_PREFIX_LEN);
for (opcmdInfoPtr=mathOpCmds ; opcmdInfoPtr->name!=NULL ; opcmdInfoPtr++){
- TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)Tcl_Alloc(sizeof(TclOpCmdClientData));
+ TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)
+ Tcl_Alloc(sizeof(TclOpCmdClientData));
occdPtr->op = opcmdInfoPtr->name;
occdPtr->i.numArgs = opcmdInfoPtr->i.numArgs;
@@ -1321,7 +1327,7 @@ static void
DeleteOpCmdClientData(
void *clientData)
{
- TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
+ TclOpCmdClientData *occdPtr = (TclOpCmdClientData *) clientData;
Tcl_Free(occdPtr);
}
@@ -1331,10 +1337,10 @@ DeleteOpCmdClientData(
*
* TclRegisterCommandTypeName, TclGetCommandTypeName --
*
- * Command type registration and lookup mechanism. Everything is keyed by
- * the Tcl_ObjCmdProc for the command, and that is used as the *key* into
- * the hash table that maps to constant strings that are names. (It is
- * recommended that those names be ASCII.)
+ * Command type registration and lookup mechanism. Everything is keyed by
+ * the Tcl_ObjCmdProc for the command, and that is used as the *key* into
+ * the hash table that maps to constant strings that are names. (It is
+ * recommended that those names be ASCII.)
*
* ---------------------------------------------------------------------
*/
@@ -1348,21 +1354,21 @@ TclRegisterCommandTypeName(
Tcl_MutexLock(&commandTypeLock);
if (commandTypeInit == 0) {
- Tcl_InitHashTable(&commandTypeTable, TCL_ONE_WORD_KEYS);
- commandTypeInit = 1;
+ Tcl_InitHashTable(&commandTypeTable, TCL_ONE_WORD_KEYS);
+ commandTypeInit = 1;
}
if (nameStr != NULL) {
- int isNew;
+ int isNew;
- hPtr = Tcl_CreateHashEntry(&commandTypeTable,
- implementationProc, &isNew);
- Tcl_SetHashValue(hPtr, (void *) nameStr);
+ hPtr = Tcl_CreateHashEntry(&commandTypeTable,
+ implementationProc, &isNew);
+ Tcl_SetHashValue(hPtr, (void *) nameStr);
} else {
- hPtr = Tcl_FindHashEntry(&commandTypeTable,
- implementationProc);
- if (hPtr != NULL) {
- Tcl_DeleteHashEntry(hPtr);
- }
+ hPtr = Tcl_FindHashEntry(&commandTypeTable,
+ implementationProc);
+ if (hPtr != NULL) {
+ Tcl_DeleteHashEntry(hPtr);
+ }
}
Tcl_MutexUnlock(&commandTypeLock);
}
@@ -1376,15 +1382,15 @@ TclGetCommandTypeName(
const char *name = "native";
if (procPtr == NULL) {
- procPtr = cmdPtr->nreProc;
+ procPtr = cmdPtr->nreProc;
}
Tcl_MutexLock(&commandTypeLock);
if (commandTypeInit) {
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&commandTypeTable, procPtr);
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&commandTypeTable, procPtr);
- if (hPtr && Tcl_GetHashValue(hPtr)) {
- name = (const char *) Tcl_GetHashValue(hPtr);
- }
+ if (hPtr && Tcl_GetHashValue(hPtr)) {
+ name = (const char *) Tcl_GetHashValue(hPtr);
+ }
}
Tcl_MutexUnlock(&commandTypeLock);
@@ -1424,41 +1430,43 @@ TclHideUnsafeCommands(
}
for (unsafePtr = unsafeEnsembleCommands;
- unsafePtr->ensembleNsName; unsafePtr++) {
- if (unsafePtr->commandName) {
- /*
- * Hide an ensemble subcommand.
- */
-
- Tcl_Obj *cmdName = Tcl_ObjPrintf("::tcl::%s::%s",
- unsafePtr->ensembleNsName, unsafePtr->commandName);
- Tcl_Obj *hideName = Tcl_ObjPrintf("tcl:%s:%s",
- unsafePtr->ensembleNsName, unsafePtr->commandName);
-
- if (TclRenameCommand(interp, TclGetString(cmdName),
- "___tmp") != TCL_OK
- || Tcl_HideCommand(interp, "___tmp",
- TclGetString(hideName)) != TCL_OK) {
- Tcl_Panic("problem making '%s %s' safe: %s",
- unsafePtr->ensembleNsName, unsafePtr->commandName,
- Tcl_GetStringResult(interp));
- }
- Tcl_CreateObjCommand(interp, TclGetString(cmdName),
- BadEnsembleSubcommand, (void *)unsafePtr, NULL);
- TclDecrRefCount(cmdName);
- TclDecrRefCount(hideName);
- } else {
- /*
- * Hide an ensemble main command (for compatibility).
- */
-
- if (Tcl_HideCommand(interp, unsafePtr->ensembleNsName,
- unsafePtr->ensembleNsName) != TCL_OK) {
- Tcl_Panic("problem making '%s' safe: %s",
- unsafePtr->ensembleNsName,
- Tcl_GetStringResult(interp));
- }
- }
+ unsafePtr->ensembleNsName; unsafePtr++) {
+ if (unsafePtr->commandName) {
+ /*
+ * Hide an ensemble subcommand.
+ */
+
+ Tcl_Obj *cmdName = Tcl_ObjPrintf("::tcl::%s::%s",
+ unsafePtr->ensembleNsName, unsafePtr->commandName);
+ Tcl_Obj *hideName = Tcl_ObjPrintf("tcl:%s:%s",
+ unsafePtr->ensembleNsName, unsafePtr->commandName);
+
+#define INTERIM_HACK_NAME "___tmp"
+
+ if (TclRenameCommand(interp, TclGetString(cmdName),
+ INTERIM_HACK_NAME) != TCL_OK
+ || Tcl_HideCommand(interp, INTERIM_HACK_NAME,
+ TclGetString(hideName)) != TCL_OK) {
+ Tcl_Panic("problem making '%s %s' safe: %s",
+ unsafePtr->ensembleNsName, unsafePtr->commandName,
+ Tcl_GetStringResult(interp));
+ }
+ Tcl_CreateObjCommand(interp, TclGetString(cmdName),
+ BadEnsembleSubcommand, (void *)unsafePtr, NULL);
+ TclDecrRefCount(cmdName);
+ TclDecrRefCount(hideName);
+ } else {
+ /*
+ * Hide an ensemble main command (for compatibility).
+ */
+
+ if (Tcl_HideCommand(interp, unsafePtr->ensembleNsName,
+ unsafePtr->ensembleNsName) != TCL_OK) {
+ Tcl_Panic("problem making '%s' safe: %s",
+ unsafePtr->ensembleNsName,
+ Tcl_GetStringResult(interp));
+ }
+ }
}
return TCL_OK;
@@ -1492,8 +1500,8 @@ BadEnsembleSubcommand(
const UnsafeEnsembleInfo *infoPtr = (const UnsafeEnsembleInfo *)clientData;
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "not allowed to invoke subcommand %s of %s",
- infoPtr->commandName, infoPtr->ensembleNsName));
+ "not allowed to invoke subcommand %s of %s",
+ infoPtr->commandName, infoPtr->ensembleNsName));
Tcl_SetErrorCode(interp, "TCL", "SAFE", "SUBCOMMAND", (char *)NULL);
return TCL_ERROR;
}
@@ -1524,22 +1532,22 @@ Tcl_CallWhenDeleted(
Tcl_Interp *interp, /* Interpreter to watch. */
Tcl_InterpDeleteProc *proc, /* Function to call when interpreter is about
* to be deleted. */
- void *clientData) /* One-word value to pass to proc. */
+ void *clientData) /* One-word value to pass to proc. */
{
Interp *iPtr = (Interp *) interp;
static Tcl_ThreadDataKey assocDataCounterKey;
- int *assocDataCounterPtr =
- (int *)Tcl_GetThreadData(&assocDataCounterKey, sizeof(int));
+ int *assocDataCounterPtr = (int *)
+ Tcl_GetThreadData(&assocDataCounterKey, sizeof(int));
int isNew;
char buffer[32 + TCL_INTEGER_SPACE];
- AssocData *dPtr = (AssocData *)Tcl_Alloc(sizeof(AssocData));
+ AssocData *dPtr = (AssocData *) Tcl_Alloc(sizeof(AssocData));
Tcl_HashEntry *hPtr;
snprintf(buffer, sizeof(buffer), "Assoc Data Key #%d", *assocDataCounterPtr);
(*assocDataCounterPtr)++;
if (iPtr->assocData == NULL) {
- iPtr->assocData = (Tcl_HashTable *)Tcl_Alloc(sizeof(Tcl_HashTable));
+ iPtr->assocData = (Tcl_HashTable *) Tcl_Alloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(iPtr->assocData, TCL_STRING_KEYS);
}
hPtr = Tcl_CreateHashEntry(iPtr->assocData, buffer, &isNew);
@@ -1572,7 +1580,7 @@ Tcl_DontCallWhenDeleted(
Tcl_Interp *interp, /* Interpreter to watch. */
Tcl_InterpDeleteProc *proc, /* Function to call when interpreter is about
* to be deleted. */
- void *clientData) /* One-word value to pass to proc. */
+ void *clientData) /* One-word value to pass to proc. */
{
Interp *iPtr = (Interp *) interp;
Tcl_HashTable *hTablePtr;
@@ -1586,7 +1594,7 @@ Tcl_DontCallWhenDeleted(
}
for (hPtr = Tcl_FirstHashEntry(hTablePtr, &hSearch); hPtr != NULL;
hPtr = Tcl_NextHashEntry(&hSearch)) {
- dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
+ dPtr = (AssocData *) Tcl_GetHashValue(hPtr);
if ((dPtr->proc == proc) && (dPtr->clientData == clientData)) {
Tcl_Free(dPtr);
Tcl_DeleteHashEntry(hPtr);
@@ -1620,7 +1628,7 @@ Tcl_SetAssocData(
const char *name, /* Name for association. */
Tcl_InterpDeleteProc *proc, /* Proc to call when interpreter is about to
* be deleted. */
- void *clientData) /* One-word value to pass to proc. */
+ void *clientData) /* One-word value to pass to proc. */
{
Interp *iPtr = (Interp *) interp;
AssocData *dPtr;
@@ -1628,14 +1636,14 @@ Tcl_SetAssocData(
int isNew;
if (iPtr->assocData == NULL) {
- iPtr->assocData = (Tcl_HashTable *)Tcl_Alloc(sizeof(Tcl_HashTable));
+ iPtr->assocData = (Tcl_HashTable *) Tcl_Alloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(iPtr->assocData, TCL_STRING_KEYS);
}
hPtr = Tcl_CreateHashEntry(iPtr->assocData, name, &isNew);
if (isNew == 0) {
- dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
+ dPtr = (AssocData *) Tcl_GetHashValue(hPtr);
} else {
- dPtr = (AssocData *)Tcl_Alloc(sizeof(AssocData));
+ dPtr = (AssocData *) Tcl_Alloc(sizeof(AssocData));
}
dPtr->proc = proc;
dPtr->clientData = clientData;
@@ -1676,7 +1684,7 @@ Tcl_DeleteAssocData(
if (hPtr == NULL) {
return;
}
- dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
+ dPtr = (AssocData *) Tcl_GetHashValue(hPtr);
Tcl_DeleteHashEntry(hPtr);
if (dPtr->proc != NULL) {
dPtr->proc(dPtr->clientData, interp);
@@ -1721,7 +1729,7 @@ Tcl_GetAssocData(
if (hPtr == NULL) {
return NULL;
}
- dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
+ dPtr = (AssocData *) Tcl_GetHashValue(hPtr);
if (procPtr != NULL) {
*procPtr = dPtr->proc;
}
@@ -1873,7 +1881,7 @@ DeleteInterpProc(
Tcl_MutexLock(&cancelLock);
hPtr = Tcl_FindHashEntry(&cancelTable, iPtr);
if (hPtr != NULL) {
- CancelInfo *cancelInfo = (CancelInfo *)Tcl_GetHashValue(hPtr);
+ CancelInfo *cancelInfo = (CancelInfo *) Tcl_GetHashValue(hPtr);
if (cancelInfo != NULL) {
if (cancelInfo->result != NULL) {
@@ -1931,13 +1939,13 @@ DeleteInterpProc(
hPtr = Tcl_FirstHashEntry(hTablePtr, &search);
for (; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_DeleteCommandFromToken(interp, (Tcl_Command)Tcl_GetHashValue(hPtr));
+ Tcl_DeleteCommandFromToken(interp,
+ (Tcl_Command) Tcl_GetHashValue(hPtr));
}
Tcl_DeleteHashTable(hTablePtr);
Tcl_Free(hTablePtr);
}
-
if (iPtr->assocData != NULL) {
AssocData *dPtr;
@@ -1949,7 +1957,7 @@ DeleteInterpProc(
for (hPtr = Tcl_FirstHashEntry(hTablePtr, &search);
hPtr != NULL;
hPtr = Tcl_FirstHashEntry(hTablePtr, &search)) {
- dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
+ dPtr = (AssocData *) Tcl_GetHashValue(hPtr);
if (dPtr->proc != NULL) {
dPtr->proc(dPtr->clientData, interp);
}
@@ -2037,7 +2045,7 @@ DeleteInterpProc(
for (hPtr = Tcl_FirstHashEntry(iPtr->linePBodyPtr, &search);
hPtr != NULL;
hPtr = Tcl_NextHashEntry(&search)) {
- CmdFrame *cfPtr = (CmdFrame *)Tcl_GetHashValue(hPtr);
+ CmdFrame *cfPtr = (CmdFrame *) Tcl_GetHashValue(hPtr);
Proc *procPtr = (Proc *) Tcl_GetHashKey(iPtr->linePBodyPtr, hPtr);
procPtr->iPtr = NULL;
@@ -2061,7 +2069,7 @@ DeleteInterpProc(
for (hPtr = Tcl_FirstHashEntry(iPtr->lineBCPtr, &search);
hPtr != NULL;
hPtr = Tcl_NextHashEntry(&search)) {
- ExtCmdLoc *eclPtr = (ExtCmdLoc *)Tcl_GetHashValue(hPtr);
+ ExtCmdLoc *eclPtr = (ExtCmdLoc *) Tcl_GetHashValue(hPtr);
if (eclPtr->type == TCL_LOCATION_SOURCE) {
Tcl_DecrRefCount(eclPtr->path);
@@ -2190,7 +2198,7 @@ Tcl_HideCommand(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"cannot use namespace qualifiers in hidden command"
" token (rename)", -1));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "HIDDENTOKEN", (char *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "HIDDENTOKEN", (char *)NULL);
return TCL_ERROR;
}
@@ -2213,9 +2221,9 @@ Tcl_HideCommand(
if (cmdPtr->nsPtr != iPtr->globalNsPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can only hide global namespace commands (use rename then hide)",
- -1));
- Tcl_SetErrorCode(interp, "TCL", "HIDE", "NON_GLOBAL", (char *)NULL);
+ "can only hide global namespace commands (use rename then hide)",
+ -1));
+ Tcl_SetErrorCode(interp, "TCL", "HIDE", "NON_GLOBAL", (char *)NULL);
return TCL_ERROR;
}
@@ -2225,7 +2233,7 @@ Tcl_HideCommand(
hiddenCmdTablePtr = iPtr->hiddenCmdTablePtr;
if (hiddenCmdTablePtr == NULL) {
- hiddenCmdTablePtr = (Tcl_HashTable *)Tcl_Alloc(sizeof(Tcl_HashTable));
+ hiddenCmdTablePtr = (Tcl_HashTable *) Tcl_Alloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(hiddenCmdTablePtr, TCL_STRING_KEYS);
iPtr->hiddenCmdTablePtr = hiddenCmdTablePtr;
}
@@ -2239,9 +2247,9 @@ Tcl_HideCommand(
hPtr = Tcl_CreateHashEntry(hiddenCmdTablePtr, hiddenCmdToken, &isNew);
if (!isNew) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "hidden command named \"%s\" already exists",
- hiddenCmdToken));
- Tcl_SetErrorCode(interp, "TCL", "HIDE", "ALREADY_HIDDEN", (char *)NULL);
+ "hidden command named \"%s\" already exists",
+ hiddenCmdToken));
+ Tcl_SetErrorCode(interp, "TCL", "HIDE", "ALREADY_HIDDEN", (char *)NULL);
return TCL_ERROR;
}
@@ -2343,9 +2351,9 @@ Tcl_ExposeCommand(
if (strstr(cmdName, "::") != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "cannot expose to a namespace (use expose to toplevel, then rename)",
- -1));
- Tcl_SetErrorCode(interp, "TCL", "EXPOSE", "NON_GLOBAL", (char *)NULL);
+ "cannot expose to a namespace (use expose to toplevel, then rename)",
+ -1));
+ Tcl_SetErrorCode(interp, "TCL", "EXPOSE", "NON_GLOBAL", (char *)NULL);
return TCL_ERROR;
}
@@ -2360,12 +2368,12 @@ Tcl_ExposeCommand(
}
if (hPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "unknown hidden command \"%s\"", hiddenCmdToken));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "HIDDENTOKEN",
- hiddenCmdToken, (char *)NULL);
+ "unknown hidden command \"%s\"", hiddenCmdToken));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "HIDDENTOKEN",
+ hiddenCmdToken, (char *)NULL);
return TCL_ERROR;
}
- cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
+ cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
/*
* Check that we have a true global namespace command (enforced by
@@ -2399,8 +2407,8 @@ Tcl_ExposeCommand(
hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, cmdName, &isNew);
if (!isNew) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "exposed command \"%s\" already exists", cmdName));
- Tcl_SetErrorCode(interp, "TCL", "EXPOSE", "COMMAND_EXISTS", (char *)NULL);
+ "exposed command \"%s\" already exists", cmdName));
+ Tcl_SetErrorCode(interp, "TCL", "EXPOSE", "COMMAND_EXISTS", (char *)NULL);
return TCL_ERROR;
}
@@ -2497,7 +2505,7 @@ Tcl_CreateCommand(
* specified namespace; otherwise it is put in
* the global namespace. */
Tcl_CmdProc *proc, /* Function to associate with cmdName. */
- void *clientData, /* Arbitrary value passed to string proc. */
+ void *clientData, /* Arbitrary value passed to string proc. */
Tcl_CmdDeleteProc *deleteProc)
/* If not NULL, gives a function to call when
* this command is deleted. */
@@ -2528,26 +2536,26 @@ Tcl_CreateCommand(
*/
while (1) {
- /*
- * Determine where the command should reside. If its name contains
- * namespace qualifiers, we put it in the specified namespace;
+ /*
+ * Determine where the command should reside. If its name contains
+ * namespace qualifiers, we put it in the specified namespace;
* otherwise, we always put it in the global namespace.
- */
+ */
- if (strstr(cmdName, "::") != NULL) {
+ if (strstr(cmdName, "::") != NULL) {
Namespace *dummy1, *dummy2;
TclGetNamespaceForQualName(interp, cmdName, NULL,
TCL_CREATE_NS_IF_UNKNOWN, &nsPtr, &dummy1, &dummy2, &tail);
if ((nsPtr == NULL) || (tail == NULL)) {
- return (Tcl_Command) NULL;
+ return (Tcl_Command) NULL;
}
- } else {
+ } else {
nsPtr = iPtr->globalNsPtr;
tail = cmdName;
- }
+ }
- hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
+ hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew);
if (isNew || deleted) {
/*
@@ -2558,10 +2566,10 @@ Tcl_CreateCommand(
}
/*
- * An existing command conflicts. Try to delete it...
- */
+ * An existing command conflicts. Try to delete it...
+ */
- cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
+ cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
/*
* Be careful to preserve any existing import links so we can restore
@@ -2616,7 +2624,7 @@ Tcl_CreateCommand(
TclInvalidateNsCmdLookup(nsPtr);
TclInvalidateNsPath(nsPtr);
}
- cmdPtr = (Command *)Tcl_Alloc(sizeof(Command));
+ cmdPtr = (Command *) Tcl_Alloc(sizeof(Command));
Tcl_SetHashValue(hPtr, cmdPtr);
cmdPtr->hPtr = hPtr;
cmdPtr->nsPtr = nsPtr;
@@ -2643,7 +2651,7 @@ Tcl_CreateCommand(
cmdPtr->importRefPtr = oldRefPtr;
while (oldRefPtr != NULL) {
Command *refCmdPtr = oldRefPtr->importedCmdPtr;
- dataPtr = (ImportedCmdData *)refCmdPtr->objClientData;
+ dataPtr = (ImportedCmdData *) refCmdPtr->objClientData;
dataPtr->realCmdPtr = cmdPtr;
oldRefPtr = oldRefPtr->nextPtr;
}
@@ -2692,7 +2700,6 @@ typedef struct {
Tcl_ObjCmdProc2 *nreProc;
} CmdWrapperInfo;
-
static int
cmdWrapperProc(
void *clientData,
@@ -2700,7 +2707,7 @@ cmdWrapperProc(
int objc,
Tcl_Obj * const *objv)
{
- CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
+ CmdWrapperInfo *info = (CmdWrapperInfo *) clientData;
if (objc < 0) {
objc = -1;
}
@@ -2711,7 +2718,7 @@ static void
cmdWrapperDeleteProc(
void *clientData)
{
- CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
+ CmdWrapperInfo *info = (CmdWrapperInfo *) clientData;
clientData = info->deleteData;
Tcl_CmdDeleteProc *deleteProc = info->deleteProc;
@@ -2731,14 +2738,14 @@ Tcl_CreateObjCommand2(
* the global namespace. */
Tcl_ObjCmdProc2 *proc, /* Object-based function to associate with
* name. */
- void *clientData, /* Arbitrary value to pass to object
+ void *clientData, /* Arbitrary value to pass to object
* function. */
Tcl_CmdDeleteProc *deleteProc
/* If not NULL, gives a function to call when
* this command is deleted. */
)
{
- CmdWrapperInfo *info = (CmdWrapperInfo *)Tcl_Alloc(sizeof(CmdWrapperInfo));
+ CmdWrapperInfo *info = (CmdWrapperInfo *) Tcl_Alloc(sizeof(CmdWrapperInfo));
info->proc = proc;
info->clientData = clientData;
info->deleteProc = deleteProc;
@@ -2759,7 +2766,7 @@ Tcl_CreateObjCommand(
* the global namespace. */
Tcl_ObjCmdProc *proc, /* Object-based function to associate with
* name. */
- void *clientData, /* Arbitrary value to pass to object
+ void *clientData, /* Arbitrary value to pass to object
* function. */
Tcl_CmdDeleteProc *deleteProc
/* If not NULL, gives a function to call when
@@ -2805,11 +2812,11 @@ Tcl_Command
TclCreateObjCommandInNs(
Tcl_Interp *interp,
const char *cmdName, /* Name of command, without any namespace
- * components. */
- Tcl_Namespace *namesp, /* The namespace to create the command in */
+ * components. */
+ Tcl_Namespace *namesp, /* The namespace to create the command in */
Tcl_ObjCmdProc *proc, /* Object-based function to associate with
* name. */
- void *clientData, /* Arbitrary value to pass to object
+ void *clientData, /* Arbitrary value to pass to object
* function. */
Tcl_CmdDeleteProc *deleteProc)
/* If not NULL, gives a function to call when
@@ -2841,10 +2848,10 @@ TclCreateObjCommandInNs(
}
/*
- * An existing command conflicts. Try to delete it...
- */
+ * An existing command conflicts. Try to delete it...
+ */
- cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
+ cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
/*
* Command already exists; delete it. Be careful to preserve any
@@ -2859,14 +2866,14 @@ TclCreateObjCommandInNs(
}
/*
- * Make sure namespace doesn't get deallocated.
- */
+ * Make sure namespace doesn't get deallocated.
+ */
cmdPtr->nsPtr->refCount++;
Tcl_DeleteCommandFromToken(interp, (Tcl_Command) cmdPtr);
nsPtr = (Namespace *) TclEnsureNamespace(interp,
- (Tcl_Namespace *) cmdPtr->nsPtr);
+ (Tcl_Namespace *) cmdPtr->nsPtr);
TclNsDecrRefCount(cmdPtr->nsPtr);
if (cmdPtr->flags & CMD_REDEF_IN_PROGRESS) {
@@ -2908,7 +2915,7 @@ TclCreateObjCommandInNs(
TclInvalidateNsCmdLookup(nsPtr);
TclInvalidateNsPath(nsPtr);
}
- cmdPtr = (Command *)Tcl_Alloc(sizeof(Command));
+ cmdPtr = (Command *) Tcl_Alloc(sizeof(Command));
Tcl_SetHashValue(hPtr, cmdPtr);
cmdPtr->hPtr = hPtr;
cmdPtr->nsPtr = nsPtr;
@@ -2936,7 +2943,7 @@ TclCreateObjCommandInNs(
while (oldRefPtr != NULL) {
Command *refCmdPtr = oldRefPtr->importedCmdPtr;
- dataPtr = (ImportedCmdData*)refCmdPtr->objClientData;
+ dataPtr = (ImportedCmdData*) refCmdPtr->objClientData;
cmdPtr->refCount++;
TclCleanupCommandMacro(dataPtr->realCmdPtr);
dataPtr->realCmdPtr = cmdPtr;
@@ -2978,12 +2985,12 @@ TclCreateObjCommandInNs(
int
InvokeStringCommand(
- void *clientData, /* Points to command's Command structure. */
+ void *clientData, /* Points to command's Command structure. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Command *cmdPtr = (Command *)clientData;
+ Command *cmdPtr = (Command *) clientData;
int i, result;
const char **argv = (const char **)
TclStackAlloc(interp, (objc + 1) * sizeof(char *));
@@ -3052,10 +3059,10 @@ TclRenameCommand(
cmdPtr = (Command *) cmd;
if (cmdPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't %s \"%s\": command doesn't exist",
- ((newName == NULL)||(*newName == '\0'))? "delete":"rename",
+ "can't %s \"%s\": command doesn't exist",
+ ((newName == NULL) || (*newName == '\0')) ? "delete" : "rename",
oldName));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND", oldName, (char *)NULL);
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND", oldName, (char *)NULL);
return TCL_ERROR;
}
@@ -3085,16 +3092,16 @@ TclRenameCommand(
if ((newNsPtr == NULL) || (newTail == NULL)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't rename to \"%s\": bad command name", newName));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMMAND", (char *)NULL);
+ "can't rename to \"%s\": bad command name", newName));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMMAND", (char *)NULL);
result = TCL_ERROR;
goto done;
}
if (Tcl_FindHashEntry(&newNsPtr->cmdTable, newTail) != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't rename to \"%s\": command already exists", newName));
- Tcl_SetErrorCode(interp, "TCL", "OPERATION", "RENAME",
- "TARGET_EXISTS", (char *)NULL);
+ "can't rename to \"%s\": command already exists", newName));
+ Tcl_SetErrorCode(interp, "TCL", "OPERATION", "RENAME",
+ "TARGET_EXISTS", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -3266,7 +3273,7 @@ Tcl_SetCommandInfo(
static int
invokeObj2Command(
- void *clientData, /* Points to command's Command structure. */
+ void *clientData, /* Points to command's Command structure. */
Tcl_Interp *interp, /* Current interpreter. */
Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -3293,7 +3300,7 @@ cmdWrapper2Proc(
Tcl_Size objc,
Tcl_Obj *const objv[])
{
- Command *cmdPtr = (Command *)clientData;
+ Command *cmdPtr = (Command *) clientData;
if (objc > INT_MAX) {
return TclCommandWordLimitError(interp, objc);
}
@@ -3330,7 +3337,7 @@ Tcl_SetCommandInfoFromToken(
cmdPtr->objClientData = infoPtr->objClientData;
}
if (cmdPtr->deleteProc == cmdWrapperDeleteProc) {
- CmdWrapperInfo *info = (CmdWrapperInfo *)cmdPtr->deleteData;
+ CmdWrapperInfo *info = (CmdWrapperInfo *) cmdPtr->deleteData;
if (infoPtr->objProc2 == NULL) {
info->proc = invokeObj2Command;
info->clientData = cmdPtr;
@@ -3346,7 +3353,8 @@ Tcl_SetCommandInfoFromToken(
info->deleteData = infoPtr->deleteData;
} else {
if ((infoPtr->objProc2 != NULL) && (infoPtr->objProc2 != cmdWrapper2Proc)) {
- CmdWrapperInfo *info = (CmdWrapperInfo *)Tcl_Alloc(sizeof(CmdWrapperInfo));
+ CmdWrapperInfo *info = (CmdWrapperInfo *)
+ Tcl_Alloc(sizeof(CmdWrapperInfo));
info->proc = infoPtr->objProc2;
info->clientData = infoPtr->objClientData2;
info->nreProc = NULL;
@@ -3437,7 +3445,7 @@ Tcl_GetCommandInfoFromToken(
infoPtr->proc = cmdPtr->proc;
infoPtr->clientData = cmdPtr->clientData;
if (cmdPtr->deleteProc == cmdWrapperDeleteProc) {
- CmdWrapperInfo *info = (CmdWrapperInfo *)cmdPtr->deleteData;
+ CmdWrapperInfo *info = (CmdWrapperInfo *) cmdPtr->deleteData;
infoPtr->deleteProc = info->deleteProc;
infoPtr->deleteData = info->deleteData;
infoPtr->objProc2 = info->proc;
@@ -3491,7 +3499,7 @@ Tcl_GetCommandName(
return "";
}
- return (const char *)Tcl_GetHashKey(cmdPtr->hPtr->tablePtr, cmdPtr->hPtr);
+ return (const char *) Tcl_GetHashKey(cmdPtr->hPtr->tablePtr, cmdPtr->hPtr);
}
/*
@@ -3541,7 +3549,8 @@ Tcl_GetCommandFullName(
}
}
if (cmdPtr->hPtr != NULL) {
- name = (char *)Tcl_GetHashKey(cmdPtr->hPtr->tablePtr, cmdPtr->hPtr);
+ name = (char *)
+ Tcl_GetHashKey(cmdPtr->hPtr->tablePtr, cmdPtr->hPtr);
Tcl_AppendToObj(objPtr, name, -1);
}
}
@@ -3666,7 +3675,7 @@ Tcl_DeleteCommandFromToken(
if (cmdPtr->tracePtr != NULL) {
CommandTrace *tracePtr;
/* CallCommandTraces() does not cmdPtr, that's
- * done just before Tcl_DeleteCommandFromToken() returns */
+ * done just before Tcl_DeleteCommandFromToken() returns */
CallCommandTraces(iPtr,cmdPtr,NULL,NULL,TCL_TRACE_DELETE);
/*
@@ -3920,11 +3929,11 @@ CallCommandTraces(
static int
CancelEvalProc(
- void *clientData, /* Interp to cancel the script in progress. */
+ void *clientData, /* Interp to cancel the script in progress. */
TCL_UNUSED(Tcl_Interp *),
int code) /* Current return code from command. */
{
- CancelInfo *cancelInfo = (CancelInfo *)clientData;
+ CancelInfo *cancelInfo = (CancelInfo *) clientData;
Interp *iPtr;
if (cancelInfo != NULL) {
@@ -3998,7 +4007,7 @@ CancelEvalProc(
void
TclCleanupCommand(
- Command *cmdPtr) /* Points to the Command structure to
+ Command *cmdPtr) /* Points to the Command structure to
* be freed. */
{
if (cmdPtr->refCount-- <= 1) {
@@ -4150,7 +4159,7 @@ Tcl_Canceled(
*/
if (!TclCanceled(iPtr)) {
- return TCL_OK;
+ return TCL_OK;
}
/*
@@ -4171,7 +4180,7 @@ Tcl_Canceled(
*/
if ((flags & TCL_CANCEL_UNWIND) && !(iPtr->flags & TCL_CANCEL_UNWIND)) {
- return TCL_OK;
+ return TCL_OK;
}
/*
@@ -4180,34 +4189,34 @@ Tcl_Canceled(
*/
if (flags & TCL_LEAVE_ERR_MSG) {
- const char *id, *message = NULL;
- Tcl_Size length;
+ const char *id, *message = NULL;
+ Tcl_Size length;
- /*
- * Setup errorCode variables so that we can differentiate between
- * being canceled and unwound.
- */
+ /*
+ * Setup errorCode variables so that we can differentiate between
+ * being canceled and unwound.
+ */
- if (iPtr->asyncCancelMsg != NULL) {
- message = TclGetStringFromObj(iPtr->asyncCancelMsg, &length);
- } else {
- length = 0;
- }
+ if (iPtr->asyncCancelMsg != NULL) {
+ message = TclGetStringFromObj(iPtr->asyncCancelMsg, &length);
+ } else {
+ length = 0;
+ }
- if (iPtr->flags & TCL_CANCEL_UNWIND) {
- id = "IUNWIND";
- if (length == 0) {
- message = "eval unwound";
- }
- } else {
- id = "ICANCEL";
- if (length == 0) {
- message = "eval canceled";
- }
- }
+ if (iPtr->flags & TCL_CANCEL_UNWIND) {
+ id = "IUNWIND";
+ if (length == 0) {
+ message = "eval unwound";
+ }
+ } else {
+ id = "ICANCEL";
+ if (length == 0) {
+ message = "eval canceled";
+ }
+ }
- Tcl_SetObjResult(interp, Tcl_NewStringObj(message, -1));
- Tcl_SetErrorCode(interp, "TCL", "CANCEL", id, message, (char *)NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(message, -1));
+ Tcl_SetErrorCode(interp, "TCL", "CANCEL", id, message, (char *)NULL);
}
/*
@@ -4246,7 +4255,7 @@ Tcl_CancelEval(
* script. */
Tcl_Obj *resultObjPtr, /* The script cancellation error message or
* NULL for a default error message. */
- void *clientData, /* Passed to CancelEvalProc. */
+ void *clientData, /* Passed to CancelEvalProc. */
int flags) /* Collection of OR-ed bits that control
* the cancellation of the script. Only
* TCL_CANCEL_UNWIND is currently
@@ -4277,7 +4286,7 @@ Tcl_CancelEval(
goto done;
}
- cancelInfo = (CancelInfo *)Tcl_GetHashValue(hPtr);
+ cancelInfo = (CancelInfo *) Tcl_GetHashValue(hPtr);
/*
* Populate information needed by the interpreter thread to fulfill the
@@ -4289,7 +4298,8 @@ Tcl_CancelEval(
if (resultObjPtr != NULL) {
result = TclGetStringFromObj(resultObjPtr, &cancelInfo->length);
- cancelInfo->result = (char *)Tcl_Realloc(cancelInfo->result,cancelInfo->length);
+ cancelInfo->result = (char *)
+ Tcl_Realloc(cancelInfo->result, cancelInfo->length);
memcpy(cancelInfo->result, result, cancelInfo->length);
TclDecrRefCount(resultObjPtr); /* Discard their result object. */
} else {
@@ -4392,7 +4402,7 @@ TclNREvalObjv(
*/
if (iPtr->deferredCallbacks) {
- iPtr->deferredCallbacks = NULL;
+ iPtr->deferredCallbacks = NULL;
} else {
TclNRAddCallback(interp, NRCommand, NULL, NULL, NULL, NULL);
}
@@ -4409,10 +4419,10 @@ EvalObjvCore(
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
- Command *cmdPtr = NULL, *preCmdPtr = (Command *)data[0];
+ Command *cmdPtr = NULL, *preCmdPtr = (Command *) data[0];
int flags = PTR2INT(data[1]);
int objc = PTR2INT(data[2]);
- Tcl_Obj **objv = (Tcl_Obj **)data[3];
+ Tcl_Obj **objv = (Tcl_Obj **) data[3];
Interp *iPtr = (Interp *) interp;
Namespace *lookupNsPtr = NULL;
int enterTracesDone = 0;
@@ -4480,13 +4490,13 @@ EvalObjvCore(
assert(cmdPtr == NULL);
if (preCmdPtr) {
/*
- * Caller gave it to us.
- */
+ * Caller gave it to us.
+ */
if (!(preCmdPtr->flags & CMD_DEAD)) {
/*
- * So long as it exists, use it.
- */
+ * So long as it exists, use it.
+ */
cmdPtr = preCmdPtr;
} else if (flags & TCL_EVAL_NORESOLVE) {
@@ -4511,7 +4521,7 @@ EvalObjvCore(
if (enterTracesDone || iPtr->tracePtr
|| (cmdPtr->flags & CMD_HAS_EXEC_TRACES)) {
Tcl_Obj *commandPtr = TclGetSourceFromFrame(
- flags & TCL_EVAL_SOURCE_IN_FRAME ? iPtr->cmdFramePtr : NULL,
+ flags & TCL_EVAL_SOURCE_IN_FRAME ? iPtr->cmdFramePtr : NULL,
objc, objv);
Tcl_IncrRefCount(commandPtr);
@@ -4554,7 +4564,7 @@ EvalObjvCore(
cmdPtr->refCount++;
TclNRAddCallback(interp, TEOV_RunLeaveTraces, INT2PTR(objc),
- commandPtr, cmdPtr, objv);
+ commandPtr, cmdPtr, objv);
}
TclNRAddCallback(interp, Dispatch,
@@ -4569,10 +4579,10 @@ Dispatch(
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
- Tcl_ObjCmdProc *objProc = (Tcl_ObjCmdProc *)data[0];
+ Tcl_ObjCmdProc *objProc = (Tcl_ObjCmdProc *) data[0];
void *clientData = data[1];
Tcl_Size objc = PTR2INT(data[2]);
- Tcl_Obj **objv = (Tcl_Obj **)data[3];
+ Tcl_Obj **objv = (Tcl_Obj **) data[3];
Interp *iPtr = (Interp *) interp;
#ifdef USE_DTRACE
@@ -4617,8 +4627,8 @@ TclNRRunCallbacks(
* are to be run. */
{
while (TOP_CB(interp) != rootPtr) {
- NRE_callback *callbackPtr = TOP_CB(interp);
- Tcl_NRPostProc *procPtr = callbackPtr->procPtr;
+ NRE_callback *callbackPtr = TOP_CB(interp);
+ Tcl_NRPostProc *procPtr = callbackPtr->procPtr;
TOP_CB(interp) = callbackPtr->nextPtr;
result = procPtr(callbackPtr->data, interp, result);
@@ -4638,12 +4648,12 @@ NRCommand(
iPtr->numLevels--;
- /*
- * If there is a tailcall, schedule it next
- */
+ /*
+ * If there is a tailcall, schedule it next
+ */
if (data[1] && (data[1] != INT2PTR(1))) {
- listPtr = (Tcl_Obj *)data[1];
+ listPtr = (Tcl_Obj *) data[1];
data[1] = NULL;
TclNRAddCallback(interp, TclNRTailcallEval, listPtr, NULL, NULL, NULL);
@@ -4737,7 +4747,7 @@ TEOV_RestoreVarFrame(
Tcl_Interp *interp,
int result)
{
- ((Interp *) interp)->varFramePtr = (CallFrame *)data[0];
+ ((Interp *) interp)->varFramePtr = (CallFrame *) data[0];
return result;
}
@@ -4781,7 +4791,7 @@ TEOV_Error(
const char *cmdString;
Tcl_Size cmdLen;
int objc = PTR2INT(data[0]);
- Tcl_Obj **objv = (Tcl_Obj **)data[1];
+ Tcl_Obj **objv = (Tcl_Obj **) data[1];
if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
/*
@@ -4843,7 +4853,7 @@ TEOV_NotFound(
TclListObjGetElements(NULL, currNsPtr->unknownHandlerPtr,
&handlerObjc, &handlerObjv);
newObjc = objc + handlerObjc;
- newObjv = (Tcl_Obj **)TclStackAlloc(interp, sizeof(Tcl_Obj *) * newObjc);
+ newObjv = (Tcl_Obj **) TclStackAlloc(interp, sizeof(Tcl_Obj *) * newObjc);
/*
* Copy command prefix from unknown handler and add on the real command's
@@ -4855,7 +4865,7 @@ TEOV_NotFound(
newObjv[i] = handlerObjv[i];
Tcl_IncrRefCount(newObjv[i]);
}
- memcpy(newObjv+handlerObjc, objv, sizeof(Tcl_Obj *) * objc);
+ memcpy(newObjv + handlerObjc, objv, sizeof(Tcl_Obj *) * objc);
/*
* Look up and invoke the handler (by recursive call to this function). If
@@ -4870,9 +4880,9 @@ TEOV_NotFound(
cmdPtr = TEOV_LookupCmdFromObj(interp, newObjv[0], lookupNsPtr);
if (cmdPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "invalid command name \"%s\"", TclGetString(objv[0])));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND",
- TclGetString(objv[0]), (char *)NULL);
+ "invalid command name \"%s\"", TclGetString(objv[0])));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COMMAND",
+ TclGetString(objv[0]), (char *)NULL);
/*
* Release any resources we locked and allocated during the handler
@@ -4904,8 +4914,8 @@ TEOV_NotFoundCallback(
{
Interp *iPtr = (Interp *) interp;
int objc = PTR2INT(data[0]);
- Tcl_Obj **objv = (Tcl_Obj **)data[1];
- Namespace *savedNsPtr = (Namespace *)data[2];
+ Tcl_Obj **objv = (Tcl_Obj **) data[1];
+ Namespace *savedNsPtr = (Namespace *) data[2];
int i;
@@ -4985,9 +4995,9 @@ TEOV_RunLeaveTraces(
Interp *iPtr = (Interp *) interp;
int traceCode = TCL_OK;
int objc = PTR2INT(data[0]);
- Tcl_Obj *commandPtr = (Tcl_Obj *)data[1];
- Command *cmdPtr = (Command *)data[2];
- Tcl_Obj **objv = (Tcl_Obj **)data[3];
+ Tcl_Obj *commandPtr = (Tcl_Obj *) data[1];
+ Command *cmdPtr = (Command *) data[2];
+ Tcl_Obj **objv = (Tcl_Obj **) data[3];
Tcl_Size length;
const char *command = TclGetStringFromObj(commandPtr, &length);
@@ -5071,7 +5081,7 @@ Tcl_EvalTokensStandard(
* errors. */
Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to
* evaluate and concatenate. */
- Tcl_Size count) /* Number of tokens to consider at tokenPtr.
+ Tcl_Size count) /* Number of tokens to consider at tokenPtr.
* Must be at least 1. */
{
return TclSubstTokens(interp, tokenPtr, count, /* numLeftPtr */ NULL, 1,
@@ -5126,7 +5136,7 @@ TclEvalEx(
* evaluation of the script. Only
* TCL_EVAL_GLOBAL is currently supported. */
Tcl_Size line, /* The line the script starts on. */
- Tcl_Size *clNextOuter, /* Information about an outer context for */
+ Tcl_Size *clNextOuter, /* Information about an outer context for */
const char *outerScript) /* continuation line data. This is set only in
* TclSubstTokens(), to properly handle
* [...]-nested commands. The 'outerScript'
@@ -5162,15 +5172,18 @@ TclEvalEx(
* state has been allocated while evaluating
* the script, so that it can be freed
* properly if an error occurs. */
- Tcl_Parse *parsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse));
- CmdFrame *eeFramePtr = (CmdFrame *)TclStackAlloc(interp, sizeof(CmdFrame));
+ Tcl_Parse *parsePtr = (Tcl_Parse *)
+ TclStackAlloc(interp, sizeof(Tcl_Parse));
+ CmdFrame *eeFramePtr = (CmdFrame *)
+ TclStackAlloc(interp, sizeof(CmdFrame));
Tcl_Obj **stackObjArray = (Tcl_Obj **)
TclStackAlloc(interp, minObjs * sizeof(Tcl_Obj *));
- int *expandStack = (int *)TclStackAlloc(interp, minObjs * sizeof(int));
- Tcl_Size *linesStack = (Tcl_Size *)TclStackAlloc(interp, minObjs * sizeof(Tcl_Size));
+ int *expandStack = (int *) TclStackAlloc(interp, minObjs * sizeof(int));
+ Tcl_Size *linesStack = (Tcl_Size *)
+ TclStackAlloc(interp, minObjs * sizeof(Tcl_Size));
/* TIP #280 Structures for tracking of command
* locations. */
- Tcl_Size *clNext = NULL; /* Pointer for the tracking of invisible
+ Tcl_Size *clNext = NULL; /* Pointer for the tracking of invisible
* continuation lines. Initialized only if the
* caller gave us a table of locations to
* track, via scriptCLLocPtr. It always refers
@@ -5303,9 +5316,11 @@ TclEvalEx(
*/
if (numWords > minObjs) {
- expand = (int *)Tcl_Alloc(numWords * sizeof(int));
- objvSpace = (Tcl_Obj **)Tcl_Alloc(numWords * sizeof(Tcl_Obj *));
- lineSpace = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size));
+ expand = (int *) Tcl_Alloc(numWords * sizeof(int));
+ objvSpace = (Tcl_Obj **)
+ Tcl_Alloc(numWords * sizeof(Tcl_Obj *));
+ lineSpace = (Tcl_Size *)
+ Tcl_Alloc(numWords * sizeof(Tcl_Size));
}
expandRequested = 0;
objv = objvSpace;
@@ -5314,7 +5329,7 @@ TclEvalEx(
iPtr->cmdFramePtr = eeFramePtr->nextPtr;
for (objectsUsed = 0, tokenPtr = parsePtr->tokenPtr;
objectsUsed < numWords;
- objectsUsed++, tokenPtr += tokenPtr->numComponents+1) {
+ objectsUsed++, tokenPtr += tokenPtr->numComponents + 1) {
Tcl_Size additionalObjsCount;
/*
@@ -5337,7 +5352,7 @@ TclEvalEx(
iPtr->evalFlags |= TCL_EVAL_FILE;
}
- code = TclSubstTokens(interp, tokenPtr+1,
+ code = TclSubstTokens(interp, tokenPtr + 1,
tokenPtr->numComponents, NULL, wordLine,
wordCLNext, outerScript);
@@ -5359,7 +5374,8 @@ TclEvalEx(
*/
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
- "\n (expanding word %" TCL_SIZE_MODIFIER "d)", objectsUsed));
+ "\n (expanding word %" TCL_SIZE_MODIFIER "d)",
+ objectsUsed));
Tcl_DecrRefCount(objv[objectsUsed]);
break;
}
@@ -5402,9 +5418,10 @@ TclEvalEx(
Tcl_Size objIdx = objectsNeeded - 1;
if ((numWords > minObjs) || (objectsNeeded > minObjs)) {
- objv = objvSpace =
- (Tcl_Obj **)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Obj *));
- lines = lineSpace = (Tcl_Size *)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Size));
+ objv = objvSpace = (Tcl_Obj **)
+ Tcl_Alloc(objectsNeeded * sizeof(Tcl_Obj *));
+ lines = lineSpace = (Tcl_Size *)
+ Tcl_Alloc(objectsNeeded * sizeof(Tcl_Size));
}
objectsUsed = 0;
@@ -5428,7 +5445,7 @@ TclEvalEx(
objectsUsed++;
}
}
- objv += objIdx+1;
+ objv += objIdx + 1;
if (copy != stackObjArray) {
Tcl_Free(copy);
@@ -5725,7 +5742,7 @@ TclArgumentEnter(
* and initialize references.
*/
- cfwPtr = (CFWord *)Tcl_Alloc(sizeof(CFWord));
+ cfwPtr = (CFWord *) Tcl_Alloc(sizeof(CFWord));
cfwPtr->framePtr = cfPtr;
cfwPtr->word = i;
cfwPtr->refCount = 1;
@@ -5736,7 +5753,7 @@ TclArgumentEnter(
* relevant. Just remember the reference to prevent early removal.
*/
- cfwPtr = (CFWord *)Tcl_GetHashValue(hPtr);
+ cfwPtr = (CFWord *) Tcl_GetHashValue(hPtr);
cfwPtr->refCount++;
}
}
@@ -5773,13 +5790,12 @@ TclArgumentRelease(
for (i = 1; i < objc; i++) {
CFWord *cfwPtr;
- Tcl_HashEntry *hPtr =
- Tcl_FindHashEntry(iPtr->lineLAPtr, objv[i]);
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(iPtr->lineLAPtr, objv[i]);
if (!hPtr) {
continue;
}
- cfwPtr = (CFWord *)Tcl_GetHashValue(hPtr);
+ cfwPtr = (CFWord *) Tcl_GetHashValue(hPtr);
if (cfwPtr->refCount-- > 1) {
continue;
@@ -5825,13 +5841,12 @@ TclArgumentBCEnter(
ECL *ePtr;
CFWordBC *lastPtr = NULL;
Interp *iPtr = (Interp *) interp;
- Tcl_HashEntry *hePtr =
- Tcl_FindHashEntry(iPtr->lineBCPtr, codePtr);
+ Tcl_HashEntry *hePtr = Tcl_FindHashEntry(iPtr->lineBCPtr, codePtr);
if (!hePtr) {
return;
}
- eclPtr = (ExtCmdLoc *)Tcl_GetHashValue(hePtr);
+ eclPtr = (ExtCmdLoc *) Tcl_GetHashValue(hePtr);
ePtr = &eclPtr->loc[cmd];
/*
@@ -5848,7 +5863,7 @@ TclArgumentBCEnter(
*/
if (ePtr->nline != objc) {
- return;
+ return;
}
/*
@@ -5866,8 +5881,8 @@ TclArgumentBCEnter(
if (ePtr->line[word] >= 0) {
int isNew;
Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(iPtr->lineLABCPtr,
- objv[word], &isNew);
- CFWordBC *cfwPtr = (CFWordBC *)Tcl_Alloc(sizeof(CFWordBC));
+ objv[word], &isNew);
+ CFWordBC *cfwPtr = (CFWordBC *) Tcl_Alloc(sizeof(CFWordBC));
cfwPtr->framePtr = cfPtr;
cfwPtr->obj = objv[word];
@@ -5891,7 +5906,7 @@ TclArgumentBCEnter(
* information in the new structure.
*/
- cfwPtr->prevPtr = (CFWordBC *)Tcl_GetHashValue(hPtr);
+ cfwPtr->prevPtr = (CFWordBC *) Tcl_GetHashValue(hPtr);
}
Tcl_SetHashValue(hPtr, cfwPtr);
@@ -5933,7 +5948,7 @@ TclArgumentBCRelease(
CFWordBC *nextPtr = cfwPtr->nextPtr;
Tcl_HashEntry *hPtr =
Tcl_FindHashEntry(iPtr->lineLABCPtr, cfwPtr->obj);
- CFWordBC *xPtr = (CFWordBC *)Tcl_GetHashValue(hPtr);
+ CFWordBC *xPtr = (CFWordBC *) Tcl_GetHashValue(hPtr);
if (xPtr != cfwPtr) {
Tcl_Panic("TclArgumentBC Enter/Release Mismatch");
@@ -5999,7 +6014,7 @@ TclArgumentGet(
hPtr = Tcl_FindHashEntry(iPtr->lineLAPtr, obj);
if (hPtr) {
- CFWord *cfwPtr = (CFWord *)Tcl_GetHashValue(hPtr);
+ CFWord *cfwPtr = (CFWord *) Tcl_GetHashValue(hPtr);
*wordPtr = cfwPtr->word;
*cfPtrPtr = cfwPtr->framePtr;
@@ -6013,7 +6028,7 @@ TclArgumentGet(
hPtr = Tcl_FindHashEntry(iPtr->lineLABCPtr, obj);
if (hPtr) {
- CFWordBC *cfwPtr = (CFWordBC *)Tcl_GetHashValue(hPtr);
+ CFWordBC *cfwPtr = (CFWordBC *) Tcl_GetHashValue(hPtr);
framePtr = cfwPtr->framePtr;
framePtr->data.tebc.pc = (char *) (((ByteCode *)
@@ -6056,7 +6071,7 @@ int
Tcl_EvalObjEx(
Tcl_Interp *interp, /* Token for command interpreter (returned by
* a previous call to Tcl_CreateInterp). */
- Tcl_Obj *objPtr, /* Pointer to object containing commands to
+ Tcl_Obj *objPtr, /* Pointer to object containing commands to
* execute. */
int flags) /* Collection of OR-ed bits that control the
* evaluation of the script. Supported values
@@ -6069,7 +6084,7 @@ int
TclEvalObjEx(
Tcl_Interp *interp, /* Token for command interpreter (returned by
* a previous call to Tcl_CreateInterp). */
- Tcl_Obj *objPtr, /* Pointer to object containing commands to
+ Tcl_Obj *objPtr, /* Pointer to object containing commands to
* execute. */
int flags, /* Collection of OR-ed bits that control the
* evaluation of the script. Supported values
@@ -6088,7 +6103,7 @@ int
TclNREvalObjEx(
Tcl_Interp *interp, /* Token for command interpreter (returned by
* a previous call to Tcl_CreateInterp). */
- Tcl_Obj *objPtr, /* Pointer to object containing commands to
+ Tcl_Obj *objPtr, /* Pointer to object containing commands to
* execute. */
int flags, /* Collection of OR-ed bits that control the
* evaluation of the script. Supported values
@@ -6152,7 +6167,7 @@ TclNREvalObjEx(
* should be pushed, as needed by alias and ensemble redirections.
*/
- eoFramePtr = (CmdFrame *)TclStackAlloc(interp, sizeof(CmdFrame));
+ eoFramePtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame));
eoFramePtr->nline = 0;
eoFramePtr->line = NULL;
@@ -6173,7 +6188,7 @@ TclNREvalObjEx(
}
TclMarkTailcall(interp);
- TclNRAddCallback(interp, TEOEx_ListCallback, listPtr, eoFramePtr,
+ TclNRAddCallback(interp, TEOEx_ListCallback, listPtr, eoFramePtr,
objPtr, NULL);
TclListObjGetElements(NULL, listPtr, &objc, &objv);
@@ -6194,9 +6209,9 @@ TclNREvalObjEx(
* iPtr->varFramePtr in case
* TCL_EVAL_GLOBAL was set. */
- if (TclInterpReady(interp) != TCL_OK) {
- return TCL_ERROR;
- }
+ if (TclInterpReady(interp) != TCL_OK) {
+ return TCL_ERROR;
+ }
if (flags & TCL_EVAL_GLOBAL) {
savedVarFramePtr = iPtr->varFramePtr;
iPtr->varFramePtr = iPtr->rootFramePtr;
@@ -6206,7 +6221,7 @@ TclNREvalObjEx(
TclNRAddCallback(interp, TEOEx_ByteCodeCallback, savedVarFramePtr,
objPtr, INT2PTR(allowExceptions), NULL);
- return TclNRExecuteByteCode(interp, codePtr);
+ return TclNRExecuteByteCode(interp, codePtr);
}
{
@@ -6261,8 +6276,8 @@ TEOEx_ByteCodeCallback(
int result)
{
Interp *iPtr = (Interp *) interp;
- CallFrame *savedVarFramePtr = (CallFrame *)data[0];
- Tcl_Obj *objPtr = (Tcl_Obj *)data[1];
+ CallFrame *savedVarFramePtr = (CallFrame *) data[0];
+ Tcl_Obj *objPtr = (Tcl_Obj *) data[1];
int allowExceptions = PTR2INT(data[2]);
if (iPtr->numLevels == 0) {
@@ -6307,9 +6322,9 @@ TEOEx_ListCallback(
int result)
{
Interp *iPtr = (Interp *) interp;
- Tcl_Obj *listPtr = (Tcl_Obj *)data[0];
- CmdFrame *eoFramePtr = (CmdFrame *)data[1];
- Tcl_Obj *objPtr = (Tcl_Obj *)data[2];
+ Tcl_Obj *listPtr = (Tcl_Obj *) data[0];
+ CmdFrame *eoFramePtr = (CmdFrame *) data[1];
+ Tcl_Obj *objPtr = (Tcl_Obj *) data[2];
/*
* Remove the cmdFrame
@@ -6489,7 +6504,7 @@ int
Tcl_ExprLongObj(
Tcl_Interp *interp, /* Context in which to evaluate the
* expression. */
- Tcl_Obj *objPtr, /* Expression to evaluate. */
+ Tcl_Obj *objPtr, /* Expression to evaluate. */
long *ptr) /* Where to store long result. */
{
Tcl_Obj *resultPtr;
@@ -6502,7 +6517,7 @@ Tcl_ExprLongObj(
return TCL_ERROR;
}
- if (Tcl_GetNumberFromObj(interp, resultPtr, &internalPtr, &type)!=TCL_OK) {
+ if (Tcl_GetNumberFromObj(interp, resultPtr, &internalPtr, &type) != TCL_OK) {
return TCL_ERROR;
}
@@ -6536,7 +6551,7 @@ int
Tcl_ExprDoubleObj(
Tcl_Interp *interp, /* Context in which to evaluate the
* expression. */
- Tcl_Obj *objPtr, /* Expression to evaluate. */
+ Tcl_Obj *objPtr, /* Expression to evaluate. */
double *ptr) /* Where to store double result. */
{
Tcl_Obj *resultPtr;
@@ -6612,7 +6627,7 @@ int
TclObjInvokeNamespace(
Tcl_Interp *interp, /* Interpreter in which command is to be
* invoked. */
- Tcl_Size objc, /* Count of arguments. */
+ Tcl_Size objc, /* Count of arguments. */
Tcl_Obj *const objv[], /* Argument objects; objv[0] points to the
* name of the command to invoke. */
Tcl_Namespace *nsPtr, /* The namespace to use. */
@@ -6656,7 +6671,7 @@ int
TclObjInvoke(
Tcl_Interp *interp, /* Interpreter in which command is to be
* invoked. */
- Tcl_Size objc, /* Count of arguments. */
+ Tcl_Size objc, /* Count of arguments. */
Tcl_Obj *const objv[], /* Argument objects; objv[0] points to the
* name of the command to invoke. */
int flags) /* Combination of flags controlling the call:
@@ -6668,7 +6683,7 @@ TclObjInvoke(
}
if ((objc < 1) || (objv == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "illegal argument vector", -1));
+ "illegal argument vector", -1));
return TCL_ERROR;
}
if ((flags & TCL_INVOKE_HIDDEN) == 0) {
@@ -6697,12 +6712,12 @@ TclNRInvoke(
}
if (hPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "invalid hidden command name \"%s\"", cmdName));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "HIDDENTOKEN", cmdName,
- (char *)NULL);
+ "invalid hidden command name \"%s\"", cmdName));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "HIDDENTOKEN", cmdName,
+ (char *)NULL);
return TCL_ERROR;
}
- cmdPtr = (Command *)Tcl_GetHashValue(hPtr);
+ cmdPtr = (Command *) Tcl_GetHashValue(hPtr);
/*
* Avoid the exception-handling brain damage when numLevels == 0
@@ -6726,7 +6741,7 @@ NRPostInvoke(
Tcl_Interp *interp,
int result)
{
- Interp *iPtr = (Interp *)interp;
+ Interp *iPtr = (Interp *) interp;
iPtr->numLevels--;
return result;
@@ -7187,7 +7202,7 @@ ExprIsqrtFunc(
negarg:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "square root of negative argument", -1));
+ "square root of negative argument", -1));
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
"domain error: argument not in valid range", (char *)NULL);
return TCL_ERROR;
@@ -7247,7 +7262,7 @@ ExprSqrtFunc(
static int
ExprUnaryFunc(
- void *clientData, /* Contains the address of a function that
+ void *clientData, /* Contains the address of a function that
* takes one double argument and returns a
* double result. */
Tcl_Interp *interp, /* The interpreter in which to execute the
@@ -7257,7 +7272,7 @@ ExprUnaryFunc(
{
int code;
double d;
- double (*func)(double) = (double (*)(double)) clientData;
+ BuiltinUnaryFunc *func = (BuiltinUnaryFunc *) clientData;
if (objc != 2) {
MathFuncWrongNumArgs(interp, 2, objc, objv);
@@ -7311,7 +7326,7 @@ CheckDoubleResult(
static int
ExprBinaryFunc(
- void *clientData, /* Contains the address of a function that
+ void *clientData, /* Contains the address of a function that
* takes two double arguments and returns a
* double result. */
Tcl_Interp *interp, /* The interpreter in which to execute the
@@ -7321,7 +7336,7 @@ ExprBinaryFunc(
{
int code;
double d1, d2;
- double (*func)(double, double) = (double (*)(double, double)) clientData;
+ BuiltinBinaryFunc *func = (BuiltinBinaryFunc *) clientData;
if (objc != 3) {
MathFuncWrongNumArgs(interp, 3, objc, objv);
@@ -7397,13 +7412,14 @@ ExprAbsFunc(
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
return TCL_OK;
}
- bytes++; numBytes--;
+ bytes++;
+ numBytes--;
}
}
goto unChanged;
} else if (l == WIDE_MIN) {
if (sizeof(Tcl_WideInt) > sizeof(int64_t)) {
- Tcl_WideUInt ul = -(Tcl_WideUInt)WIDE_MIN;
+ Tcl_WideUInt ul = -(Tcl_WideUInt) WIDE_MIN;
if (mp_init(&big) != MP_OKAY || mp_unpack(&big, 1, 1,
sizeof(Tcl_WideInt), 0, 0, &ul) != MP_OKAY) {
return TCL_ERROR;
@@ -7539,7 +7555,7 @@ ExprIntFunc(
if (type == TCL_NUMBER_DOUBLE) {
d = *((const double *) ptr);
- if ((d >= (double)WIDE_MAX) || (d <= (double)WIDE_MIN)) {
+ if ((d >= (double) WIDE_MAX) || (d <= (double) WIDE_MIN)) {
mp_int big;
if (Tcl_InitBignumFromDouble(interp, d, &big) != TCL_OK) {
@@ -7615,20 +7631,20 @@ ExprMaxMinFunc(
}
res = objv[1];
for (i = 1; i < objc; i++) {
- if (Tcl_GetNumberFromObj(interp, objv[i], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
- }
- if (type == TCL_NUMBER_NAN) {
- /*
- * Get the error message for NaN.
- */
-
- Tcl_GetDoubleFromObj(interp, objv[i], &d);
- return TCL_ERROR;
- }
- if (TclCompareTwoNumbers(objv[i], res) == op) {
- res = objv[i];
- }
+ if (Tcl_GetNumberFromObj(interp, objv[i], &ptr, &type) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (type == TCL_NUMBER_NAN) {
+ /*
+ * Get the error message for NaN.
+ */
+
+ Tcl_GetDoubleFromObj(interp, objv[i], &d);
+ return TCL_ERROR;
+ }
+ if (TclCompareTwoNumbers(objv[i], res) == op) {
+ res = objv[i];
+ }
}
Tcl_SetObjResult(interp, res);
@@ -7684,7 +7700,7 @@ ExprRandFunc(
* take into consideration the thread this interp is running in.
*/
- iPtr->randSeed = TclpGetClicks() + PTR2UINT(Tcl_GetCurrentThread())*4093U;
+ iPtr->randSeed = TclpGetClicks() + PTR2UINT(Tcl_GetCurrentThread()) * 4093U;
/*
* Make sure 1 <= randSeed <= (2^31) - 2. See below.
@@ -7781,7 +7797,7 @@ ExprRoundFunc(
} else if (fractPart >= 0.5) {
max--;
}
- if ((intPart >= (double)max) || (intPart <= (double)min)) {
+ if ((intPart >= (double) max) || (intPart <= (double) min)) {
mp_int big;
mp_err err = MP_OKAY;
@@ -7800,7 +7816,7 @@ ExprRoundFunc(
Tcl_SetObjResult(interp, Tcl_NewBignumObj(&big));
return TCL_OK;
} else {
- Tcl_WideInt result = (Tcl_WideInt)intPart;
+ Tcl_WideInt result = (Tcl_WideInt) intPart;
if (fractPart <= -0.5) {
result--;
@@ -7881,8 +7897,8 @@ ExprSrandFunc(
* This page contains the functions that implement all of the built-in
* math functions for classifying IEEE doubles.
*
- * These have to be a little bit careful while Tcl_GetDoubleFromObj()
- * rejects NaN values, which these functions *explicitly* accept.
+ * These have to be a little bit careful while Tcl_GetDoubleFromObj()
+ * rejects NaN values, which these functions *explicitly* accept.
*
* Results:
* Each function returns TCL_OK if it succeeds and pushes an Tcl object
@@ -7916,16 +7932,16 @@ ClassifyDouble(
* Hence we define those here.
*/
#ifndef FP_NAN
-# define FP_NAN 1 /* Value is NaN */
-# define FP_INFINITE 2 /* Value is an infinity */
-# define FP_ZERO 3 /* Value is a zero */
-# define FP_NORMAL 4 /* Value is a normal float */
-# define FP_SUBNORMAL 5 /* Value has lost accuracy */
+# define FP_NAN 1 /* Value is NaN */
+# define FP_INFINITE 2 /* Value is an infinity */
+# define FP_ZERO 3 /* Value is a zero */
+# define FP_NORMAL 4 /* Value is a normal float */
+# define FP_SUBNORMAL 5 /* Value has lost accuracy */
#endif /* !FP_NAN */
#if TCL_FPCLASSIFY_MODE == 3
return __builtin_fpclassify(
- FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
+ FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
#elif TCL_FPCLASSIFY_MODE == 2
/*
* We assume this hack is only needed on little-endian systems.
@@ -7935,27 +7951,27 @@ ClassifyDouble(
*/
union {
- double d; /* Interpret as double */
- struct {
- unsigned int low; /* Lower 32 bits */
- unsigned int high; /* Upper 32 bits */
- } w; /* Interpret as unsigned integer words */
- } doubleMeaning; /* So we can look at the representation of a
- * double directly. Platform (i.e., processor)
- * specific; this is for x86 (and most other
- * little-endian processors, but those are
- * untested). */
+ double d; /* Interpret as double */
+ struct {
+ unsigned int low; /* Lower 32 bits */
+ unsigned int high; /* Upper 32 bits */
+ } w; /* Interpret as unsigned integer words */
+ } doubleMeaning; /* So we can look at the representation of a
+ * double directly. Platform (i.e., processor)
+ * specific; this is for x86 (and most other
+ * little-endian processors, but those are
+ * untested). */
unsigned int exponent, mantissaLow, mantissaHigh;
- /* The pieces extracted from the double. */
- int zeroMantissa; /* Was the mantissa zero? That's special. */
+ /* The pieces extracted from the double. */
+ int zeroMantissa; /* Was the mantissa zero? That's special. */
/*
* Shifts and masks to use with the doubleMeaning variable above.
*/
-#define EXPONENT_MASK 0x7FF /* 11 bits (after shifting) */
-#define EXPONENT_SHIFT 20 /* Moves exponent to bottom of word */
-#define MANTISSA_MASK 0xFFFFF /* 20 bits (plus 32 from other word) */
+#define EXPONENT_MASK 0x7FF /* 11 bits (after shifting) */
+#define EXPONENT_SHIFT 20 /* Moves exponent to bottom of word */
+#define MANTISSA_MASK 0xFFFFF /* 20 bits (plus 32 from other word) */
/*
* Extract the exponent (11 bits) and mantissa (52 bits). Note that we
@@ -7974,43 +7990,43 @@ ClassifyDouble(
switch (exponent) {
case 0:
- /*
- * When the exponent is all zeros, it's a ZERO or a SUBNORMAL.
- */
+ /*
+ * When the exponent is all zeros, it's a ZERO or a SUBNORMAL.
+ */
- return zeroMantissa ? FP_ZERO : FP_SUBNORMAL;
+ return zeroMantissa ? FP_ZERO : FP_SUBNORMAL;
case EXPONENT_MASK:
- /*
- * When the exponent is all ones, it's an INF or a NAN.
- */
+ /*
+ * When the exponent is all ones, it's an INF or a NAN.
+ */
- return zeroMantissa ? FP_INFINITE : FP_NAN;
+ return zeroMantissa ? FP_INFINITE : FP_NAN;
default:
- /*
- * Everything else is a NORMAL double precision float.
- */
+ /*
+ * Everything else is a NORMAL double precision float.
+ */
- return FP_NORMAL;
+ return FP_NORMAL;
}
#elif TCL_FPCLASSIFY_MODE == 1
switch (_fpclass(d)) {
case _FPCLASS_NZ:
case _FPCLASS_PZ:
- return FP_ZERO;
+ return FP_ZERO;
case _FPCLASS_NN:
case _FPCLASS_PN:
- return FP_NORMAL;
+ return FP_NORMAL;
case _FPCLASS_ND:
case _FPCLASS_PD:
- return FP_SUBNORMAL;
+ return FP_SUBNORMAL;
case _FPCLASS_NINF:
case _FPCLASS_PINF:
- return FP_INFINITE;
+ return FP_INFINITE;
default:
- Tcl_Panic("result of _fpclass() outside documented range!");
+ Tcl_Panic("result of _fpclass() outside documented range!");
case _FPCLASS_QNAN:
case _FPCLASS_SNAN:
- return FP_NAN;
+ return FP_NAN;
}
#else /* TCL_FPCLASSIFY_MODE not in (0..3) */
#error "unknown or unexpected TCL_FPCLASSIFY_MODE"
@@ -8036,14 +8052,14 @@ ExprIsFiniteFunc(
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type != TCL_NUMBER_NAN) {
- if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
- return TCL_ERROR;
- }
- type = ClassifyDouble(d);
- result = (type != FP_INFINITE && type != FP_NAN);
+ if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ type = ClassifyDouble(d);
+ result = (type != FP_INFINITE && type != FP_NAN);
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
@@ -8067,13 +8083,13 @@ ExprIsInfinityFunc(
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type != TCL_NUMBER_NAN) {
- if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
- return TCL_ERROR;
- }
- result = (ClassifyDouble(d) == FP_INFINITE);
+ if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ result = (ClassifyDouble(d) == FP_INFINITE);
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
@@ -8097,13 +8113,13 @@ ExprIsNaNFunc(
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type != TCL_NUMBER_NAN) {
- if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
- return TCL_ERROR;
- }
- result = (ClassifyDouble(d) == FP_NAN);
+ if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ result = (ClassifyDouble(d) == FP_NAN);
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
@@ -8127,13 +8143,13 @@ ExprIsNormalFunc(
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type != TCL_NUMBER_NAN) {
- if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
- return TCL_ERROR;
- }
- result = (ClassifyDouble(d) == FP_NORMAL);
+ if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ result = (ClassifyDouble(d) == FP_NORMAL);
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
@@ -8157,13 +8173,13 @@ ExprIsSubnormalFunc(
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type != TCL_NUMBER_NAN) {
- if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
- return TCL_ERROR;
- }
- result = (ClassifyDouble(d) == FP_SUBNORMAL);
+ if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ result = (ClassifyDouble(d) == FP_SUBNORMAL);
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
@@ -8187,23 +8203,23 @@ ExprIsUnorderedFunc(
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type == TCL_NUMBER_NAN) {
- result = 1;
+ result = 1;
} else {
- d = *((const double *) ptr);
- result = (ClassifyDouble(d) == FP_NAN);
+ d = *((const double *) ptr);
+ result = (ClassifyDouble(d) == FP_NAN);
}
if (Tcl_GetNumberFromObj(interp, objv[2], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type == TCL_NUMBER_NAN) {
- result |= 1;
+ result |= 1;
} else {
- d = *((const double *) ptr);
- result |= (ClassifyDouble(d) == FP_NAN);
+ d = *((const double *) ptr);
+ result |= (ClassifyDouble(d) == FP_NAN);
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
@@ -8224,39 +8240,39 @@ FloatClassifyObjCmd(
int type;
if (objc != 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "floatValue");
+ Tcl_WrongNumArgs(interp, 1, objv, "floatValue");
return TCL_ERROR;
}
if (Tcl_GetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (type == TCL_NUMBER_NAN) {
- goto gotNaN;
+ goto gotNaN;
} else if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
switch (ClassifyDouble(d)) {
case FP_INFINITE:
- TclNewLiteralStringObj(objPtr, "infinite");
- break;
+ TclNewLiteralStringObj(objPtr, "infinite");
+ break;
case FP_NAN:
gotNaN:
- TclNewLiteralStringObj(objPtr, "nan");
- break;
+ TclNewLiteralStringObj(objPtr, "nan");
+ break;
case FP_NORMAL:
- TclNewLiteralStringObj(objPtr, "normal");
- break;
+ TclNewLiteralStringObj(objPtr, "normal");
+ break;
case FP_SUBNORMAL:
- TclNewLiteralStringObj(objPtr, "subnormal");
- break;
+ TclNewLiteralStringObj(objPtr, "subnormal");
+ break;
case FP_ZERO:
- TclNewLiteralStringObj(objPtr, "zero");
- break;
+ TclNewLiteralStringObj(objPtr, "zero");
+ break;
default:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "unable to classify number: %f", d));
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "unable to classify number: %f", d));
+ return TCL_ERROR;
}
Tcl_SetObjResult(interp, objPtr);
return TCL_OK;
@@ -8289,10 +8305,10 @@ MathFuncWrongNumArgs(
const char *name = TclGetString(objv[0]);
const char *tail = name + strlen(name);
- while (tail > name+1) {
+ while (tail > name + 1) {
tail--;
if (*tail == ':' && tail[-1] == ':') {
- name = tail+1;
+ name = tail + 1;
break;
}
}
@@ -8487,14 +8503,14 @@ wrapperNRObjProc(
int objc,
Tcl_Obj *const objv[])
{
- CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
+ CmdWrapperInfo *info = (CmdWrapperInfo *) clientData;
clientData = info->clientData;
Tcl_ObjCmdProc2 *proc = info->proc;
Tcl_Free(info);
if (objc < 0) {
objc = -1;
}
- return proc(clientData, interp, (Tcl_Size)objc, objv);
+ return proc(clientData, interp, (Tcl_Size) objc, objv);
}
int
@@ -8511,7 +8527,8 @@ Tcl_NRCallObjProc2(
}
NRE_callback *rootPtr = TOP_CB(interp);
- CmdWrapperInfo *info = (CmdWrapperInfo *)Tcl_Alloc(sizeof(CmdWrapperInfo));
+ CmdWrapperInfo *info = (CmdWrapperInfo *)
+ Tcl_Alloc(sizeof(CmdWrapperInfo));
info->clientData = clientData;
info->proc = objProc;
@@ -8555,7 +8572,8 @@ cmdWrapperNreProc(
int objc,
Tcl_Obj *const objv[])
{
- CmdWrapperInfo *info = (CmdWrapperInfo *)clientData;
+ CmdWrapperInfo *info = (CmdWrapperInfo *) clientData;
+
if (objc < 0) {
objc = -1;
}
@@ -8575,13 +8593,15 @@ Tcl_NRCreateCommand2(
* calls. */
Tcl_ObjCmdProc2 *nreProc, /* Object-based function to associate with
* name, provides NR implementation */
- void *clientData, /* Arbitrary value to pass to object
+ void *clientData, /* Arbitrary value to pass to object
* function. */
Tcl_CmdDeleteProc *deleteProc)
/* If not NULL, gives a function to call when
* this command is deleted. */
{
- CmdWrapperInfo *info = (CmdWrapperInfo *)Tcl_Alloc(sizeof(CmdWrapperInfo));
+ CmdWrapperInfo *info = (CmdWrapperInfo *)
+ Tcl_Alloc(sizeof(CmdWrapperInfo));
+
info->proc = proc;
info->clientData = clientData;
info->nreProc = nreProc;
@@ -8606,7 +8626,7 @@ Tcl_NRCreateCommand(
* calls. */
Tcl_ObjCmdProc *nreProc, /* Object-based function to associate with
* name, provides NR implementation */
- void *clientData, /* Arbitrary value to pass to object
+ void *clientData, /* Arbitrary value to pass to object
* function. */
Tcl_CmdDeleteProc *deleteProc)
/* If not NULL, gives a function to call when
@@ -8614,7 +8634,7 @@ Tcl_NRCreateCommand(
{
Command *cmdPtr = (Command *)
Tcl_CreateObjCommand(interp, cmdName, proc, clientData,
- deleteProc);
+ deleteProc);
cmdPtr->nreProc = nreProc;
return (Tcl_Command) cmdPtr;
@@ -8631,8 +8651,8 @@ TclNRCreateCommandInNs(
Tcl_CmdDeleteProc *deleteProc)
{
Command *cmdPtr = (Command *)
- TclCreateObjCommandInNs(interp, cmdName, nsPtr, proc, clientData,
- deleteProc);
+ TclCreateObjCommandInNs(interp, cmdName, nsPtr, proc, clientData,
+ deleteProc);
cmdPtr->nreProc = nreProc;
return (Tcl_Command) cmdPtr;
@@ -8655,7 +8675,7 @@ int
Tcl_NREvalObjv(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* command. Also used for error reporting. */
- Tcl_Size objc, /* Number of words in command. */
+ Tcl_Size objc, /* Number of words in command. */
Tcl_Obj *const objv[], /* An array of pointers to objects that are
* the words that make up the command. */
int flags) /* Collection of OR-ed bits that control the
@@ -8714,8 +8734,8 @@ TclMarkTailcall(
if (iPtr->deferredCallbacks == NULL) {
TclNRAddCallback(interp, NRCommand, NULL, NULL,
- NULL, NULL);
- iPtr->deferredCallbacks = TOP_CB(interp);
+ NULL, NULL);
+ iPtr->deferredCallbacks = TOP_CB(interp);
}
}
@@ -8762,12 +8782,12 @@ TclSetTailcall(
NRE_callback *runPtr;
for (runPtr = TOP_CB(interp); runPtr; runPtr = runPtr->nextPtr) {
- if (((runPtr->procPtr) == NRCommand) && !runPtr->data[1]) {
- break;
- }
+ if (((runPtr->procPtr) == NRCommand) && !runPtr->data[1]) {
+ break;
+ }
}
if (!runPtr) {
- Tcl_Panic("tailcall cannot find the right splicing spot: should not happen!");
+ Tcl_Panic("tailcall cannot find the right splicing spot: should not happen!");
}
runPtr->data[1] = listPtr;
}
@@ -8803,9 +8823,9 @@ TclNRTailcallObjCmd(
}
if (!(iPtr->varFramePtr->isProcCallFrame & 1)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "tailcall can only be called from a proc, lambda or method", -1));
- Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (char *)NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "tailcall can only be called from a proc, lambda or method", -1));
+ Tcl_SetErrorCode(interp, "TCL", "TAILCALL", "ILLEGAL", (char *)NULL);
return TCL_ERROR;
}
@@ -8815,8 +8835,8 @@ TclNRTailcallObjCmd(
*/
if (iPtr->varFramePtr->tailcallPtr) {
- Tcl_DecrRefCount(iPtr->varFramePtr->tailcallPtr);
- iPtr->varFramePtr->tailcallPtr = NULL;
+ Tcl_DecrRefCount(iPtr->varFramePtr->tailcallPtr);
+ iPtr->varFramePtr->tailcallPtr = NULL;
}
/*
@@ -8826,19 +8846,19 @@ TclNRTailcallObjCmd(
*/
if (objc > 1) {
- Tcl_Obj *listPtr, *nsObjPtr;
- Tcl_Namespace *nsPtr = (Tcl_Namespace *) iPtr->varFramePtr->nsPtr;
+ Tcl_Obj *listPtr, *nsObjPtr;
+ Tcl_Namespace *nsPtr = (Tcl_Namespace *) iPtr->varFramePtr->nsPtr;
- /*
- * The tailcall data is in a Tcl list: the first element is the
- * namespace, the rest the command to be tailcalled.
- */
+ /*
+ * The tailcall data is in a Tcl list: the first element is the
+ * namespace, the rest the command to be tailcalled.
+ */
- nsObjPtr = Tcl_NewStringObj(nsPtr->fullName, -1);
- listPtr = Tcl_NewListObj(objc, objv);
+ nsObjPtr = Tcl_NewStringObj(nsPtr->fullName, -1);
+ listPtr = Tcl_NewListObj(objc, objv);
TclListObjSetElement(interp, listPtr, 0, nsObjPtr);
- iPtr->varFramePtr->tailcallPtr = listPtr;
+ iPtr->varFramePtr->tailcallPtr = listPtr;
}
return TCL_RETURN;
}
@@ -8860,7 +8880,7 @@ TclNRTailcallEval(
int result)
{
Interp *iPtr = (Interp *) interp;
- Tcl_Obj *listPtr = (Tcl_Obj *)data[0], *nsObjPtr;
+ Tcl_Obj *listPtr = (Tcl_Obj *) data[0], *nsObjPtr;
Tcl_Namespace *nsPtr;
Tcl_Size objc;
Tcl_Obj **objv;
@@ -8873,13 +8893,13 @@ TclNRTailcallEval(
}
if (result != TCL_OK) {
- /*
- * Tailcall execution was preempted, eg by an intervening catch or by
- * a now-gone namespace: cleanup and return.
- */
+ /*
+ * Tailcall execution was preempted, eg by an intervening catch or by
+ * a now-gone namespace: cleanup and return.
+ */
Tcl_DecrRefCount(listPtr);
- return result;
+ return result;
}
/*
@@ -8889,7 +8909,7 @@ TclNRTailcallEval(
TclMarkTailcall(interp);
TclNRAddCallback(interp, TclNRReleaseValues, listPtr, NULL, NULL,NULL);
iPtr->lookupNsPtr = (Namespace *) nsPtr;
- return TclNREvalObjv(interp, objc-1, objv+1, 0, NULL);
+ return TclNREvalObjv(interp, objc - 1, objv + 1, 0, NULL);
}
int
@@ -8966,7 +8986,7 @@ TclNRYieldObjCmd(
if (!corPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "yield can only be called in a coroutine", -1));
+ "yield can only be called in a coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", (char *)NULL);
return TCL_ERROR;
}
@@ -8977,7 +8997,7 @@ TclNRYieldObjCmd(
NRE_ASSERT(!COR_IS_SUSPENDED(corPtr));
TclNRAddCallback(interp, TclNRCoroutineActivateCallback, corPtr,
- clientData, NULL, NULL);
+ clientData, NULL, NULL);
return TCL_OK;
}
@@ -8999,17 +9019,17 @@ TclNRYieldToObjCmd(
if (!corPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "yieldto can only be called in a coroutine", -1));
+ "yieldto can only be called in a coroutine", -1));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", (char *)NULL);
return TCL_ERROR;
}
if (((Namespace *) nsPtr)->flags & NS_DYING) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"yieldto called in deleted namespace", -1));
- Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
+ Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "YIELDTO_IN_DELETED",
(char *)NULL);
- return TCL_ERROR;
+ return TCL_ERROR;
}
/*
@@ -9041,7 +9061,7 @@ RewindCoroutineCallback(
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
- return Tcl_RestoreInterpState(interp, (Tcl_InterpState)data[0]);
+ return Tcl_RestoreInterpState(interp, (Tcl_InterpState) data[0]);
}
static int
@@ -9066,7 +9086,7 @@ static void
DeleteCoroutine(
void *clientData)
{
- CoroutineData *corPtr = (CoroutineData *)clientData;
+ CoroutineData *corPtr = (CoroutineData *) clientData;
Tcl_Interp *interp = corPtr->eePtr->interp;
NRE_callback *rootPtr = TOP_CB(interp);
@@ -9081,7 +9101,7 @@ NRCoroutineCallerCallback(
Tcl_Interp *interp,
int result)
{
- CoroutineData *corPtr = (CoroutineData *)data[0];
+ CoroutineData *corPtr = (CoroutineData *) data[0];
Command *cmdPtr = corPtr->cmdPtr;
/*
@@ -9127,7 +9147,7 @@ NRCoroutineExitCallback(
Tcl_Interp *interp,
int result)
{
- CoroutineData *corPtr = (CoroutineData *)data[0];
+ CoroutineData *corPtr = (CoroutineData *) data[0];
Command *cmdPtr = corPtr->cmdPtr;
/*
@@ -9174,14 +9194,14 @@ NRCoroutineExitCallback(
*
* TclNRCoroutineActivateCallback --
*
- * This is the workhorse for coroutines: it implements both yield and
- * resume.
+ * This is the workhorse for coroutines: it implements both yield and
+ * resume.
*
- * It is important that both be implemented in the same callback: the
- * detection of the impossibility to suspend due to a busy C-stack relies
- * on the precise position of a local variable in the stack. We do not
- * want the compiler to play tricks on us, either by moving things around
- * or inlining.
+ * It is important that both be implemented in the same callback: the
+ * detection of the impossibility to suspend due to a busy C-stack relies
+ * on the precise position of a local variable in the stack. We do not
+ * want the compiler to play tricks on us, either by moving things around
+ * or inlining.
*
*----------------------------------------------------------------------
*/
@@ -9192,46 +9212,46 @@ TclNRCoroutineActivateCallback(
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
- CoroutineData *corPtr = (CoroutineData *)data[0];
+ CoroutineData *corPtr = (CoroutineData *) data[0];
void *stackLevel = TclGetCStackPtr();
if (!corPtr->stackLevel) {
- /*
- * -- Coroutine is suspended --
- * Push the callback to restore the caller's context on yield or
- * return.
- */
-
- TclNRAddCallback(interp, NRCoroutineCallerCallback, corPtr,
- NULL, NULL, NULL);
-
- /*
- * Record the stackLevel at which the resume is happening, then swap
- * the interp's environment to make it suitable to run this coroutine.
- */
-
- corPtr->stackLevel = stackLevel;
- Tcl_Size numLevels = corPtr->auxNumLevels;
- corPtr->auxNumLevels = iPtr->numLevels;
-
- SAVE_CONTEXT(corPtr->caller);
- corPtr->callerEEPtr = iPtr->execEnvPtr;
- RESTORE_CONTEXT(corPtr->running);
- iPtr->execEnvPtr = corPtr->eePtr;
- iPtr->numLevels += numLevels;
+ /*
+ * -- Coroutine is suspended --
+ * Push the callback to restore the caller's context on yield or
+ * return.
+ */
+
+ TclNRAddCallback(interp, NRCoroutineCallerCallback, corPtr,
+ NULL, NULL, NULL);
+
+ /*
+ * Record the stackLevel at which the resume is happening, then swap
+ * the interp's environment to make it suitable to run this coroutine.
+ */
+
+ corPtr->stackLevel = stackLevel;
+ Tcl_Size numLevels = corPtr->auxNumLevels;
+ corPtr->auxNumLevels = iPtr->numLevels;
+
+ SAVE_CONTEXT(corPtr->caller);
+ corPtr->callerEEPtr = iPtr->execEnvPtr;
+ RESTORE_CONTEXT(corPtr->running);
+ iPtr->execEnvPtr = corPtr->eePtr;
+ iPtr->numLevels += numLevels;
} else {
- /*
- * Coroutine is active: yield
- */
+ /*
+ * Coroutine is active: yield
+ */
- if (corPtr->stackLevel != stackLevel) {
+ if (corPtr->stackLevel != stackLevel) {
NRE_callback *runPtr;
iPtr->execEnvPtr = corPtr->callerEEPtr;
if (corPtr->yieldPtr) {
for (runPtr = TOP_CB(interp); runPtr; runPtr = runPtr->nextPtr) {
if (runPtr->data[1] == corPtr->yieldPtr) {
- Tcl_DecrRefCount((Tcl_Obj *)runPtr->data[1]);
+ Tcl_DecrRefCount((Tcl_Obj *) runPtr->data[1]);
runPtr->data[1] = NULL;
corPtr->yieldPtr = NULL;
break;
@@ -9240,31 +9260,30 @@ TclNRCoroutineActivateCallback(
}
iPtr->execEnvPtr = corPtr->eePtr;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "cannot yield: C stack busy", -1));
+ Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "CANT_YIELD",
+ (char *)NULL);
+ return TCL_ERROR;
+ }
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "cannot yield: C stack busy", -1));
- Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "CANT_YIELD",
- (char *)NULL);
- return TCL_ERROR;
- }
-
- void *type = data[1];
- if (type == CORO_ACTIVATE_YIELD) {
- corPtr->nargs = COROUTINE_ARGUMENTS_SINGLE_OPTIONAL;
- } else if (type == CORO_ACTIVATE_YIELDM) {
- corPtr->nargs = COROUTINE_ARGUMENTS_ARBITRARY;
- } else {
- Tcl_Panic("Yield received an option which is not implemented");
- }
+ void *type = data[1];
+ if (type == CORO_ACTIVATE_YIELD) {
+ corPtr->nargs = COROUTINE_ARGUMENTS_SINGLE_OPTIONAL;
+ } else if (type == CORO_ACTIVATE_YIELDM) {
+ corPtr->nargs = COROUTINE_ARGUMENTS_ARBITRARY;
+ } else {
+ Tcl_Panic("Yield received an option which is not implemented");
+ }
corPtr->yieldPtr = NULL;
- corPtr->stackLevel = NULL;
+ corPtr->stackLevel = NULL;
- Tcl_Size numLevels = iPtr->numLevels;
- iPtr->numLevels = corPtr->auxNumLevels;
- corPtr->auxNumLevels = numLevels - corPtr->auxNumLevels;
+ Tcl_Size numLevels = iPtr->numLevels;
+ iPtr->numLevels = corPtr->auxNumLevels;
+ corPtr->auxNumLevels = numLevels - corPtr->auxNumLevels;
- iPtr->execEnvPtr = corPtr->callerEEPtr;
+ iPtr->execEnvPtr = corPtr->callerEEPtr;
}
return TCL_OK;
@@ -9275,7 +9294,7 @@ TclNRCoroutineActivateCallback(
*
* TclNREvalList --
*
- * Callback to invoke command as list, used in order to delayed
+ * Callback to invoke command as list, used in order to delayed
* processing of canonical list command in sane environment.
*
*----------------------------------------------------------------------
@@ -9289,7 +9308,7 @@ TclNREvalList(
{
Tcl_Size objc;
Tcl_Obj **objv;
- Tcl_Obj *listPtr = (Tcl_Obj *)data[0];
+ Tcl_Obj *listPtr = (Tcl_Obj *) data[0];
Tcl_IncrRefCount(listPtr);
@@ -9304,7 +9323,7 @@ TclNREvalList(
*
* CoroTypeObjCmd --
*
- * Implementation of [::tcl::unsupported::corotype] command.
+ * Implementation of [::tcl::unsupported::corotype] command.
*
*----------------------------------------------------------------------
*/
@@ -9330,11 +9349,11 @@ CoroTypeObjCmd(
cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objv[1]);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can only get coroutine type of a coroutine", -1));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
- TclGetString(objv[1]), (char *)NULL);
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can only get coroutine type of a coroutine", -1));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
+ TclGetString(objv[1]), (char *)NULL);
+ return TCL_ERROR;
}
/*
@@ -9342,10 +9361,10 @@ CoroTypeObjCmd(
* future.
*/
- corPtr = (CoroutineData *)cmdPtr->objClientData;
+ corPtr = (CoroutineData *) cmdPtr->objClientData;
if (!COR_IS_SUSPENDED(corPtr)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("active", -1));
- return TCL_OK;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("active", -1));
+ return TCL_OK;
}
/*
@@ -9355,16 +9374,16 @@ CoroTypeObjCmd(
switch (corPtr->nargs) {
case COROUTINE_ARGUMENTS_SINGLE_OPTIONAL:
- Tcl_SetObjResult(interp, Tcl_NewStringObj("yield", -1));
- return TCL_OK;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("yield", -1));
+ return TCL_OK;
case COROUTINE_ARGUMENTS_ARBITRARY:
- Tcl_SetObjResult(interp, Tcl_NewStringObj("yieldto", -1));
- return TCL_OK;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("yieldto", -1));
+ return TCL_OK;
default:
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unknown coroutine type", -1));
- Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BAD_TYPE", (char *)NULL);
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "unknown coroutine type", -1));
+ Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BAD_TYPE", (char *)NULL);
+ return TCL_ERROR;
}
}
@@ -9373,7 +9392,7 @@ CoroTypeObjCmd(
*
* TclNRCoroInjectObjCmd, TclNRCoroProbeObjCmd --
*
- * Implementation of [coroinject] and [coroprobe] commands.
+ * Implementation of [coroinject] and [coroprobe] commands.
*
*----------------------------------------------------------------------
*/
@@ -9391,12 +9410,12 @@ GetCoroutineFromObj(
Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, objPtr);
if ((!cmdPtr) || (cmdPtr->nreProc != TclNRInterpCoroutine)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(errMsg, -1));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
- TclGetString(objPtr), (char *)NULL);
- return NULL;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(errMsg, -1));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "COROUTINE",
+ TclGetString(objPtr), (char *) NULL);
+ return NULL;
}
- return (CoroutineData *)cmdPtr->objClientData;
+ return (CoroutineData *) cmdPtr->objClientData;
}
static int
@@ -9419,15 +9438,15 @@ TclNRCoroInjectObjCmd(
}
corPtr = GetCoroutineFromObj(interp, objv[1],
- "can only inject a command into a coroutine");
+ "can only inject a command into a coroutine");
if (!corPtr) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can only inject a command into a suspended coroutine", -1));
- Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can only inject a command into a suspended coroutine", -1));
+ Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
+ return TCL_ERROR;
}
/*
@@ -9438,7 +9457,7 @@ TclNRCoroInjectObjCmd(
ExecEnv *savedEEPtr = iPtr->execEnvPtr;
iPtr->execEnvPtr = corPtr->eePtr;
TclNRAddCallback(interp, InjectHandler, corPtr,
- Tcl_NewListObj(objc - 2, objv + 2), INT2PTR(corPtr->nargs), NULL);
+ Tcl_NewListObj(objc - 2, objv + 2), INT2PTR(corPtr->nargs), NULL);
iPtr->execEnvPtr = savedEEPtr;
return TCL_OK;
@@ -9464,16 +9483,16 @@ TclNRCoroProbeObjCmd(
}
corPtr = GetCoroutineFromObj(interp, objv[1],
- "can only inject a probe command into a coroutine");
+ "can only inject a probe command into a coroutine");
if (!corPtr) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can only inject a probe command into a suspended coroutine",
- -1));
- Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can only inject a probe command into a suspended coroutine",
+ -1));
+ Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
+ return TCL_ERROR;
}
/*
@@ -9484,7 +9503,7 @@ TclNRCoroProbeObjCmd(
ExecEnv *savedEEPtr = iPtr->execEnvPtr;
iPtr->execEnvPtr = corPtr->eePtr;
TclNRAddCallback(interp, InjectHandler, corPtr,
- Tcl_NewListObj(objc - 2, objv + 2), INT2PTR(corPtr->nargs), corPtr);
+ Tcl_NewListObj(objc - 2, objv + 2), INT2PTR(corPtr->nargs), corPtr);
iPtr->execEnvPtr = savedEEPtr;
/*
@@ -9495,7 +9514,7 @@ TclNRCoroProbeObjCmd(
*/
TclNRAddCallback(interp, NRCoroutineCallerCallback, corPtr,
- NULL, NULL, NULL);
+ NULL, NULL, NULL);
/*
* Record the stackLevel at which the resume is happening, then swap
@@ -9523,18 +9542,18 @@ TclNRCoroProbeObjCmd(
*
* InjectHandler, InjectHandlerPostProc --
*
- * Part of the implementation of [coroinject] and [coroprobe]. These are
- * run inside the context of the coroutine being injected/probed into.
+ * Part of the implementation of [coroinject] and [coroprobe]. These are
+ * run inside the context of the coroutine being injected/probed into.
*
- * InjectHandler runs a script (possibly adding arguments) in the context
- * of the coroutine. The script is specified as a one-shot list (with
- * reference count equal to 1) in data[1]. This function also arranges
- * for InjectHandlerPostProc to be the part that runs after the script
- * completes.
+ * InjectHandler runs a script (possibly adding arguments) in the context
+ * of the coroutine. The script is specified as a one-shot list (with
+ * reference count equal to 1) in data[1]. This function also arranges
+ * for InjectHandlerPostProc to be the part that runs after the script
+ * completes.
*
- * InjectHandlerPostProc cleans up after InjectHandler (deleting the
- * list) and, for the [coroprobe] command *only*, yields back to the
- * caller context (i.e., where [coroprobe] was run).
+ * InjectHandlerPostProc cleans up after InjectHandler (deleting the
+ * list) and, for the [coroprobe] command *only*, yields back to the
+ * caller context (i.e., where [coroprobe] was run).
*s
*----------------------------------------------------------------------
*/
@@ -9545,8 +9564,8 @@ InjectHandler(
Tcl_Interp *interp,
TCL_UNUSED(int) /*result*/)
{
- CoroutineData *corPtr = (CoroutineData *)data[0];
- Tcl_Obj *listPtr = (Tcl_Obj *)data[1];
+ CoroutineData *corPtr = (CoroutineData *) data[0];
+ Tcl_Obj *listPtr = (Tcl_Obj *) data[1];
Tcl_Size nargs = PTR2INT(data[2]);
void *isProbe = data[3];
Tcl_Size objc;
@@ -9581,7 +9600,7 @@ InjectHandler(
Tcl_IncrRefCount(listPtr);
TclMarkTailcall(interp);
TclNRAddCallback(interp, InjectHandlerPostCall, corPtr, listPtr,
- INT2PTR(nargs), isProbe);
+ INT2PTR(nargs), isProbe);
TclListObjGetElements(NULL, listPtr, &objc, &objv);
return TclNREvalObjv(interp, objc, objv, 0, NULL);
}
@@ -9592,8 +9611,8 @@ InjectHandlerPostCall(
Tcl_Interp *interp,
int result)
{
- CoroutineData *corPtr = (CoroutineData *)data[0];
- Tcl_Obj *listPtr = (Tcl_Obj *)data[1];
+ CoroutineData *corPtr = (CoroutineData *) data[0];
+ Tcl_Obj *listPtr = (Tcl_Obj *) data[1];
Tcl_Size nargs = PTR2INT(data[2]);
void *isProbe = data[3];
@@ -9611,16 +9630,16 @@ InjectHandlerPostCall(
*/
if (isProbe) {
- if (result == TCL_ERROR) {
- Tcl_AddErrorInfo(interp,
- "\n (injected coroutine probe command)");
- }
- corPtr->nargs = nargs;
- corPtr->stackLevel = NULL;
- Tcl_Size numLevels = iPtr->numLevels;
- iPtr->numLevels = corPtr->auxNumLevels;
- corPtr->auxNumLevels = numLevels - corPtr->auxNumLevels;
- iPtr->execEnvPtr = corPtr->callerEEPtr;
+ if (result == TCL_ERROR) {
+ Tcl_AddErrorInfo(interp,
+ "\n (injected coroutine probe command)");
+ }
+ corPtr->nargs = nargs;
+ corPtr->stackLevel = NULL;
+ Tcl_Size numLevels = iPtr->numLevels;
+ iPtr->numLevels = corPtr->auxNumLevels;
+ corPtr->auxNumLevels = numLevels - corPtr->auxNumLevels;
+ iPtr->execEnvPtr = corPtr->callerEEPtr;
}
return result;
}
@@ -9630,7 +9649,7 @@ InjectHandlerPostCall(
*
* NRInjectObjCmd --
*
- * Implementation of [::tcl::unsupported::inject] command.
+ * Implementation of [::tcl::unsupported::inject] command.
*
*----------------------------------------------------------------------
*/
@@ -9656,15 +9675,15 @@ NRInjectObjCmd(
}
corPtr = GetCoroutineFromObj(interp, objv[1],
- "can only inject a command into a coroutine");
+ "can only inject a command into a coroutine");
if (!corPtr) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (!COR_IS_SUSPENDED(corPtr)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can only inject a command into a suspended coroutine", -1));
- Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can only inject a command into a suspended coroutine", -1));
+ Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL);
+ return TCL_ERROR;
}
/*
@@ -9673,8 +9692,8 @@ NRInjectObjCmd(
*/
iPtr->execEnvPtr = corPtr->eePtr;
- TclNRAddCallback(interp, TclNREvalList, Tcl_NewListObj(objc-2, objv+2),
- NULL, NULL, NULL);
+ TclNRAddCallback(interp, TclNREvalList, Tcl_NewListObj(objc - 2, objv + 2),
+ NULL, NULL, NULL);
iPtr->execEnvPtr = savedEEPtr;
return TCL_OK;
@@ -9687,12 +9706,12 @@ TclNRInterpCoroutine(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- CoroutineData *corPtr = (CoroutineData *)clientData;
+ CoroutineData *corPtr = (CoroutineData *) clientData;
if (!COR_IS_SUSPENDED(corPtr)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "coroutine \"%s\" is already running",
- TclGetString(objv[0])));
+ "coroutine \"%s\" is already running",
+ TclGetString(objv[0])));
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "BUSY", (char *)NULL);
return TCL_ERROR;
}
@@ -9705,31 +9724,31 @@ TclNRInterpCoroutine(
switch (corPtr->nargs) {
case COROUTINE_ARGUMENTS_SINGLE_OPTIONAL:
- if (objc == 2) {
- Tcl_SetObjResult(interp, objv[1]);
- } else if (objc > 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "?arg?");
- return TCL_ERROR;
- }
- break;
+ if (objc == 2) {
+ Tcl_SetObjResult(interp, objv[1]);
+ } else if (objc > 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "?arg?");
+ return TCL_ERROR;
+ }
+ break;
default:
- if (corPtr->nargs + 1 != objc) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("wrong coro nargs; how did we get here? "
- "not implemented!", -1));
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
- return TCL_ERROR;
- }
- /* fallthrough */
+ if (corPtr->nargs + 1 != objc) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("wrong coro nargs; how did we get here? "
+ "not implemented!", -1));
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
+ return TCL_ERROR;
+ }
+ /* fallthrough */
case COROUTINE_ARGUMENTS_ARBITRARY:
- if (objc > 1) {
- Tcl_SetObjResult(interp, Tcl_NewListObj(objc-1, objv+1));
- }
- break;
+ if (objc > 1) {
+ Tcl_SetObjResult(interp, Tcl_NewListObj(objc - 1, objv + 1));
+ }
+ break;
}
TclNRAddCallback(interp, TclNRCoroutineActivateCallback, corPtr,
- NULL, NULL, NULL);
+ NULL, NULL, NULL);
return TCL_OK;
}
@@ -9738,8 +9757,8 @@ TclNRInterpCoroutine(
*
* TclNRCoroutineObjCmd --
*
- * Implementation of [coroutine] command; see documentation for
- * description of what this does.
+ * Implementation of [coroutine] command; see documentation for
+ * description of what this does.
*
*----------------------------------------------------------------------
*/
@@ -9755,7 +9774,7 @@ TclNRCoroutineObjCmd(
CoroutineData *corPtr;
const char *procName, *simpleName;
Namespace *nsPtr, *altNsPtr, *cxtNsPtr,
- *inNsPtr = (Namespace *)TclGetCurrentNamespace(interp);
+ *inNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
Namespace *lookupNsPtr = iPtr->varFramePtr->nsPtr;
if (objc < 3) {
@@ -9769,16 +9788,16 @@ TclNRCoroutineObjCmd(
if (nsPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't create procedure \"%s\": unknown namespace",
- procName));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "NAMESPACE", (char *)NULL);
+ "can't create procedure \"%s\": unknown namespace",
+ procName));
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "NAMESPACE", (char *)NULL);
return TCL_ERROR;
}
if (simpleName == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't create procedure \"%s\": bad procedure name",
- procName));
- Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMMAND", procName, (char *)NULL);
+ "can't create procedure \"%s\": bad procedure name",
+ procName));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMMAND", procName, (char *)NULL);
return TCL_ERROR;
}
@@ -9787,10 +9806,10 @@ TclNRCoroutineObjCmd(
* struct and create the corresponding command.
*/
- corPtr = (CoroutineData *)Tcl_Alloc(sizeof(CoroutineData));
+ corPtr = (CoroutineData *) Tcl_Alloc(sizeof(CoroutineData));
cmdPtr = (Command *) TclNRCreateCommandInNs(interp, simpleName,
- (Tcl_Namespace *)nsPtr, /*objProc*/ NULL, TclNRInterpCoroutine,
+ (Tcl_Namespace *) nsPtr, /*objProc*/ NULL, TclNRInterpCoroutine,
corPtr, DeleteCoroutine);
corPtr->cmdPtr = cmdPtr;
@@ -9809,7 +9828,8 @@ TclNRCoroutineObjCmd(
Tcl_HashSearch hSearch;
Tcl_HashEntry *hePtr;
- corPtr->lineLABCPtr = (Tcl_HashTable *)Tcl_Alloc(sizeof(Tcl_HashTable));
+ corPtr->lineLABCPtr = (Tcl_HashTable *)
+ Tcl_Alloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(corPtr->lineLABCPtr, TCL_ONE_WORD_KEYS);
for (hePtr = Tcl_FirstHashEntry(iPtr->lineLABCPtr,&hSearch);
@@ -9870,7 +9890,7 @@ TclNRCoroutineObjCmd(
*/
TclNRAddCallback(interp, TclNRCoroutineActivateCallback, corPtr,
- NULL, NULL, NULL);
+ NULL, NULL, NULL);
return TCL_OK;
}