diff options
Diffstat (limited to 'generic/tclEnsemble.c')
-rw-r--r-- | generic/tclEnsemble.c | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 6ff5df4..c8cffa2 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -188,7 +188,8 @@ TclNamespaceEnsembleCmd( switch (index) { case ENS_CREATE: { const char *name; - int len, allocatedMapFlag = 0; + size_t len; + int allocatedMapFlag = 0; /* * Defaults */ @@ -501,7 +502,8 @@ TclNamespaceEnsembleCmd( Tcl_SetObjResult(interp, resultObj); } else { - int len, allocatedMapFlag = 0; + size_t len; + int allocatedMapFlag = 0; Tcl_Obj *subcmdObj = NULL, *mapObj = NULL, *paramObj = NULL, *unknownObj = NULL; /* Defaults, silence gcc 4 warnings */ int permitPrefix, flags = 0; /* silence gcc 4 warning */ @@ -792,7 +794,7 @@ Tcl_SetEnsembleSubcommandList( return TCL_ERROR; } if (subcmdList != NULL) { - int length; + size_t length; if (TclListObjLength(interp, subcmdList, &length) != TCL_OK) { return TCL_ERROR; @@ -859,7 +861,7 @@ Tcl_SetEnsembleParameterList( Command *cmdPtr = (Command *) token; EnsembleConfig *ensemblePtr; Tcl_Obj *oldList; - int length; + size_t length; if (cmdPtr->objProc != TclEnsembleImplementationCmd) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -944,7 +946,8 @@ Tcl_SetEnsembleMappingDict( return TCL_ERROR; } if (mapDict != NULL) { - int size, done; + size_t size; + int done; Tcl_DictSearch search; Tcl_Obj *valuePtr; @@ -1043,7 +1046,7 @@ Tcl_SetEnsembleUnknownHandler( return TCL_ERROR; } if (unknownList != NULL) { - int length; + size_t length; if (TclListObjLength(interp, unknownList, &length) != TCL_OK) { return TCL_ERROR; @@ -1527,7 +1530,8 @@ TclMakeEnsemble( Tcl_DString buf, hiddenBuf; const char **nameParts = NULL; const char *cmdName = NULL; - int i, nameCount = 0, ensembleFlags = 0, hiddenLen; + size_t i, nameCount = 0; + int ensembleFlags = 0, hiddenLen; /* * Construct the path for the ensemble namespace and create it. @@ -1886,7 +1890,7 @@ NsEnsembleImplementationCmdNR( Tcl_Obj *copyPtr; /* The list of words to dispatch on. * Will be freed by the dispatch engine. */ Tcl_Obj **copyObjv; - int copyObjc, prefixObjc; + size_t copyObjc, prefixObjc; TclListObjLength(NULL, prefixObj, &prefixObjc); @@ -2106,7 +2110,7 @@ void TclSpellFix( Tcl_Interp *interp, Tcl_Obj *const *objv, - int objc, + size_t objc, size_t badIdx, Tcl_Obj *bad, Tcl_Obj *fix) @@ -2231,8 +2235,8 @@ Tcl_Obj *const * TclFetchEnsembleRoot( Tcl_Interp *interp, Tcl_Obj *const *objv, - int objc, - int *objcPtr) + size_t objc, + size_t *objcPtr) { Tcl_Obj *const *sourceObjs; Interp *iPtr = (Interp *) interp; @@ -2282,7 +2286,9 @@ EnsembleUnknownCallback( Tcl_Obj *const objv[], Tcl_Obj **prefixObjPtr) { - int paramc, i, result, prefixObjc; + size_t paramc; + int result; + size_t i, prefixObjc; Tcl_Obj **paramv, *unknownCmd, *ensObj; /* @@ -2293,7 +2299,7 @@ EnsembleUnknownCallback( TclNewObj(ensObj); Tcl_GetCommandFullName(interp, ensemblePtr->token, ensObj); Tcl_ListObjAppendElement(NULL, unknownCmd, ensObj); - for (i=1 ; i<objc ; i++) { + for (i = 1 ; i < (size_t)objc ; i++) { Tcl_ListObjAppendElement(NULL, unknownCmd, objv[i]); } TclListObjGetElements(NULL, unknownCmd, ¶mc, ¶mv); @@ -2581,7 +2587,7 @@ BuildEnsembleConfig( Tcl_InitHashTable(hash, TCL_STRING_KEYS); if (subList) { - int subc; + size_t subc; Tcl_Obj **subv, *target, *cmdObj, *cmdPrefixObj; const char *name; @@ -2597,7 +2603,7 @@ BuildEnsembleConfig( * as the dict mapping to targets. */ - for (i = 0; i < (size_t)subc; i += 2) { + for (i = 0; i < subc; i += 2) { name = TclGetString(subv[i]); hPtr = Tcl_CreateHashEntry(hash, name, &isNew); if (!isNew) { @@ -2621,7 +2627,7 @@ BuildEnsembleConfig( * Usual case where we can freely act on the list and dict. */ - for (i = 0; i < (size_t)subc; i++) { + for (i = 0; i < subc; i++) { name = TclGetString(subv[i]); hPtr = Tcl_CreateHashEntry(hash, name, &isNew); if (!isNew) { @@ -2911,14 +2917,14 @@ TclCompileEnsemble( Tcl_Obj *replaced, *replacement; Tcl_Command ensemble = (Tcl_Command) cmdPtr; Command *oldCmdPtr = cmdPtr, *newCmdPtr; - int len, result, flags = 0, i, depth = 1, invokeAnyway = 0; + int result, flags = 0, depth = 1, invokeAnyway = 0; int ourResult = TCL_ERROR; - size_t numBytes; + size_t i, len, numBytes; const char *word; TclNewObj(replaced); Tcl_IncrRefCount(replaced); - if (parsePtr->numWords < depth + 1) { + if ((int)parsePtr->numWords <= depth) { goto failed; } if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { @@ -3145,7 +3151,7 @@ TclCompileEnsemble( if (cmdPtr->compileProc == TclCompileEnsemble) { tokenPtr = TokenAfter(tokenPtr); - if (parsePtr->numWords < depth + 1 + if ((int)parsePtr->numWords < depth + 1 || tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { /* * Too hard because the user has done something unpleasant like @@ -3178,7 +3184,7 @@ TclCompileEnsemble( * Throw out any line information generated by the failed compile attempt. */ - while (mapPtr->nuloc - 1 > eclIndex) { + while (mapPtr->nuloc > eclIndex + 1) { mapPtr->nuloc--; Tcl_Free(mapPtr->loc[mapPtr->nuloc].line); mapPtr->loc[mapPtr->nuloc].line = NULL; @@ -3240,19 +3246,20 @@ int TclAttemptCompileProc( Tcl_Interp *interp, Tcl_Parse *parsePtr, - int depth, + size_t depth, Command *cmdPtr, CompileEnv *envPtr) /* Holds resulting instructions. */ { DefineLineInformation; - int result, i; + int result; + size_t i; Tcl_Token *saveTokenPtr = parsePtr->tokenPtr; - int savedStackDepth = envPtr->currStackDepth; + size_t savedStackDepth = envPtr->currStackDepth; unsigned savedCodeNext = envPtr->codeNext - envPtr->codeStart; - int savedAuxDataArrayNext = envPtr->auxDataArrayNext; - int savedExceptArrayNext = envPtr->exceptArrayNext; + size_t savedAuxDataArrayNext = envPtr->auxDataArrayNext1; + size_t savedExceptArrayNext = envPtr->exceptArrayNext; #ifdef TCL_COMPILE_DEBUG - int savedExceptDepth = envPtr->exceptDepth; + size_t savedExceptDepth = envPtr->exceptDepth; #endif if (cmdPtr->compileProc == NULL) { @@ -3311,12 +3318,12 @@ TclAttemptCompileProc( ExceptionAux *auxPtr = envPtr->exceptAuxArrayPtr; for (i = 0; i < savedExceptArrayNext; i++) { - while (auxPtr->numBreakTargets > 0 + while ((int)auxPtr->numBreakTargets > 0 && auxPtr->breakTargets[auxPtr->numBreakTargets - 1] >= savedCodeNext) { auxPtr->numBreakTargets--; } - while (auxPtr->numContinueTargets > 0 + while ((int)auxPtr->numContinueTargets > 0 && auxPtr->continueTargets[auxPtr->numContinueTargets - 1] >= savedCodeNext) { auxPtr->numContinueTargets--; @@ -3325,12 +3332,12 @@ TclAttemptCompileProc( } envPtr->exceptArrayNext = savedExceptArrayNext; - if (savedAuxDataArrayNext != envPtr->auxDataArrayNext) { + if (savedAuxDataArrayNext != envPtr->auxDataArrayNext1) { AuxData *auxDataPtr = envPtr->auxDataArrayPtr; AuxData *auxDataEnd = auxDataPtr; auxDataPtr += savedAuxDataArrayNext; - auxDataEnd += envPtr->auxDataArrayNext; + auxDataEnd += envPtr->auxDataArrayNext1; while (auxDataPtr < auxDataEnd) { if (auxDataPtr->type->freeProc != NULL) { @@ -3338,7 +3345,7 @@ TclAttemptCompileProc( } auxDataPtr++; } - envPtr->auxDataArrayNext = savedAuxDataArrayNext; + envPtr->auxDataArrayNext1 = savedAuxDataArrayNext; } envPtr->currStackDepth = savedStackDepth; envPtr->codeNext = envPtr->codeStart + savedCodeNext; @@ -3381,8 +3388,8 @@ CompileToInvokedCommand( Tcl_Token *tokPtr; Tcl_Obj *objPtr, **words; const char *bytes; - int i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME; - size_t length; + int cmdLit, extraLiteralFlags = LITERAL_CMD_NAME; + size_t i, numWords, length; /* * Push the words of the command. Take care; the command words may be @@ -3393,7 +3400,7 @@ CompileToInvokedCommand( TclListObjGetElements(NULL, replacements, &numWords, &words); for (i = 0, tokPtr = parsePtr->tokenPtr; i < parsePtr->numWords; i++, tokPtr = TokenAfter(tokPtr)) { - if (i > 0 && i < numWords+1) { + if (i > 0 && i <= numWords) { bytes = Tcl_GetStringFromObj(words[i-1], &length); PushLiteral(envPtr, bytes, length); continue; @@ -3684,7 +3691,7 @@ TclCompileBasicMin0ArgCmd( * which is the only code that sees the shenanigans of ensemble dispatch. */ - if (parsePtr->numWords < 1) { + if ((int)parsePtr->numWords < 1) { return TCL_ERROR; } @@ -3706,7 +3713,7 @@ TclCompileBasicMin1ArgCmd( * which is the only code that sees the shenanigans of ensemble dispatch. */ - if (parsePtr->numWords < 2) { + if ((int)parsePtr->numWords < 2) { return TCL_ERROR; } @@ -3728,7 +3735,7 @@ TclCompileBasicMin2ArgCmd( * which is the only code that sees the shenanigans of ensemble dispatch. */ - if (parsePtr->numWords < 3) { + if ((int)parsePtr->numWords < 3) { return TCL_ERROR; } |