From 875e3b392ba9b930fa009077b451b08f15b4ea72 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Jan 2022 15:23:21 +0000 Subject: change signature for Tcl_DictObjPutKeyList and Tcl_DictObjRemoveKeyList too --- generic/tcl.decls | 4 ++-- generic/tclCmdMZ.c | 48 ++++++++++++++++++++++++++---------------------- generic/tclCompCmdsGR.c | 5 +++-- generic/tclConfig.c | 6 +++--- generic/tclDecls.h | 8 ++++---- generic/tclDictObj.c | 37 ++++++++++++++++++++----------------- generic/tclEnsemble.c | 13 +++++++------ generic/tclExecute.c | 26 +++++++++++++++----------- generic/tclInt.decls | 2 +- generic/tclIntDecls.h | 4 ++-- generic/tclVar.c | 35 ++++++++++++++++++++--------------- generic/tclZipfs.c | 6 +++--- generic/tclZlib.c | 17 +++++++++-------- 13 files changed, 115 insertions(+), 96 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index 9b572ff..6a969d7 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1857,11 +1857,11 @@ declare 500 { } declare 501 { int Tcl_DictObjPutKeyList(Tcl_Interp *interp, Tcl_Obj *dictPtr, - int keyc, Tcl_Obj *const *keyv, Tcl_Obj *valuePtr) + size_t keyc, Tcl_Obj *const *keyv, Tcl_Obj *valuePtr) } declare 502 { int Tcl_DictObjRemoveKeyList(Tcl_Interp *interp, Tcl_Obj *dictPtr, - int keyc, Tcl_Obj *const *keyv) + size_t keyc, Tcl_Obj *const *keyv) } declare 503 { Tcl_Obj *Tcl_NewDictObj(void) diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 573d653..6ef3220 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -487,8 +487,8 @@ Tcl_RegsubObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int result, cflags, all, match, command, numParts; - size_t idx, wlen, wsublen = 0, offset, numMatches; + int result, cflags, all, match, command; + size_t idx, wlen, wsublen = 0, offset, numMatches, numParts; size_t start, end, subStart, subEnd; Tcl_RegExp regExpr; Tcl_RegExpInfo info; @@ -675,7 +675,7 @@ Tcl_RegsubObjCmd( * object. (If they aren't, that's cheap to do.) */ - if (TclListObjLength_(interp, objv[2], &numParts) != TCL_OK) { + if (Tcl_ListObjLength(interp, objv[2], &numParts) != TCL_OK) { return TCL_ERROR; } if (numParts < 1) { @@ -775,9 +775,9 @@ Tcl_RegsubObjCmd( if (command) { Tcl_Obj **args = NULL, **parts; - int numArgs; + size_t numArgs; - TclListObjGetElements_(interp, subPtr, &numParts, &parts); + Tcl_ListObjGetElements(interp, subPtr, &numParts, &parts); numArgs = numParts + info.nsubs + 1; args = (Tcl_Obj **)Tcl_Alloc(sizeof(Tcl_Obj*) * numArgs); memcpy(args, parts, sizeof(Tcl_Obj*) * numParts); @@ -1631,9 +1631,10 @@ StringIsCmd( chcomp = Tcl_UniCharIsControl; break; case STR_IS_DICT: { - int dresult, dsize; + int dresult; + size_t dsize; - dresult = TclDictObjSize_(interp, objPtr, &dsize); + dresult = Tcl_DictObjSize(interp, objPtr, &dsize); Tcl_ResetResult(interp); result = (dresult == TCL_OK) ? 1 : 0; if (dresult != TCL_OK && failVarObj != NULL) { @@ -1994,7 +1995,8 @@ StringMapCmd( if (!TclHasStringRep(objv[objc-2]) && TclHasInternalRep(objv[objc-2], &tclDictType)) { - int i, done; + size_t i; + int done; Tcl_DictSearch search; /* @@ -2002,7 +2004,7 @@ StringMapCmd( * sure. This shortens this code quite a bit. */ - TclDictObjSize_(interp, objv[objc-2], &i); + Tcl_DictObjSize(interp, objv[objc-2], &i); if (i == 0) { /* * Empty charMap, just return whatever string was given. @@ -2028,8 +2030,8 @@ StringMapCmd( } Tcl_DictObjDone(&search); } else { - int i; - if (TclListObjGetElements_(interp, objv[objc-2], &i, + size_t i; + if (Tcl_ListObjGetElements(interp, objv[objc-2], &i, &mapElemv) != TCL_OK) { return TCL_ERROR; } @@ -3576,9 +3578,10 @@ TclNRSwitchObjCmd( splitObjs = 0; if (objc == 1) { Tcl_Obj **listv; + size_t listc; blist = objv[0]; - if (TclListObjGetElements_(interp, objv[0], &objc, &listv) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[0], &listc, &listv) != TCL_OK) { return TCL_ERROR; } @@ -3586,11 +3589,12 @@ TclNRSwitchObjCmd( * Ensure that the list is non-empty. */ - if (objc < 1) { + if (listc < 1 || listc > INT_MAX) { Tcl_WrongNumArgs(interp, 1, savedObjv, "?-option ...? string {?pattern body ...? ?default body?}"); return TCL_ERROR; } + objc = listc; objv = listv; splitObjs = 1; } @@ -4865,8 +4869,8 @@ TryPostBody( int result) { Tcl_Obj *resultObj, *options, *handlersObj, *finallyObj, *cmdObj, **objv; - int i, code, objc; - int numHandlers = 0; + int code, objc; + size_t i, numHandlers = 0; handlersObj = (Tcl_Obj *)data[0]; finallyObj = (Tcl_Obj *)data[1]; @@ -4913,12 +4917,12 @@ TryPostBody( int found = 0; Tcl_Obj **handlers, **info; - TclListObjGetElements_(NULL, handlersObj, &numHandlers, &handlers); + Tcl_ListObjGetElements(NULL, handlersObj, &numHandlers, &handlers); for (i=0 ; i 0) { Tcl_Obj *varName; diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 46d39be..bb1c21b 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -2399,7 +2399,8 @@ TclCompileReturnCmd( * General syntax: [return ?-option value ...? ?result?] * An even number of words means an explicit result argument is present. */ - int level, code, objc, size, status = TCL_OK; + int level, code, objc, status = TCL_OK; + size_t size; int numWords = parsePtr->numWords; int explicitResult = (0 == (numWords % 2)); int numOptionWords = numWords - 1 - explicitResult; @@ -2529,7 +2530,7 @@ TclCompileReturnCmd( } /* Optimize [return -level 0 $x]. */ - TclDictObjSize_(NULL, returnOpts, &size); + Tcl_DictObjSize(NULL, returnOpts, &size); if (size == 0 && level == 0 && code == TCL_OK) { Tcl_DecrRefCount(returnOpts); return TCL_OK; diff --git a/generic/tclConfig.c b/generic/tclConfig.c index 9d41a45..08d5f1b 100644 --- a/generic/tclConfig.c +++ b/generic/tclConfig.c @@ -199,8 +199,8 @@ QueryConfigObjCmd( QCCD *cdPtr = (QCCD *)clientData; Tcl_Obj *pkgName = cdPtr->pkg; Tcl_Obj *pDB, *pkgDict, *val, *listPtr; - size_t n = 0; - int index, m; + size_t m, n = 0; + int index; static const char *const subcmdStrings[] = { "get", "list", NULL }; @@ -272,7 +272,7 @@ QueryConfigObjCmd( return TCL_ERROR; } - TclDictObjSize_(interp, pkgDict, &m); + Tcl_DictObjSize(interp, pkgDict, &m); listPtr = Tcl_NewListObj(m, NULL); if (!listPtr) { diff --git a/generic/tclDecls.h b/generic/tclDecls.h index d354969..e83a8de 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1308,11 +1308,11 @@ EXTERN void Tcl_DictObjNext(Tcl_DictSearch *searchPtr, EXTERN void Tcl_DictObjDone(Tcl_DictSearch *searchPtr); /* 501 */ EXTERN int Tcl_DictObjPutKeyList(Tcl_Interp *interp, - Tcl_Obj *dictPtr, int keyc, + Tcl_Obj *dictPtr, size_t keyc, Tcl_Obj *const *keyv, Tcl_Obj *valuePtr); /* 502 */ EXTERN int Tcl_DictObjRemoveKeyList(Tcl_Interp *interp, - Tcl_Obj *dictPtr, int keyc, + Tcl_Obj *dictPtr, size_t keyc, Tcl_Obj *const *keyv); /* 503 */ EXTERN Tcl_Obj * Tcl_NewDictObj(void); @@ -2279,8 +2279,8 @@ typedef struct TclStubs { int (*tcl_DictObjFirst) (Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_DictSearch *searchPtr, Tcl_Obj **keyPtrPtr, Tcl_Obj **valuePtrPtr, int *donePtr); /* 498 */ void (*tcl_DictObjNext) (Tcl_DictSearch *searchPtr, Tcl_Obj **keyPtrPtr, Tcl_Obj **valuePtrPtr, int *donePtr); /* 499 */ void (*tcl_DictObjDone) (Tcl_DictSearch *searchPtr); /* 500 */ - int (*tcl_DictObjPutKeyList) (Tcl_Interp *interp, Tcl_Obj *dictPtr, int keyc, Tcl_Obj *const *keyv, Tcl_Obj *valuePtr); /* 501 */ - int (*tcl_DictObjRemoveKeyList) (Tcl_Interp *interp, Tcl_Obj *dictPtr, int keyc, Tcl_Obj *const *keyv); /* 502 */ + int (*tcl_DictObjPutKeyList) (Tcl_Interp *interp, Tcl_Obj *dictPtr, size_t keyc, Tcl_Obj *const *keyv, Tcl_Obj *valuePtr); /* 501 */ + int (*tcl_DictObjRemoveKeyList) (Tcl_Interp *interp, Tcl_Obj *dictPtr, size_t keyc, Tcl_Obj *const *keyv); /* 502 */ Tcl_Obj * (*tcl_NewDictObj) (void); /* 503 */ Tcl_Obj * (*tcl_DbNewDictObj) (const char *file, int line); /* 504 */ void (*tcl_RegisterConfig) (Tcl_Interp *interp, const char *pkgName, const Tcl_Config *configuration, const char *valEncoding); /* 505 */ diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index a124a32..1e1d1eb 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -602,11 +602,11 @@ SetDictFromAny( */ if (TclHasInternalRep(objPtr, &tclListType)) { - int objc, i; + size_t objc, i; Tcl_Obj **objv; /* Cannot fail, we already know the Tcl_ObjType is "list". */ - TclListObjGetElements_(NULL, objPtr, &objc, &objv); + Tcl_ListObjGetElements(NULL, objPtr, &objc, &objv); if (objc & 1) { goto missingValue; } @@ -777,12 +777,12 @@ Tcl_Obj * TclTraceDictPath( Tcl_Interp *interp, Tcl_Obj *dictPtr, - int keyc, + size_t keyc, Tcl_Obj *const keyv[], int flags) { Dict *dict, *newDict; - int i; + size_t i; DictGetInternalRep(dictPtr, dict); if (dict == NULL) { @@ -1278,7 +1278,7 @@ int Tcl_DictObjPutKeyList( Tcl_Interp *interp, Tcl_Obj *dictPtr, - int keyc, + size_t keyc, Tcl_Obj *const keyv[], Tcl_Obj *valuePtr) { @@ -1289,7 +1289,7 @@ Tcl_DictObjPutKeyList( if (Tcl_IsShared(dictPtr)) { Tcl_Panic("%s called with shared object", "Tcl_DictObjPutKeyList"); } - if (keyc < 1) { + if (keyc + 1 < 2) { Tcl_Panic("%s called with empty key list", "Tcl_DictObjPutKeyList"); } @@ -1339,7 +1339,7 @@ int Tcl_DictObjRemoveKeyList( Tcl_Interp *interp, Tcl_Obj *dictPtr, - int keyc, + size_t keyc, Tcl_Obj *const keyv[]) { Dict *dict; @@ -2460,7 +2460,8 @@ DictForNRCmd( Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj; Tcl_Obj **varv, *keyObj, *valueObj; Tcl_DictSearch *searchPtr; - int varc, done; + size_t varc; + int done; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -2472,7 +2473,7 @@ DictForNRCmd( * Parse arguments. */ - if (TclListObjGetElements_(interp, objv[1], &varc, &varv) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[1], &varc, &varv) != TCL_OK) { return TCL_ERROR; } if (varc != 2) { @@ -2491,7 +2492,7 @@ DictForNRCmd( TclStackFree(interp, searchPtr); return TCL_OK; } - TclListObjGetElements_(NULL, objv[1], &varc, &varv); + Tcl_ListObjGetElements(NULL, objv[1], &varc, &varv); keyVarObj = varv[0]; valueVarObj = varv[1]; scriptObj = objv[3]; @@ -2654,7 +2655,8 @@ DictMapNRCmd( Interp *iPtr = (Interp *) interp; Tcl_Obj **varv, *keyObj, *valueObj; DictMapStorage *storagePtr; - int varc, done; + size_t varc; + int done; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -2666,7 +2668,7 @@ DictMapNRCmd( * Parse arguments. */ - if (TclListObjGetElements_(interp, objv[1], &varc, &varv) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[1], &varc, &varv) != TCL_OK) { return TCL_ERROR; } if (varc != 2) { @@ -2692,7 +2694,7 @@ DictMapNRCmd( return TCL_OK; } TclNewObj(storagePtr->accumulatorObj); - TclListObjGetElements_(NULL, objv[1], &varc, &varv); + Tcl_ListObjGetElements(NULL, objv[1], &varc, &varv); storagePtr->keyVarObj = varv[0]; storagePtr->valueVarObj = varv[1]; storagePtr->scriptObj = objv[3]; @@ -2992,7 +2994,8 @@ DictFilterCmd( Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj; Tcl_Obj **varv, *keyObj = NULL, *valueObj = NULL, *resultObj, *boolObj; Tcl_DictSearch search; - int index, varc, done, result, satisfied; + int index, done, result, satisfied; + size_t varc; const char *pattern; if (objc < 3) { @@ -3105,7 +3108,7 @@ DictFilterCmd( * copying from the "dict for" implementation has occurred! */ - if (TclListObjGetElements_(interp, objv[3], &varc, &varv) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[3], &varc, &varv) != TCL_OK) { return TCL_ERROR; } if (varc != 2) { @@ -3473,7 +3476,7 @@ FinalizeDictWith( int result) { Tcl_Obj **pathv; - int pathc; + size_t pathc; Tcl_InterpState state; Tcl_Obj *varName = (Tcl_Obj *)data[0]; Tcl_Obj *keysPtr = (Tcl_Obj *)data[1]; @@ -3491,7 +3494,7 @@ FinalizeDictWith( state = Tcl_SaveInterpState(interp, result); if (pathPtr != NULL) { - TclListObjGetElements_(NULL, pathPtr, &pathc, &pathv); + Tcl_ListObjGetElements(NULL, pathPtr, &pathc, &pathv); } else { pathc = 0; pathv = NULL; diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 49ac9af..4131651 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -940,11 +940,12 @@ Tcl_SetEnsembleMappingDict( return TCL_ERROR; } if (mapDict != NULL) { - int size, done; + size_t size; + int done; Tcl_DictSearch search; Tcl_Obj *valuePtr; - if (TclDictObjSize_(interp, mapDict, &size) != TCL_OK) { + if (Tcl_DictObjSize(interp, mapDict, &size) != TCL_OK) { return TCL_ERROR; } @@ -3377,8 +3378,8 @@ CompileToInvokedCommand( Tcl_Token *tokPtr; Tcl_Obj *objPtr, **words; const char *bytes; - int i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME; - size_t length; + int i, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME; + size_t numWords, length; /* * Push the words of the command. Take care; the command words may be @@ -3386,10 +3387,10 @@ CompileToInvokedCommand( * difference. Hence the call to TclContinuationsEnterDerived... */ - TclListObjGetElements_(NULL, replacements, &numWords, &words); + Tcl_ListObjGetElements(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 && (size_t)i <= numWords) { bytes = Tcl_GetStringFromObj(words[i-1], &length); PushLiteral(envPtr, bytes, length); continue; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 3691b28..e0ac6336 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2049,7 +2049,8 @@ TEBCresume( Tcl_Obj *objPtr, *valuePtr, *value2Ptr, *part1Ptr, *part2Ptr, *tmpPtr; Tcl_Obj **objv = NULL; int objc = 0; - int opnd, length, pcAdjustment; + int opnd, pcAdjustment; + size_t length; Var *varPtr, *arrayPtr; #ifdef TCL_COMPILE_DEBUG char cmdNameBuf[21]; @@ -4636,7 +4637,7 @@ TEBCresume( case INST_LIST_LENGTH: TRACE(("\"%.30s\" => ", O2S(OBJ_AT_TOS))); - if (TclListObjLength_(interp, OBJ_AT_TOS, &length) != TCL_OK) { + if (Tcl_ListObjLength(interp, OBJ_AT_TOS, &length) != TCL_OK) { TRACE_ERROR(interp); goto gotError; } @@ -4902,13 +4903,13 @@ TEBCresume( s1 = Tcl_GetStringFromObj(valuePtr, &s1len); TRACE(("\"%.30s\" \"%.30s\" => ", O2S(valuePtr), O2S(value2Ptr))); - if (TclListObjLength_(interp, value2Ptr, &length) != TCL_OK) { + if (Tcl_ListObjLength(interp, value2Ptr, &length) != TCL_OK) { TRACE_ERROR(interp); goto gotError; } match = 0; if (length > 0) { - int i = 0; + size_t i = 0; Tcl_Obj *o; /* @@ -6483,22 +6484,25 @@ TEBCresume( */ { - int opnd2, allocateDict, done, i, allocdict; + int opnd2, allocateDict, done, allocdict; + size_t i; Tcl_Obj *dictPtr, *statePtr, *keyPtr, *listPtr, *varNamePtr, *keysPtr; Tcl_Obj *emptyPtr, **keyPtrPtr; Tcl_DictSearch *searchPtr; DictUpdateInfo *duiPtr; - case INST_DICT_VERIFY: + case INST_DICT_VERIFY: { + size_t size; dictPtr = OBJ_AT_TOS; TRACE(("\"%.30s\" => ", O2S(dictPtr))); - if (TclDictObjSize_(interp, dictPtr, &done) != TCL_OK) { + if (Tcl_DictObjSize(interp, dictPtr, &size) != TCL_OK) { TRACE_APPEND(("ERROR verifying dictionary nature of \"%.30s\": %s\n", O2S(dictPtr), O2S(Tcl_GetObjResult(interp)))); goto gotError; } TRACE_APPEND(("OK\n")); NEXT_INST_F(1, 1, 0); + } break; case INST_DICT_EXISTS: { @@ -6937,12 +6941,12 @@ TEBCresume( } } Tcl_IncrRefCount(dictPtr); - if (TclListObjGetElements_(interp, OBJ_AT_TOS, &length, + if (Tcl_ListObjGetElements(interp, OBJ_AT_TOS, &length, &keyPtrPtr) != TCL_OK) { TRACE_ERROR(interp); goto gotError; } - if ((size_t)length != duiPtr->length) { + if (length != duiPtr->length) { Tcl_Panic("dictUpdateStart argument length mismatch"); } for (i=0 ; icurrentInput); zshPtr->currentInput = NULL; } - TclListObjLength_(NULL, zshPtr->inData, &listLen); + Tcl_ListObjLength(NULL, zshPtr->inData, &listLen); if (listLen > 0) { /* * There is more input available, get it from the list and @@ -1422,7 +1422,7 @@ Tcl_ZlibStreamGet( e = inflate(&zshPtr->stream, zshPtr->flush); } }; - TclListObjLength_(NULL, zshPtr->inData, &listLen); + Tcl_ListObjLength(NULL, zshPtr->inData, &listLen); while ((zshPtr->stream.avail_out > 0) && (e == Z_OK || e == Z_BUF_ERROR) && (listLen > 0)) { @@ -1502,7 +1502,7 @@ Tcl_ZlibStreamGet( inflateEnd(&zshPtr->stream); } } else { - TclListObjLength_(NULL, zshPtr->outData, &listLen); + Tcl_ListObjLength(NULL, zshPtr->outData, &listLen); if (count == TCL_INDEX_NONE) { count = 0; for (i=0; i dataPos) && - (TclListObjLength_(NULL, zshPtr->outData, &listLen) == TCL_OK) + (Tcl_ListObjLength(NULL, zshPtr->outData, &listLen) == TCL_OK) && (listLen > 0)) { /* * Get the next chunk off our list of chunks and grab the data out @@ -2409,7 +2409,8 @@ ZlibPushSubcmd( const char *const *pushOptions = pushDecompressOptions; enum pushOptionsEnum {poDictionary, poHeader, poLevel, poLimit}; Tcl_Obj *headerObj = NULL, *compDictObj = NULL; - int limit = DEFAULT_BUFFER_SIZE, dummy; + int limit = DEFAULT_BUFFER_SIZE; + size_t dummy; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, "mode channel ?options...?"); @@ -2492,7 +2493,7 @@ ZlibPushSubcmd( switch ((enum pushOptionsEnum) option) { case poHeader: headerObj = objv[i]; - if (TclDictObjSize_(interp, headerObj, &dummy) != TCL_OK) { + if (Tcl_DictObjSize(interp, headerObj, &dummy) != TCL_OK) { goto genericOptionError; } break; -- cgit v0.12