From 9c52d351f19a451f9d7fff451624b195959a558d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 8 Mar 2022 11:38:58 +0000 Subject: More size_t --- generic/regcomp.c | 4 ++-- generic/tclAssembly.c | 4 ++-- generic/tclCmdIL.c | 4 ++-- generic/tclCompCmds.c | 2 +- generic/tclCompCmdsSZ.c | 2 +- generic/tclCompile.c | 6 +++--- generic/tclCompile.h | 22 ++++++++++++++++------ generic/tclExecute.c | 2 +- generic/tclIORChan.c | 4 ++-- generic/tclListObj.c | 4 ++-- generic/tclOptimize.c | 5 +++-- generic/tclProc.c | 4 ++-- 12 files changed, 37 insertions(+), 26 deletions(-) diff --git a/generic/regcomp.c b/generic/regcomp.c index 103c0bf..4a107a8 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -410,7 +410,7 @@ compile( assert(v->nlacons == 0 || v->lacons != NULL); for (i = 1; i < v->nlacons; i++) { if (debug != NULL) { - fprintf(debug, "\n\n\n========= LA%" TCL_Z_MODIFIER "d ==========\n", i); + fprintf(debug, "\n\n\n========= LA%" TCL_Z_MODIFIER "u ==========\n", i); } nfanode(v, &v->lacons[i], debug); } @@ -2064,7 +2064,7 @@ dump( } fprintf(f, "\n\n\n========= DUMP ==========\n"); - fprintf(f, "nsub %" TCL_Z_MODIFIER "d, info 0%lo, ntree %d\n", + fprintf(f, "nsub %" TCL_Z_MODIFIER "u, info 0%lo, ntree %d\n", re->re_nsub, re->re_info, g->ntree); dumpcolors(&g->cmap, f); diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index e3e7bfc..b8a4606 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -963,14 +963,14 @@ TclCompileAssembleCmd( { Tcl_Token *tokenPtr; /* Token in the input script */ - int numCommands = envPtr->numCommands; + size_t numCommands = envPtr->numCommands; int offset = envPtr->codeNext - envPtr->codeStart; int depth = envPtr->currStackDepth; /* * Make sure that the command has a single arg that is a simple word. */ - if ((int)parsePtr->numWords != 2) { + if (parsePtr->numWords != 2) { return TCL_ERROR; } tokenPtr = TokenAfter(parsePtr->tokenPtr); diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 261cc65..07e42ef 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3383,7 +3383,7 @@ Tcl_LsearchObjCmd( } if (result == TCL_ERROR) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( - "\n (-index option item number %" TCL_Z_MODIFIER "d)", j)); + "\n (-index option item number %" TCL_Z_MODIFIER "u)", j)); goto done; } sortInfo.indexv[j] = encoded; @@ -4110,7 +4110,7 @@ Tcl_LsortObjCmd( } if (result == TCL_ERROR) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( - "\n (-index option item number %" TCL_Z_MODIFIER "d)", j)); + "\n (-index option item number %" TCL_Z_MODIFIER "u)", j)); sortInfo.resultCode = TCL_ERROR; goto done; } diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index c9a5724..a3d663b 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -3022,7 +3022,7 @@ PrintNewForeachInfo( ForeachVarList *varsPtr; size_t i, j; - Tcl_AppendPrintfToObj(appendObj, "jumpOffset=%+" TCL_Z_MODIFIER "d, vars=", + Tcl_AppendPrintfToObj(appendObj, "jumpOffset=%+" TCL_Z_MODIFIER "u, vars=", infoPtr->loopCtTemp); for (i=0 ; inumLists ; i++) { if (i) { diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 70c1a1d..0e782ac 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -893,7 +893,7 @@ TclCompileStringLenCmd( char buf[TCL_INTEGER_SPACE]; size_t len = Tcl_GetCharLength(objPtr); - len = sprintf(buf, "%" TCL_Z_MODIFIER "d", len); + len = sprintf(buf, "%" TCL_Z_MODIFIER "u", len); PushLiteral(envPtr, buf, len); } else { SetLineInformation(1); diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 9166ec4..e86a363 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -3164,7 +3164,7 @@ EnterCmdStartData( { CmdLocation *cmdLocPtr; - if ((cmdIndex < 0) || (cmdIndex >= envPtr->numCommands)) { + if ((size_t)cmdIndex >= envPtr->numCommands) { Tcl_Panic("EnterCmdStartData: bad command index %d", cmdIndex); } @@ -3243,7 +3243,7 @@ EnterCmdExtentData( { CmdLocation *cmdLocPtr; - if ((cmdIndex < 0) || (cmdIndex >= envPtr->numCommands)) { + if ((size_t)cmdIndex >= envPtr->numCommands) { Tcl_Panic("EnterCmdExtentData: bad command index %d", cmdIndex); } @@ -4028,7 +4028,7 @@ TclFixupForwardJump( */ firstCmd = jumpFixupPtr->cmdIndex; - lastCmd = envPtr->numCommands - 1; + lastCmd = (int)envPtr->numCommands - 1; if (firstCmd < lastCmd) { for (k = firstCmd; k <= lastCmd; k++) { envPtr->cmdMapPtr[k].codeOffset += 3; diff --git a/generic/tclCompile.h b/generic/tclCompile.h index b550c57..9f47a03 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -290,13 +290,13 @@ typedef struct CompileEnv { * SetByteCodeFromAny. This pointer is not * owned by the CompileEnv and must not be * freed or changed by it. */ - int numSrcBytes; /* Number of bytes in source. */ + size_t numSrcBytes; /* Number of bytes in source. */ Proc *procPtr; /* If a procedure is being compiled, a pointer * to its Proc structure; otherwise NULL. Used * to compile local variables. Set from * information provided by ObjInterpProc in * tclProc.c. */ - int numCommands; /* Number of commands compiled. */ + size_t numCommands; /* Number of commands compiled. */ int exceptDepth; /* Current exception range nesting level; -1 * if not in any range currently. */ int maxExceptDepth; /* Max nesting level of exception ranges; -1 @@ -316,6 +316,10 @@ typedef struct CompileEnv { * array byte. */ int mallocedCodeArray; /* Set 1 if code array was expanded and * codeStart points into the heap.*/ +#if TCL_MAJOR_VERSION > 8 + int mallocedExceptArray; /* 1 if ExceptionRange array was expanded and + * exceptArrayPtr points in heap, else 0. */ +#endif LiteralEntry *literalArrayPtr; /* Points to start of LiteralEntry array. */ int literalArrayNext; /* Index of next free object array entry. */ @@ -331,8 +335,9 @@ typedef struct CompileEnv { * current range's array entry. */ int exceptArrayEnd; /* Index after the last ExceptionRange array * entry. */ - int mallocedExceptArray; /* 1 if ExceptionRange array was expanded and - * exceptArrayPtr points in heap, else 0. */ +#if TCL_MAJOR_VERSION < 9 + int mallocedExceptArray; +#endif ExceptionAux *exceptAuxArrayPtr; /* Array of information used to restore the * state when processing BREAK/CONTINUE @@ -345,14 +350,19 @@ typedef struct CompileEnv { int cmdMapEnd; /* Index after last CmdLocation entry. */ int mallocedCmdMap; /* 1 if command map array was expanded and * cmdMapPtr points in the heap, else 0. */ +#if TCL_MAJOR_VERSION > 8 + int mallocedAuxDataArray; /* 1 if aux data array was expanded and + * auxDataArrayPtr points in heap else 0. */ +#endif AuxData *auxDataArrayPtr; /* Points to auxiliary data array start. */ int auxDataArrayNext; /* Next free compile aux data array index. * auxDataArrayNext is the number of aux data * items and (auxDataArrayNext-1) is index of * current aux data array entry. */ int auxDataArrayEnd; /* Index after last aux data array entry. */ - int mallocedAuxDataArray; /* 1 if aux data array was expanded and - * auxDataArrayPtr points in heap else 0. */ +#if TCL_MAJOR_VERSION < 9 + int mallocedAuxDataArray; +#endif unsigned char staticCodeSpace[COMPILEENV_INIT_CODE_BYTES]; /* Initial storage for code. */ LiteralEntry staticLiteralSpace[COMPILEENV_INIT_NUM_OBJECTS]; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 91796b3..fb51350 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2658,7 +2658,7 @@ TEBCresume( /* Ugly abuse! */ starting = 1; #endif - TRACE(("=> drop %" TCL_Z_MODIFIER "d items\n", objc)); + TRACE(("=> drop %" TCL_Z_MODIFIER "u items\n", objc)); NEXT_INST_V(1, objc, 0); case INST_EXPAND_STKTOP: { diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 7588ffa..f8646ff 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -2006,7 +2006,7 @@ ReflectGetOption( Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Expected list with even number of " - "elements, got %" TCL_Z_MODIFIER "d element%s instead", listc, + "elements, got %" TCL_Z_MODIFIER "u element%s instead", listc, (listc == 1 ? "" : "s"))); goto error; } else { @@ -3320,7 +3320,7 @@ ForwardProc( char *buf = (char *)Tcl_Alloc(200); sprintf(buf, - "{Expected list with even number of elements, got %" TCL_Z_MODIFIER "d %s instead}", + "{Expected list with even number of elements, got %" TCL_Z_MODIFIER "u %s instead}", listc, (listc == 1 ? "element" : "elements")); ForwardSetDynamicError(paramPtr, buf); diff --git a/generic/tclListObj.c b/generic/tclListObj.c index f7c32ef..17dd466 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -1763,7 +1763,7 @@ TclListObjSetElement( if (length == 0) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "index \"%" TCL_Z_MODIFIER "d\" out of range", index)); + "index \"%" TCL_Z_MODIFIER "u\" out of range", index)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", NULL); } @@ -1785,7 +1785,7 @@ TclListObjSetElement( if (index>=elemCount) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "index \"%" TCL_Z_MODIFIER "d\" out of range", index)); + "index \"%" TCL_Z_MODIFIER "u\" out of range", index)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX", "OUTOFRANGE", NULL); } diff --git a/generic/tclOptimize.c b/generic/tclOptimize.c index 1ef5ae7..094638e 100644 --- a/generic/tclOptimize.c +++ b/generic/tclOptimize.c @@ -54,7 +54,8 @@ LocateTargetAddresses( Tcl_HashTable *tablePtr) { unsigned char *currentInstPtr, *targetInstPtr; - int isNew, i; + int isNew; + size_t i; Tcl_HashEntry *hPtr; Tcl_HashSearch hSearch; @@ -124,7 +125,7 @@ LocateTargetAddresses( * Enter in the targets of exception ranges. */ - for (i=0 ; iexceptArrayNext ; i++) { + for (i=0 ; i<(size_t)envPtr->exceptArrayNext ; i++) { ExceptionRange *rangePtr = &envPtr->exceptArrayPtr[i]; if (rangePtr->type == CATCH_EXCEPTION_RANGE) { diff --git a/generic/tclProc.c b/generic/tclProc.c index 55c109e..feba33b 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -492,7 +492,7 @@ TclCreateProc( if (precompiled) { if (numArgs > (size_t)procPtr->numArgs) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "procedure \"%s\": arg list contains %" TCL_Z_MODIFIER "d entries, " + "procedure \"%s\": arg list contains %" TCL_Z_MODIFIER "u entries, " "precompiled header expects %d", procName, numArgs, procPtr->numArgs)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC", @@ -587,7 +587,7 @@ TclCreateProc( || (localPtr->defValuePtr == NULL && fieldCount == 2) || (localPtr->defValuePtr != NULL && fieldCount != 2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "procedure \"%s\": formal parameter %" TCL_Z_MODIFIER "d is " + "procedure \"%s\": formal parameter %" TCL_Z_MODIFIER "u is " "inconsistent with precompiled body", procName, i)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC", "BYTECODELIES", NULL); -- cgit v0.12