From 798a505ffb312727e4e5b9d44891d067aeb9172e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 Mar 2022 21:25:13 +0000 Subject: more tweaks --- generic/tclBasic.c | 6 +++--- generic/tclCompile.c | 29 +++++++++++++++-------------- generic/tclCompile.h | 8 ++++---- generic/tclExecute.c | 2 +- generic/tclInt.h | 2 +- generic/tclLiteral.c | 12 ++++++------ 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 7d09caf..a43bca0 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -5019,7 +5019,7 @@ TclEvalEx( * TCL_EVAL_GLOBAL was set. */ int allowExceptions = (iPtr->evalFlags & TCL_ALLOW_EXCEPTIONS); int gotParse = 0; - unsigned int i, objectsUsed = 0; + size_t i, objectsUsed = 0; /* These variables keep track of how much * state has been allocated while evaluating * the script, so that it can be freed @@ -5219,7 +5219,7 @@ TclEvalEx( */ Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( - "\n (expanding word %d)", objectsUsed)); + "\n (expanding word %" TCL_Z_MODIFIER "u)", objectsUsed)); Tcl_DecrRefCount(objv[objectsUsed]); break; } @@ -5697,7 +5697,7 @@ TclArgumentBCEnter( * housekeeping, and can escape now. */ - if (ePtr->nline != objc) { + if (ePtr->nline != (size_t)objc) { return; } diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 3095e72..016981d 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -692,9 +692,9 @@ static void StartExpanding(CompileEnv *envPtr); * TIP #280: Helper for building the per-word line information of all compiled * commands. */ -static void EnterCmdWordData(ExtCmdLoc *eclPtr, int srcOffset, +static void EnterCmdWordData(ExtCmdLoc *eclPtr, size_t srcOffset, Tcl_Token *tokenPtr, const char *cmd, - int numWords, int line, int *clNext, int **lines, + size_t numWords, int line, int *clNext, int **lines, CompileEnv *envPtr); static void ReleaseCmdWordData(ExtCmdLoc *eclPtr); @@ -1449,8 +1449,8 @@ TclInitCompileEnv( envPtr->mallocedCodeArray = 0; envPtr->literalArrayPtr = envPtr->staticLiteralSpace; - envPtr->literalArrayNext1 = 0; - envPtr->literalArrayEnd1 = COMPILEENV_INIT_NUM_OBJECTS; + envPtr->literalArrayNext = 0; + envPtr->literalArrayEnd = COMPILEENV_INIT_NUM_OBJECTS; envPtr->mallocedLiteralArray = 0; envPtr->exceptArrayPtr = envPtr->staticExceptArraySpace; @@ -1544,7 +1544,7 @@ TclInitCompileEnv( pc = 1; } - if ((ctxPtr->nline <= word) || (ctxPtr->line[word] < 0)) { + if ((ctxPtr->nline <= (size_t)word) || (ctxPtr->line[word] < 0)) { /* * Word is not a literal, relative counting. */ @@ -1642,7 +1642,7 @@ TclFreeCompileEnv( LiteralEntry *entryPtr = envPtr->literalArrayPtr; AuxData *auxDataPtr = envPtr->auxDataArrayPtr; - for (i = 0; i < envPtr->literalArrayNext1; i++) { + for (i = 0; i < envPtr->literalArrayNext; i++) { TclReleaseLiteral((Tcl_Interp *)envPtr->iPtr, entryPtr->objPtr); entryPtr++; } @@ -2769,7 +2769,7 @@ PreventCycle( { size_t i; - for (i = 0; i < envPtr->literalArrayNext1; i++) { + for (i = 0; i < envPtr->literalArrayNext; i++) { if (objPtr == TclFetchLiteral(envPtr, i)) { /* * Prevent circular reference where the bytecode internalrep of @@ -2806,7 +2806,7 @@ TclInitByteCode( #ifdef TCL_COMPILE_DEBUG unsigned char *nextPtr; #endif - int numLitObjects = envPtr->literalArrayNext1; + int numLitObjects = envPtr->literalArrayNext; Namespace *namespacePtr; int i, isNew; Interp *iPtr; @@ -2818,7 +2818,7 @@ TclInitByteCode( iPtr = envPtr->iPtr; codeBytes = envPtr->codeNext - envPtr->codeStart; - objArrayBytes = envPtr->literalArrayNext1 * sizeof(Tcl_Obj *); + objArrayBytes = envPtr->literalArrayNext * sizeof(Tcl_Obj *); exceptArrayBytes = envPtr->exceptArrayNext * sizeof(ExceptionRange); auxDataArrayBytes = envPtr->auxDataArrayNext1 * sizeof(AuxData); cmdLocBytes = GetCmdLocEncodingSize(envPtr); @@ -3283,10 +3283,10 @@ EnterCmdWordData( ExtCmdLoc *eclPtr, /* Points to the map environment structure in * which to enter command location * information. */ - int srcOffset, /* Offset of first char of the command. */ + size_t srcOffset, /* Offset of first char of the command. */ Tcl_Token *tokenPtr, const char *cmd, - int numWords, + size_t numWords, int line, int *clNext, int **wlines, @@ -3294,7 +3294,8 @@ EnterCmdWordData( { ECL *ePtr; const char *last; - int wordIdx, wordLine, *wwlines, *wordNext; + size_t wordIdx; + int wordLine, *wwlines, *wordNext; if (eclPtr->nuloc >= eclPtr->nloc) { /* @@ -3369,7 +3370,7 @@ TclCreateExceptRange( ExceptionAux *auxPtr; size_t index = envPtr->exceptArrayNext; - if (index >= (size_t)envPtr->exceptArrayEnd) { + if (index >= envPtr->exceptArrayEnd) { /* * Expand the ExceptionRange array. The currently allocated entries * are stored between elements 0 and (envPtr->exceptArrayNext - 1) @@ -3379,7 +3380,7 @@ TclCreateExceptRange( size_t currBytes = envPtr->exceptArrayNext * sizeof(ExceptionRange); size_t currBytes2 = envPtr->exceptArrayNext * sizeof(ExceptionAux); - int newElems = 2*envPtr->exceptArrayEnd; + size_t newElems = 2*envPtr->exceptArrayEnd; size_t newBytes = newElems * sizeof(ExceptionRange); size_t newBytes2 = newElems * sizeof(ExceptionAux); diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 4c55065..700e3cf 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -182,7 +182,7 @@ typedef struct { typedef struct { size_t srcOffset; /* Command location to find the entry. */ - int nline; /* Number of words in the command */ + size_t nline; /* Number of words in the command */ int *line; /* Line information for all words in the * command. */ int **next; /* Transient information used by the compiler @@ -322,8 +322,8 @@ typedef struct CompileEnv { #endif LiteralEntry *literalArrayPtr; /* Points to start of LiteralEntry array. */ - size_t literalArrayNext1; /* Index of next free object array entry. */ - size_t literalArrayEnd1; /* Index just after last obj array entry. */ + size_t literalArrayNext; /* Index of next free object array entry. */ + size_t literalArrayEnd; /* Index just after last obj array entry. */ int mallocedLiteralArray; /* 1 if object array was expanded and objArray * points into the heap, else 0. */ ExceptionRange *exceptArrayPtr; @@ -333,7 +333,7 @@ typedef struct CompileEnv { * exceptArrayNext is the number of ranges and * (exceptArrayNext-1) is the index of the * current range's array entry. */ - int exceptArrayEnd; /* Index after the last ExceptionRange array + size_t exceptArrayEnd; /* Index after the last ExceptionRange array * entry. */ #if TCL_MAJOR_VERSION < 9 int mallocedExceptArray; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index d920f2d..ab20c3e 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1680,7 +1680,7 @@ TclCompileObj( } } - if (word < ctxCopyPtr->nline) { + if ((size_t)word < ctxCopyPtr->nline) { /* * Note: We do not care if the line[word] is -1. This is a * difference and requires a recompile (location changed from diff --git a/generic/tclInt.h b/generic/tclInt.h index 5e8980a..a7e9823 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1208,7 +1208,7 @@ typedef struct CmdFrame { int level; /* Number of frames in stack, prevent O(n) * scan of list. */ int *line; /* Lines the words of the command start on. */ - int nline; + size_t nline; CallFrame *framePtr; /* Procedure activation record, may be * NULL. */ struct CmdFrame *nextPtr; /* Link to calling frame. */ diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 86dcdb2..dfb92cb 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -354,7 +354,7 @@ TclFetchLiteral( size_t index) /* Index of the desired literal, as returned * by prior call to TclRegisterLiteral() */ { - if (index >= envPtr->literalArrayNext1) { + if (index >= envPtr->literalArrayNext) { return NULL; } return envPtr->literalArrayPtr[index].objPtr; @@ -619,11 +619,11 @@ TclAddLiteralObj( LiteralEntry *lPtr; size_t objIndex; - if (envPtr->literalArrayNext1 >= envPtr->literalArrayEnd1) { + if (envPtr->literalArrayNext >= envPtr->literalArrayEnd) { ExpandLocalLiteralArray(envPtr); } - objIndex = envPtr->literalArrayNext1; - envPtr->literalArrayNext1++; + objIndex = envPtr->literalArrayNext; + envPtr->literalArrayNext++; lPtr = &envPtr->literalArrayPtr[objIndex]; lPtr->objPtr = objPtr; @@ -745,7 +745,7 @@ ExpandLocalLiteralArray( */ LiteralTable *localTablePtr = &envPtr->localLitTable; - size_t currElems = envPtr->literalArrayNext1; + size_t currElems = envPtr->literalArrayNext; size_t currBytes = (currElems * sizeof(LiteralEntry)); LiteralEntry *currArrayPtr = envPtr->literalArrayPtr; LiteralEntry *newArrayPtr; @@ -790,7 +790,7 @@ ExpandLocalLiteralArray( } envPtr->literalArrayPtr = newArrayPtr; - envPtr->literalArrayEnd1 = newSize / sizeof(LiteralEntry); + envPtr->literalArrayEnd = newSize / sizeof(LiteralEntry); } /* -- cgit v0.12