summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclDisassemble.c100
-rw-r--r--generic/tclInt.h16
-rw-r--r--generic/tclNamesp.c81
-rw-r--r--generic/tclProc.c22
-rw-r--r--generic/tclVar.c9
5 files changed, 116 insertions, 112 deletions
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 72c5bc8..2bbfc40 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -28,7 +28,7 @@ static int FormatInstruction(ByteCode *codePtr,
static void GetLocationInformation(Proc *procPtr,
Tcl_Obj **fileObjPtr, int *linePtr);
static void PrintSourceToObj(Tcl_Obj *appendObj,
- const char *stringPtr, int maxChars);
+ const char *stringPtr, Tcl_Size maxChars);
static void UpdateStringOfInstName(Tcl_Obj *objPtr);
/*
@@ -193,10 +193,10 @@ TclPrintObject(
FILE *outFile, /* The file to print the source to. */
Tcl_Obj *objPtr, /* Points to the Tcl object whose string
* representation should be printed. */
- int maxChars) /* Maximum number of chars to print. */
+ Tcl_Size maxChars) /* Maximum number of chars to print. */
{
char *bytes;
- int length;
+ Tcl_Size length;
bytes = TclGetStringFromObj(objPtr, &length);
TclPrintSource(outFile, bytes, TclMin(length, maxChars));
@@ -224,7 +224,7 @@ void
TclPrintSource(
FILE *outFile, /* The file to print the source to. */
const char *stringPtr, /* The string to print. */
- int maxChars) /* Maximum number of chars to print. */
+ Tcl_Size maxChars) /* Maximum number of chars to print. */
{
Tcl_Obj *bufferObj;
@@ -255,7 +255,8 @@ DisassembleByteCodeObj(
unsigned char *codeStart, *codeLimit, *pc;
unsigned char *codeDeltaNext, *codeLengthNext;
unsigned char *srcDeltaNext, *srcLengthNext;
- int codeOffset, codeLen, srcOffset, srcLen, numCmds, delta, i, line;
+ int codeOffset, codeLen, srcOffset, srcLen, numCmds, delta, line;
+ Tcl_Size i;
Interp *iPtr;
Tcl_Obj *bufferObj, *fileObj;
@@ -277,9 +278,8 @@ DisassembleByteCodeObj(
*/
Tcl_AppendPrintfToObj(bufferObj,
- "ByteCode %p, refCt %u, epoch %u, interp %p (epoch %u)\n",
- codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr,
- iPtr->compileEpoch);
+ "ByteCode %p, refCt %" TCL_SIZE_MODIFIER "u, epoch %" TCL_SIZE_MODIFIER "u, interp %p (epoch %" TCL_SIZE_MODIFIER "u)\n",
+ codePtr, codePtr->refCount, codePtr->compileEpoch, iPtr, iPtr->compileEpoch);
Tcl_AppendToObj(bufferObj, " Source ", -1);
PrintSourceToObj(bufferObj, codePtr->source,
TclMin(codePtr->numSrcBytes, 55));
@@ -289,7 +289,7 @@ DisassembleByteCodeObj(
TclGetString(fileObj), line);
}
Tcl_AppendPrintfToObj(bufferObj,
- "\n Cmds %d, src %d, inst %d, litObjs %u, aux %d, stkDepth %u, code/src %.2f\n",
+ "\n Cmds %d, src %" TCL_SIZE_MODIFIER "u, inst %" TCL_SIZE_MODIFIER "u, litObjs %" TCL_SIZE_MODIFIER "u, aux %" TCL_SIZE_MODIFIER "u, stkDepth %" TCL_SIZE_MODIFIER "u, code/src %.2f\n",
numCmds, codePtr->numSrcBytes, codePtr->numCodeBytes,
codePtr->numLitObjects, codePtr->numAuxDataItems,
codePtr->maxStackDepth,
@@ -301,8 +301,8 @@ DisassembleByteCodeObj(
#ifdef TCL_COMPILE_STATS
Tcl_AppendPrintfToObj(bufferObj,
- " Code %" TCL_Z_MODIFIER "u = header %" TCL_Z_MODIFIER "u+inst %d+litObj %"
- TCL_Z_MODIFIER "u+exc %" TCL_Z_MODIFIER "u+aux %" TCL_Z_MODIFIER "u+cmdMap %d\n",
+ " Code %" TCL_Z_MODIFIER "u = header %" TCL_Z_MODIFIER "u+inst %" TCL_SIZE_MODIFIER "u+litObj %"
+ TCL_Z_MODIFIER "u+exc %" TCL_Z_MODIFIER "u+aux %" TCL_Z_MODIFIER "u+cmdMap %" TCL_SIZE_MODIFIER "u\n",
codePtr->structureSize,
offsetof(ByteCode, localCachePtr),
codePtr->numCodeBytes,
@@ -320,10 +320,10 @@ DisassembleByteCodeObj(
if (codePtr->procPtr != NULL) {
Proc *procPtr = codePtr->procPtr;
- int numCompiledLocals = procPtr->numCompiledLocals;
+ Tcl_Size numCompiledLocals = procPtr->numCompiledLocals;
Tcl_AppendPrintfToObj(bufferObj,
- " Proc %p, refCt %u, args %d, compiled locals %d\n",
+ " Proc %p, refCt %" TCL_SIZE_MODIFIER "u, args %" TCL_SIZE_MODIFIER "u, compiled locals %" TCL_SIZE_MODIFIER "u\n",
procPtr, procPtr->refCount, procPtr->numArgs,
numCompiledLocals);
if (numCompiledLocals > 0) {
@@ -331,7 +331,7 @@ DisassembleByteCodeObj(
for (i = 0; i < numCompiledLocals; i++) {
Tcl_AppendPrintfToObj(bufferObj,
- " slot %d%s%s%s%s%s%s", i,
+ " slot %" TCL_SIZE_MODIFIER "u%s%s%s%s%s%s", i,
(localPtr->flags & (VAR_ARRAY|VAR_LINK)) ? "" : ", scalar",
(localPtr->flags & VAR_ARRAY) ? ", array" : "",
(localPtr->flags & VAR_LINK) ? ", link" : "",
@@ -354,24 +354,24 @@ DisassembleByteCodeObj(
*/
if (codePtr->numExceptRanges > 0) {
- Tcl_AppendPrintfToObj(bufferObj, " Exception ranges %d, depth %d:\n",
+ Tcl_AppendPrintfToObj(bufferObj, " Exception ranges %" TCL_SIZE_MODIFIER "u, depth %" TCL_SIZE_MODIFIER "u:\n",
codePtr->numExceptRanges, codePtr->maxExceptDepth);
for (i = 0; i < codePtr->numExceptRanges; i++) {
ExceptionRange *rangePtr = &codePtr->exceptArrayPtr[i];
Tcl_AppendPrintfToObj(bufferObj,
- " %d: level %d, %s, pc %d-%d, ",
+ " %" TCL_SIZE_MODIFIER "u: level %" TCL_SIZE_MODIFIER "u, %s, pc %" TCL_SIZE_MODIFIER "u-%" TCL_SIZE_MODIFIER "u, ",
i, rangePtr->nestingLevel,
(rangePtr->type==LOOP_EXCEPTION_RANGE ? "loop" : "catch"),
rangePtr->codeOffset,
(rangePtr->codeOffset + rangePtr->numCodeBytes - 1));
switch (rangePtr->type) {
case LOOP_EXCEPTION_RANGE:
- Tcl_AppendPrintfToObj(bufferObj, "continue %d, break %d\n",
+ Tcl_AppendPrintfToObj(bufferObj, "continue %" TCL_SIZE_MODIFIER "u, break %" TCL_SIZE_MODIFIER "u\n",
rangePtr->continueOffset, rangePtr->breakOffset);
break;
case CATCH_EXCEPTION_RANGE:
- Tcl_AppendPrintfToObj(bufferObj, "catch %d\n",
+ Tcl_AppendPrintfToObj(bufferObj, "catch %" TCL_SIZE_MODIFIER "u\n",
rangePtr->catchOffset);
break;
default:
@@ -407,7 +407,7 @@ DisassembleByteCodeObj(
srcLengthNext = codePtr->srcLengthStart;
codeOffset = srcOffset = 0;
for (i = 0; i < numCmds; i++) {
- if ((unsigned) *codeDeltaNext == (unsigned) 0xFF) {
+ if (*codeDeltaNext == 0xFF) {
codeDeltaNext++;
delta = TclGetInt4AtPtr(codeDeltaNext);
codeDeltaNext += 4;
@@ -417,7 +417,7 @@ DisassembleByteCodeObj(
}
codeOffset += delta;
- if ((unsigned) *codeLengthNext == (unsigned) 0xFF) {
+ if (*codeLengthNext == 0xFF) {
codeLengthNext++;
codeLen = TclGetInt4AtPtr(codeLengthNext);
codeLengthNext += 4;
@@ -426,7 +426,7 @@ DisassembleByteCodeObj(
codeLengthNext++;
}
- if ((unsigned) *srcDeltaNext == (unsigned) 0xFF) {
+ if (*srcDeltaNext == 0xFF) {
srcDeltaNext++;
delta = TclGetInt4AtPtr(srcDeltaNext);
srcDeltaNext += 4;
@@ -436,7 +436,7 @@ DisassembleByteCodeObj(
}
srcOffset += delta;
- if ((unsigned) *srcLengthNext == (unsigned) 0xFF) {
+ if (*srcLengthNext == 0xFF) {
srcLengthNext++;
srcLen = TclGetInt4AtPtr(srcLengthNext);
srcLengthNext += 4;
@@ -445,7 +445,7 @@ DisassembleByteCodeObj(
srcLengthNext++;
}
- Tcl_AppendPrintfToObj(bufferObj, "%s%4d: pc %d-%d, src %d-%d",
+ Tcl_AppendPrintfToObj(bufferObj, "%s%4" TCL_SIZE_MODIFIER "u: pc %d-%d, src %d-%d",
((i % 2)? " " : "\n "),
(i+1), codeOffset, (codeOffset + codeLen - 1),
srcOffset, (srcOffset + srcLen - 1));
@@ -466,7 +466,7 @@ DisassembleByteCodeObj(
codeOffset = srcOffset = 0;
pc = codeStart;
for (i = 0; i < numCmds; i++) {
- if ((unsigned) *codeDeltaNext == (unsigned) 0xFF) {
+ if (*codeDeltaNext == 0xFF) {
codeDeltaNext++;
delta = TclGetInt4AtPtr(codeDeltaNext);
codeDeltaNext += 4;
@@ -476,7 +476,7 @@ DisassembleByteCodeObj(
}
codeOffset += delta;
- if ((unsigned) *srcDeltaNext == (unsigned) 0xFF) {
+ if (*srcDeltaNext == 0xFF) {
srcDeltaNext++;
delta = TclGetInt4AtPtr(srcDeltaNext);
srcDeltaNext += 4;
@@ -486,7 +486,7 @@ DisassembleByteCodeObj(
}
srcOffset += delta;
- if ((unsigned) *srcLengthNext == (unsigned) 0xFF) {
+ if (*srcLengthNext == 0xFF) {
srcLengthNext++;
srcLen = TclGetInt4AtPtr(srcLengthNext);
srcLengthNext += 4;
@@ -504,7 +504,7 @@ DisassembleByteCodeObj(
pc += FormatInstruction(codePtr, pc, bufferObj);
}
- Tcl_AppendPrintfToObj(bufferObj, " Command %d: ", i+1);
+ Tcl_AppendPrintfToObj(bufferObj, " Command %" TCL_SIZE_MODIFIER "u: ", i+1);
PrintSourceToObj(bufferObj, (codePtr->source + srcOffset),
TclMin(srcLen, 55));
Tcl_AppendToObj(bufferObj, "\n", -1);
@@ -544,7 +544,7 @@ FormatInstruction(
unsigned char *codeStart = codePtr->codeStart;
unsigned pcOffset = pc - codeStart;
int opnd = 0, i, j, numBytes = 1;
- int localCt = procPtr ? procPtr->numCompiledLocals : 0;
+ Tcl_Size localCt = procPtr ? procPtr->numCompiledLocals : 0;
CompiledLocal *localPtr = procPtr ? procPtr->firstLocalPtr : NULL;
char suffixBuffer[128]; /* Additional info to print after main opcode
* and immediates. */
@@ -566,7 +566,7 @@ FormatInstruction(
break;
case OPERAND_UINT1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
- Tcl_AppendPrintfToObj(bufferObj, "%u ", (unsigned) opnd);
+ Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_UINT4:
opnd = TclGetUInt4AtPtr(pc+numBytes); numBytes += 4;
@@ -574,7 +574,7 @@ FormatInstruction(
snprintf(suffixBuffer+strlen(suffixBuffer), sizeof(suffixBuffer) - strlen(suffixBuffer),
", %u cmds start here", opnd);
}
- Tcl_AppendPrintfToObj(bufferObj, "%u ", (unsigned) opnd);
+ Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_OFFSET1:
opnd = TclGetInt1AtPtr(pc+numBytes); numBytes++;
@@ -593,16 +593,16 @@ FormatInstruction(
case OPERAND_LIT1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
suffixObj = codePtr->objArrayPtr[opnd];
- Tcl_AppendPrintfToObj(bufferObj, "%u ", (unsigned) opnd);
+ Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_LIT4:
opnd = TclGetUInt4AtPtr(pc+numBytes); numBytes += 4;
suffixObj = codePtr->objArrayPtr[opnd];
- Tcl_AppendPrintfToObj(bufferObj, "%u ", (unsigned) opnd);
+ Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
break;
case OPERAND_AUX4:
opnd = TclGetUInt4AtPtr(pc+numBytes); numBytes += 4;
- Tcl_AppendPrintfToObj(bufferObj, "%u ", (unsigned) opnd);
+ Tcl_AppendPrintfToObj(bufferObj, "%u ", opnd);
auxPtr = &codePtr->auxDataArrayPtr[opnd];
break;
case OPERAND_IDX4:
@@ -625,20 +625,20 @@ FormatInstruction(
printLVTindex:
if (localPtr != NULL) {
if (opnd >= localCt) {
- Tcl_Panic("FormatInstruction: bad local var index %u (%u locals)",
- (unsigned) opnd, localCt);
+ Tcl_Panic("FormatInstruction: bad local var index %u (%" TCL_SIZE_MODIFIER "u locals)",
+ opnd, localCt);
}
for (j = 0; j < opnd; j++) {
localPtr = localPtr->nextPtr;
}
if (TclIsVarTemporary(localPtr)) {
- snprintf(suffixBuffer, sizeof(suffixBuffer), "temp var %u", (unsigned) opnd);
+ snprintf(suffixBuffer, sizeof(suffixBuffer), "temp var %u", opnd);
} else {
snprintf(suffixBuffer, sizeof(suffixBuffer), "var ");
suffixSrc = localPtr->name;
}
}
- Tcl_AppendPrintfToObj(bufferObj, "%%v%u ", (unsigned) opnd);
+ Tcl_AppendPrintfToObj(bufferObj, "%%v%u ", opnd);
break;
case OPERAND_SCLS1:
opnd = TclGetUInt1AtPtr(pc+numBytes); numBytes++;
@@ -652,7 +652,7 @@ FormatInstruction(
}
if (suffixObj) {
const char *bytes;
- int length;
+ Tcl_Size length;
Tcl_AppendToObj(bufferObj, "\t# ", -1);
bytes = TclGetStringFromObj(codePtr->objArrayPtr[opnd], &length);
@@ -690,7 +690,7 @@ TclGetInnerContext(
const unsigned char *pc,
Tcl_Obj **tosPtr)
{
- int objc = 0, off = 0;
+ Tcl_Size objc = 0;
Tcl_Obj *result;
Interp *iPtr = (Interp *) interp;
@@ -759,7 +759,7 @@ TclGetInnerContext(
iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL);
Tcl_IncrRefCount(result);
} else {
- int len;
+ Tcl_Size len;
/*
* Reset while keeping the list internalrep as much as possible.
@@ -773,7 +773,7 @@ TclGetInnerContext(
for (; objc>0 ; objc--) {
Tcl_Obj *objPtr;
- objPtr = tosPtr[1 - objc + off];
+ objPtr = tosPtr[1 - objc];
if (!objPtr) {
Tcl_Panic("InnerContext: bad tos -- appending null object");
}
@@ -860,10 +860,10 @@ static void
PrintSourceToObj(
Tcl_Obj *appendObj, /* The object to print the source to. */
const char *stringPtr, /* The string to print. */
- int maxChars) /* Maximum number of chars to print. */
+ Tcl_Size maxChars) /* Maximum number of chars to print. */
{
const char *p;
- int i = 0, len;
+ Tcl_Size i = 0, len;
if (stringPtr == NULL) {
Tcl_AppendToObj(appendObj, "\"\"", -1);
@@ -943,8 +943,8 @@ DisassembleByteCodeAsDicts(
Tcl_Obj *description, *literals, *variables, *instructions, *inst;
Tcl_Obj *aux, *exn, *commands, *file;
unsigned char *pc, *opnd, *codeOffPtr, *codeLenPtr, *srcOffPtr, *srcLenPtr;
- int codeOffset, codeLength, sourceOffset, sourceLength;
- int i, val, line;
+ int codeOffset, codeLength, sourceOffset, sourceLength, val, line;
+ Tcl_Size i;
ByteCodeGetInternalRep(objPtr, &tclByteCodeType, codePtr);
@@ -963,7 +963,7 @@ DisassembleByteCodeAsDicts(
TclNewObj(variables);
if (codePtr->procPtr) {
- int localCount = codePtr->procPtr->numCompiledLocals;
+ Tcl_Size localCount = codePtr->procPtr->numCompiledLocals;
CompiledLocal *localPtr = codePtr->procPtr->firstLocalPtr;
for (i=0 ; i<localCount ; i++,localPtr=localPtr->nextPtr) {
@@ -1146,14 +1146,14 @@ DisassembleByteCodeAsDicts(
switch (rangePtr->type) {
case LOOP_EXCEPTION_RANGE:
Tcl_ListObjAppendElement(NULL, exn, Tcl_ObjPrintf(
- "type %s level %d from %d to %d break %d continue %d",
+ "type %s level %" TCL_SIZE_MODIFIER "u from %" TCL_SIZE_MODIFIER "u to %" TCL_SIZE_MODIFIER "u break %" TCL_SIZE_MODIFIER "u continue %" TCL_SIZE_MODIFIER "u",
"loop", rangePtr->nestingLevel, rangePtr->codeOffset,
rangePtr->codeOffset + rangePtr->numCodeBytes - 1,
rangePtr->breakOffset, rangePtr->continueOffset));
break;
case CATCH_EXCEPTION_RANGE:
Tcl_ListObjAppendElement(NULL, exn, Tcl_ObjPrintf(
- "type %s level %d from %d to %d catch %d",
+ "type %s level %" TCL_SIZE_MODIFIER "u from %" TCL_SIZE_MODIFIER "u to %" TCL_SIZE_MODIFIER "u catch %" TCL_SIZE_MODIFIER "u",
"catch", rangePtr->nestingLevel, rangePtr->codeOffset,
rangePtr->codeOffset + rangePtr->numCodeBytes - 1,
rangePtr->catchOffset));
@@ -1528,7 +1528,7 @@ Tcl_DisassembleObjCmd(
return TCL_ERROR;
}
hPtr = Tcl_FindHashEntry(&oPtr->classPtr->classMethods,
- (char *) objv[3]);
+ (char *)objv[3]);
goto methodBody;
case DISAS_OBJECT_METHOD:
if (objc != 4) {
@@ -1547,7 +1547,7 @@ Tcl_DisassembleObjCmd(
if (oPtr->methodsPtr == NULL) {
goto unknownMethod;
}
- hPtr = Tcl_FindHashEntry(oPtr->methodsPtr, (char *) objv[3]);
+ hPtr = Tcl_FindHashEntry(oPtr->methodsPtr, (char *)objv[3]);
/*
* Compile (if necessary) and disassemble a method body.
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 7114d66..25a23ed 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -877,6 +877,9 @@ typedef struct VarInHash {
#define VarHashRefCount(varPtr) \
((VarInHash *) (varPtr))->refCount
+#define VarHashGetKey(varPtr) \
+ (((VarInHash *)(varPtr))->entry.key.objPtr)
+
/*
* Macros for direct variable access by TEBC.
*/
@@ -2676,7 +2679,7 @@ typedef struct ListRep {
#define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
((((objPtr)->typePtr == &tclIntType) && ((objPtr)->internalRep.wideValue >= 0) \
&& ((Tcl_WideUInt)(objPtr)->internalRep.wideValue <= (Tcl_WideUInt)(endValue + 1))) \
- ? ((*(idxPtr) = (int)(objPtr)->internalRep.wideValue), TCL_OK) \
+ ? ((*(idxPtr) = (Tcl_Size)(objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
/*
@@ -4739,16 +4742,17 @@ MODULE_SCOPE const TclFileAttrProcs tclpFileAttrProcs[];
* of counting along a string of all one-byte characters. The ANSI C
* "prototype" for this macro is:
*
- * MODULE_SCOPE void TclNumUtfCharsM(int numChars, const char *bytes,
- * int numBytes);
+ * MODULE_SCOPE void TclNumUtfCharsM(Tcl_Size numChars, const char *bytes,
+ * Tcl_Size numBytes);
+ * numBytes must be >= 0
*----------------------------------------------------------------
*/
#define TclNumUtfCharsM(numChars, bytes, numBytes) \
do { \
- int _count, _i = (numBytes); \
+ Tcl_Size _count, _i = (numBytes); \
unsigned char *_str = (unsigned char *) (bytes); \
- while (_i && (*_str < 0xC0)) { _i--; _str++; } \
+ while (_i > 0 && (*_str < 0xC0)) { _i--; _str++; } \
_count = (numBytes) - _i; \
if (_i) { \
_count += TclNumUtfChars((bytes) + _count, _i); \
@@ -4873,7 +4877,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit;
*
* MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, Tcl_WideInt w);
* MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
- * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, int len);
+ * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, Tcl_Size len);
* MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, const char *sLiteral);
*
*----------------------------------------------------------------
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index b97d16f..aea397e 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -53,7 +53,7 @@ static Tcl_ThreadDataKey dataKey;
* with some information that is used to check the cached pointer's validity.
*/
-typedef struct ResolvedNsName {
+typedef struct {
Namespace *nsPtr; /* A cached pointer to the Namespace that the
* name resolved to. */
Namespace *refNsPtr; /* Points to the namespace context in which
@@ -326,7 +326,7 @@ Tcl_PushCallFrame(
framePtr->callerPtr = iPtr->framePtr;
framePtr->callerVarPtr = iPtr->varFramePtr;
if (iPtr->varFramePtr != NULL) {
- framePtr->level = (iPtr->varFramePtr->level + 1);
+ framePtr->level = iPtr->varFramePtr->level + 1U;
} else {
framePtr->level = 0;
}
@@ -409,9 +409,8 @@ Tcl_PopCallFrame(
*/
nsPtr = framePtr->nsPtr;
- nsPtr->activationCount--;
- if ((nsPtr->flags & NS_DYING)
- && (nsPtr->activationCount - (nsPtr == iPtr->globalNsPtr) == 0)) {
+ if ((--nsPtr->activationCount <= (nsPtr == iPtr->globalNsPtr))
+ && (nsPtr->flags & NS_DYING)) {
Tcl_DeleteNamespace((Tcl_Namespace *) nsPtr);
}
framePtr->nsPtr = NULL;
@@ -671,7 +670,8 @@ Tcl_CreateNamespace(
Tcl_HashEntry *entryPtr;
Tcl_DString buffer1, buffer2;
Tcl_DString *namePtr, *buffPtr;
- int newEntry, nameLen;
+ int newEntry;
+ size_t nameLen;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
const char *nameStr;
Tcl_DString tmpBuffer;
@@ -1009,7 +1009,7 @@ Tcl_DeleteNamespace(
* FreeNsNameInternalRep when its refCount reaches 0.
*/
- if (nsPtr->activationCount - (nsPtr == globalNsPtr) > 0) {
+ if (nsPtr->activationCount > (nsPtr == globalNsPtr)) {
nsPtr->flags |= NS_DYING;
if (nsPtr->parentPtr != NULL) {
entryPtr = Tcl_FindHashEntry(
@@ -1087,7 +1087,8 @@ TclDeleteNamespaceChildren(
{
Interp *iPtr = (Interp *) nsPtr->interp;
Tcl_HashEntry *entryPtr;
- int i, unchecked;
+ size_t i;
+ int unchecked;
Tcl_HashSearch search;
/*
* Delete all the child namespaces.
@@ -1105,7 +1106,7 @@ TclDeleteNamespaceChildren(
#ifndef BREAK_NAMESPACE_COMPAT
unchecked = (nsPtr->childTable.numEntries > 0);
while (nsPtr->childTable.numEntries > 0 && unchecked) {
- int length = nsPtr->childTable.numEntries;
+ size_t length = nsPtr->childTable.numEntries;
Namespace **children = (Namespace **)TclStackAlloc((Tcl_Interp *) iPtr,
sizeof(Namespace *) * length);
@@ -1131,7 +1132,7 @@ TclDeleteNamespaceChildren(
if (nsPtr->childTablePtr != NULL) {
unchecked = (nsPtr->childTable.numEntries > 0);
while (nsPtr->childTable.numEntries > 0 && unchecked) {
- int length = nsPtr->childTablePtr->numEntries;
+ size_t length = nsPtr->childTablePtr->numEntries;
Namespace **children = (Namespace **)TclStackAlloc((Tcl_Interp *) iPtr,
sizeof(Namespace *) * length);
@@ -1187,7 +1188,7 @@ TclTeardownNamespace(
Interp *iPtr = (Interp *) nsPtr->interp;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
- int i;
+ Tcl_Size i;
/*
* Start by destroying the namespace's variable table, since variables
@@ -1208,7 +1209,7 @@ TclTeardownNamespace(
*/
while (nsPtr->cmdTable.numEntries > 0) {
- int length = nsPtr->cmdTable.numEntries;
+ Tcl_Size length = nsPtr->cmdTable.numEntries;
Command **cmds = (Command **)TclStackAlloc((Tcl_Interp *) iPtr,
sizeof(Command *) * length);
@@ -1398,7 +1399,7 @@ Tcl_Export(
Namespace *currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
const char *simplePattern;
char *patternCpy;
- int neededElems, len, i;
+ Tcl_Size neededElems, len, i;
/*
* If the specified namespace is NULL, use the current namespace.
@@ -1525,7 +1526,8 @@ Tcl_AppendExportList(
* export pattern list is appended. */
{
Namespace *nsPtr;
- int i, result;
+ Tcl_Size i;
+ int result;
/*
* If the specified namespace is NULL, use the current namespace.
@@ -1727,7 +1729,7 @@ DoImport(
Namespace *importNsPtr,
int allowOverwrite)
{
- int i = 0, exported = 0;
+ Tcl_Size i = 0, exported = 0;
Tcl_HashEntry *found;
/*
@@ -2639,7 +2641,7 @@ Tcl_FindCommand(
cmdPtr = NULL;
if (cxtNsPtr->commandPathLength!=0 && strncmp(name, "::", 2)
&& !(flags & TCL_NAMESPACE_ONLY)) {
- int i;
+ Tcl_Size i;
Namespace *pathNsPtr, *realNsPtr, *dummyNsPtr;
(void) TclGetNamespaceForQualName(interp, name, cxtNsPtr,
@@ -3066,7 +3068,7 @@ NamespaceChildrenCmd(
listPtr = Tcl_NewListObj(0, NULL);
if ((pattern != NULL) && TclMatchIsTrivial(pattern)) {
- unsigned int length = strlen(nsPtr->fullName);
+ size_t length = strlen(nsPtr->fullName);
if (strncmp(pattern, nsPtr->fullName, length) != 0) {
goto searchDone;
@@ -3146,7 +3148,7 @@ NamespaceCodeCmd(
Namespace *currNsPtr;
Tcl_Obj *listPtr, *objPtr;
const char *arg;
- int length;
+ Tcl_Size length;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "arg");
@@ -3459,15 +3461,15 @@ NsEval_Callback(
Tcl_Namespace *namespacePtr = (Tcl_Namespace *)data[0];
if (result == TCL_ERROR) {
- int length = strlen(namespacePtr->fullName);
- int limit = 200;
+ size_t length = strlen(namespacePtr->fullName);
+ unsigned limit = 200;
int overflow = (length > limit);
char *cmd = (char *)data[1];
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (in namespace %s \"%.*s%s\" script line %d)",
cmd,
- (overflow ? limit : length), namespacePtr->fullName,
+ (overflow ? limit : (unsigned)length), namespacePtr->fullName,
(overflow ? "..." : ""), Tcl_GetErrorLine(interp)));
}
@@ -4040,7 +4042,8 @@ NamespacePathCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
- int i, nsObjc, result = TCL_ERROR;
+ Tcl_Size nsObjc, i;
+ int result = TCL_ERROR;
Tcl_Obj **nsObjv;
Tcl_Namespace **namespaceList = NULL;
@@ -4078,7 +4081,7 @@ NamespacePathCmd(
namespaceList = (Tcl_Namespace **)TclStackAlloc(interp,
sizeof(Tcl_Namespace *) * nsObjc);
- for (i=0 ; i<nsObjc ; i++) {
+ for (i = 0; i < nsObjc; i++) {
if (TclGetNamespaceFromObj(interp, nsObjv[i],
&namespaceList[i]) != TCL_OK) {
goto badNamespace;
@@ -4123,13 +4126,13 @@ NamespacePathCmd(
void
TclSetNsPath(
Namespace *nsPtr, /* Namespace whose path is to be set. */
- int pathLength, /* Length of pathAry. */
+ Tcl_Size pathLength, /* Length of pathAry. */
Tcl_Namespace *pathAry[]) /* Array of namespaces that are the path. */
{
if (pathLength != 0) {
NamespacePathEntry *tmpPathArray =
(NamespacePathEntry *)ckalloc(sizeof(NamespacePathEntry) * pathLength);
- int i;
+ Tcl_Size i;
for (i=0 ; i<pathLength ; i++) {
tmpPathArray[i].nsPtr = (Namespace *) pathAry[i];
@@ -4180,7 +4183,7 @@ static void
UnlinkNsPath(
Namespace *nsPtr)
{
- int i;
+ Tcl_Size i;
for (i=0 ; i<nsPtr->commandPathLength ; i++) {
NamespacePathEntry *nsPathPtr = &nsPtr->commandPathArray[i];
@@ -4266,7 +4269,7 @@ NamespaceQualifiersCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *name, *p;
- int length;
+ size_t length;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "string");
@@ -4431,7 +4434,7 @@ Tcl_SetNamespaceUnknownHandler(
Tcl_Namespace *nsPtr, /* Namespace which is being updated. */
Tcl_Obj *handlerPtr) /* The new handler, or NULL to reset. */
{
- int lstlen = 0;
+ Tcl_Size lstlen = 0;
Namespace *currNsPtr = (Namespace *) nsPtr;
/*
@@ -4903,11 +4906,11 @@ TclGetNamespaceChildTable(
*
* TclLogCommandInfo --
*
- * This function is invoked after an error occurs in an interpreter. It
- * adds information to iPtr->errorInfo/errorStack fields to describe the
+ * Invoked after an error occurs in an interpreter.
+ * Adds information to iPtr->errorInfo/errorStack fields to describe the
* command that was being executed when the error occurred. When pc and
* tosPtr are non-NULL, conveying a bytecode execution "inner context",
- * and the offending instruction is suitable, that inner context is
+ * and the offending instruction is suitable, and that inner context is
* recorded in errorStack.
*
* Results:
@@ -4927,8 +4930,8 @@ TclLogCommandInfo(
* command (must be <= command). */
const char *command, /* First character in command that generated
* the error. */
- int length, /* Number of bytes in command (TCL_INDEX_NONE
- * means use all bytes up to first null byte).
+ Tcl_Size length, /* Number of bytes in command (< 0 means use
+ * all bytes up to first null byte).
*/
const unsigned char *pc, /* Current pc of bytecode execution context */
Tcl_Obj **tosPtr) /* Current stack of bytecode execution
@@ -4941,8 +4944,8 @@ TclLogCommandInfo(
if (iPtr->flags & ERR_ALREADY_LOGGED) {
/*
- * Someone else has already logged error information for this command;
- * we shouldn't add anything more.
+ * Someone else has already logged error information for this command.
+ * Don't add anything more.
*/
return;
@@ -5013,7 +5016,7 @@ TclLogCommandInfo(
iPtr->errorStack = newObj;
}
if (iPtr->resetErrorStack) {
- int len;
+ Tcl_Size len;
iPtr->resetErrorStack = 0;
TclListObjLengthM(interp, iPtr->errorStack, &len);
@@ -5085,7 +5088,7 @@ void
TclErrorStackResetIf(
Tcl_Interp *interp,
const char *msg,
- int length)
+ Tcl_Size length)
{
Interp *iPtr = (Interp *) interp;
@@ -5098,7 +5101,7 @@ TclErrorStackResetIf(
iPtr->errorStack = newObj;
}
if (iPtr->resetErrorStack) {
- int len;
+ Tcl_Size len;
iPtr->resetErrorStack = 0;
TclListObjLengthM(interp, iPtr->errorStack, &len);
@@ -5140,7 +5143,7 @@ Tcl_LogCommandInfo(
* command (must be <= command). */
const char *command, /* First character in command that generated
* the error. */
- int length) /* Number of bytes in command (-1 means use
+ Tcl_Size length) /* Number of bytes in command (-1 means use
* all bytes up to first null byte). */
{
TclLogCommandInfo(interp, script, command, length, NULL, NULL);
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 3abf3c3..a107341 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -493,8 +493,8 @@ TclCreateProc(
if (precompiled) {
if (numArgs > procPtr->numArgs) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "procedure \"%s\": arg list contains %d entries, "
- "precompiled header expects %d", procName, numArgs,
+ "procedure \"%s\": arg list contains %" TCL_SIZE_MODIFIER "u entries, "
+ "precompiled header expects %" TCL_SIZE_MODIFIER "u", procName, numArgs,
procPtr->numArgs));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"BYTECODELIES", NULL);
@@ -588,7 +588,7 @@ TclCreateProc(
|| (localPtr->defValuePtr == NULL && fieldCount == 2)
|| (localPtr->defValuePtr != NULL && fieldCount != 2)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "procedure \"%s\": formal parameter %d is "
+ "procedure \"%s\": formal parameter %" TCL_SIZE_MODIFIER "u is "
"inconsistent with precompiled body", procName, i));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC",
"BYTECODELIES", NULL);
@@ -1065,7 +1065,7 @@ ProcWrongNumArgs(
{
CallFrame *framePtr = ((Interp *)interp)->varFramePtr;
Proc *procPtr = framePtr->procPtr;
- int localCt = procPtr->numCompiledLocals, numArgs, i;
+ Tcl_Size localCt = procPtr->numCompiledLocals, numArgs, i;
Tcl_Obj **desiredObjs;
const char *final = NULL;
@@ -1400,7 +1400,7 @@ InitArgsAndLocals(
Proc *procPtr = framePtr->procPtr;
ByteCode *codePtr;
Var *varPtr, *defPtr;
- int localCt = procPtr->numCompiledLocals, numArgs, argCt, i, imax;
+ Tcl_Size localCt = procPtr->numCompiledLocals, numArgs, argCt, i, imax;
Tcl_Obj *const *argObjs;
ByteCodeGetInternalRep(procPtr->bodyPtr, &tclByteCodeType, codePtr);
@@ -1559,7 +1559,7 @@ TclPushProcCallFrame(
* interpreted. */
Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
- Tcl_Size objc, /* Count of number of arguments to this
+ Tcl_Size objc, /* Count of number of arguments to this
* procedure. */
Tcl_Obj *const objv[], /* Argument value objects. */
int isLambda) /* 1 if this is a call by ApplyObjCmd: it
@@ -1686,9 +1686,9 @@ TclNRInterpProc(
static int
NRInterpProc2(
- void *clientData, /* Record describing procedure to be
+ void *clientData, /* Record describing procedure to be
* interpreted. */
- Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp, /* Interpreter in which procedure was
* invoked. */
ptrdiff_t objc, /* Count of number of arguments to this
* procedure. */
@@ -1705,9 +1705,9 @@ NRInterpProc2(
static int
ObjInterpProc2(
- void *clientData, /* Record describing procedure to be
+ void *clientData, /* Record describing procedure to be
* interpreted. */
- Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp, /* Interpreter in which procedure was
* invoked. */
ptrdiff_t objc, /* Count of number of arguments to this
* procedure. */
@@ -2021,7 +2021,7 @@ TclProcCompileProc(
TclNewLiteralStringObj(message, "Compiling ");
Tcl_IncrRefCount(message);
Tcl_AppendStringsToObj(message, description, " \"", NULL);
- Tcl_AppendLimitedToObj(message, procName, -1, 50, NULL);
+ Tcl_AppendLimitedToObj(message, procName, TCL_INDEX_NONE, 50, NULL);
fprintf(stdout, "%s\"\n", TclGetString(message));
Tcl_DecrRefCount(message);
}
diff --git a/generic/tclVar.c b/generic/tclVar.c
index ea8a104..70ba63b 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -108,9 +108,6 @@ VarHashNextVar(
return VarHashGetValue(hPtr);
}
-#define VarHashGetKey(varPtr) \
- (((VarInHash *)(varPtr))->entry.key.objPtr)
-
#define VarHashDeleteTable(tablePtr) \
Tcl_DeleteHashTable(&(tablePtr)->table)
@@ -844,8 +841,8 @@ TclLookupSimpleVar(
* the variable. */
Namespace *varNsPtr, *cxtNsPtr, *dummy1Ptr, *dummy2Ptr;
ResolverScheme *resPtr;
- int isNew, i, result;
- Tcl_Size varLen;
+ int isNew, result;
+ Tcl_Size i, varLen;
const char *varName = TclGetStringFromObj(varNamePtr, &varLen);
varPtr = NULL;
@@ -974,7 +971,7 @@ TclLookupSimpleVar(
}
}
} else { /* Local var: look in frame varFramePtr. */
- int localCt = varFramePtr->numCompiledLocals;
+ Tcl_Size localCt = varFramePtr->numCompiledLocals;
if (localCt > 0) {
Tcl_Obj **objPtrPtr = &varFramePtr->localCachePtr->varName0;