diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-10-06 09:45:49 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-10-06 09:45:49 (GMT) |
commit | 65254e27f9238b5be5dac497f9267fb484024829 (patch) | |
tree | 0d25d8a9635cbe7ee3116e23902d8a1df121b25c /generic | |
parent | 3cb6c489a3c0515c7b3aade0aaa139e637400559 (diff) | |
parent | 0b94a6293a785dce24805809dbceabca179de113 (diff) | |
download | tcl-65254e27f9238b5be5dac497f9267fb484024829.zip tcl-65254e27f9238b5be5dac497f9267fb484024829.tar.gz tcl-65254e27f9238b5be5dac497f9267fb484024829.tar.bz2 |
Merge 8.6
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclDictObj.c | 81 | ||||
-rw-r--r-- | generic/tclInt.h | 2 | ||||
-rw-r--r-- | generic/tclListObj.c | 7 | ||||
-rw-r--r-- | generic/tclUtil.c | 27 |
4 files changed, 63 insertions, 54 deletions
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index c795030..55664ce 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -129,7 +129,7 @@ typedef struct Dict { * the dictionary. Used for doing traversal of * the entries in the order that they are * created. */ - unsigned int epoch; /* Epoch counter */ + TCL_HASH_TYPE epoch; /* Epoch counter */ size_t refCount; /* Reference counter (see above) */ Tcl_Obj *chain; /* Linked list used for invalidating the * string representations of updated nested @@ -231,7 +231,7 @@ AllocChainEntry( cPtr = (ChainEntry *)ckalloc(sizeof(ChainEntry)); cPtr->entry.key.objPtr = objPtr; Tcl_IncrRefCount(objPtr); - cPtr->entry.clientData = NULL; + Tcl_SetHashValue(&cPtr->entry, NULL); cPtr->prevPtr = cPtr->nextPtr = NULL; return &cPtr->entry; @@ -488,7 +488,8 @@ UpdateStringOfDict( Dict *dict; ChainEntry *cPtr; Tcl_Obj *keyPtr, *valuePtr; - int i, length, bytesNeeded = 0; + int i, length; + TCL_HASH_TYPE bytesNeeded = 0; const char *elem; char *dst; @@ -530,7 +531,7 @@ UpdateStringOfDict( keyPtr = (Tcl_Obj *)Tcl_GetHashKey(&dict->table, &cPtr->entry); elem = TclGetStringFromObj(keyPtr, &length); bytesNeeded += TclScanElement(elem, length, flagPtr+i); - if (bytesNeeded < 0) { + if (bytesNeeded > INT_MAX) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } @@ -538,11 +539,11 @@ UpdateStringOfDict( valuePtr = (Tcl_Obj *)Tcl_GetHashValue(&cPtr->entry); elem = TclGetStringFromObj(valuePtr, &length); bytesNeeded += TclScanElement(elem, length, flagPtr+i+1); - if (bytesNeeded < 0) { + if (bytesNeeded > INT_MAX) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } } - if (bytesNeeded > INT_MAX - numElems + 1) { + if (bytesNeeded + numElems > INT_MAX + 1U) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } bytesNeeded += numElems; @@ -649,7 +650,8 @@ SetDictFromAny( while (nextElem < limit) { Tcl_Obj *keyPtr, *valuePtr; const char *elemStart; - int elemSize, literal; + int elemSize; + int literal; if (TclFindDictElement(interp, nextElem, (limit - nextElem), &elemStart, &nextElem, &elemSize, &literal) != TCL_OK) { @@ -1496,7 +1498,7 @@ Tcl_DbNewDictObj( static int DictCreateCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1546,7 +1548,7 @@ DictCreateCmd( static int DictGetCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1639,7 +1641,7 @@ DictGetCmd( static int DictGetDefCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1704,7 +1706,7 @@ DictGetDefCmd( static int DictReplaceCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1752,7 +1754,7 @@ DictReplaceCmd( static int DictRemoveCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1800,7 +1802,7 @@ DictRemoveCmd( static int DictMergeCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1887,7 +1889,7 @@ DictMergeCmd( static int DictKeysCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1966,7 +1968,7 @@ DictKeysCmd( static int DictValuesCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2026,12 +2028,13 @@ DictValuesCmd( static int DictSizeCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) { - int result, size; + int result; + int size; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "dictionary"); @@ -2064,7 +2067,7 @@ DictSizeCmd( static int DictExistsCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2106,7 +2109,7 @@ DictExistsCmd( static int DictInfoCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2150,7 +2153,7 @@ DictInfoCmd( static int DictIncrCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2271,7 +2274,7 @@ DictIncrCmd( static int DictLappendCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2358,7 +2361,7 @@ DictLappendCmd( static int DictAppendCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2460,7 +2463,7 @@ DictAppendCmd( static int DictForNRCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2469,7 +2472,8 @@ DictForNRCmd( Tcl_Obj *scriptObj, *keyVarObj, *valueVarObj; Tcl_Obj **varv, *keyObj, *valueObj; Tcl_DictSearch *searchPtr; - int varc, done; + int varc; + int done; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -2555,7 +2559,7 @@ DictForNRCmd( static int DictForLoopCallback( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -2655,7 +2659,7 @@ DictForLoopCallback( static int DictMapNRCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2663,7 +2667,8 @@ DictMapNRCmd( Interp *iPtr = (Interp *) interp; Tcl_Obj **varv, *keyObj, *valueObj; DictMapStorage *storagePtr; - int varc, done; + int varc; + int done; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -2759,7 +2764,7 @@ DictMapNRCmd( static int DictMapLoopCallback( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -2867,7 +2872,7 @@ DictMapLoopCallback( static int DictSetCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2927,7 +2932,7 @@ DictSetCmd( static int DictUnsetCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -2986,7 +2991,7 @@ DictUnsetCmd( static int DictFilterCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -3001,7 +3006,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; + int varc; const char *pattern; if (objc < 3) { @@ -3271,14 +3277,15 @@ DictFilterCmd( static int DictUpdateCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) { Interp *iPtr = (Interp *) interp; Tcl_Obj *dictPtr, *objPtr; - int i, dummy; + int i; + int dummy; if (objc < 5 || !(objc & 1)) { Tcl_WrongNumArgs(interp, 1, objv, @@ -3325,7 +3332,7 @@ DictUpdateCmd( static int FinalizeDictUpdate( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -3429,7 +3436,7 @@ FinalizeDictUpdate( static int DictWithCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -3476,7 +3483,7 @@ DictWithCmd( static int FinalizeDictWith( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { diff --git a/generic/tclInt.h b/generic/tclInt.h index bc605db..e43e627 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3386,7 +3386,7 @@ MODULE_SCOPE void TclRemoveScriptLimitCallbacks(Tcl_Interp *interp); MODULE_SCOPE int TclReToGlob(Tcl_Interp *interp, const char *reStr, int reStrLen, Tcl_DString *dsPtr, int *flagsPtr, int *quantifiersFoundPtr); -MODULE_SCOPE int TclScanElement(const char *string, int length, +MODULE_SCOPE TCL_HASH_TYPE TclScanElement(const char *string, int length, char *flagPtr); MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp, Tcl_Obj *cmdPrefix); diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 62bc162..78eb8a7 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -3417,7 +3417,8 @@ UpdateStringOfList( { # define LOCAL_SIZE 64 char localFlags[LOCAL_SIZE], *flagPtr = NULL; - ListSizeT numElems, i, length, bytesNeeded = 0; + ListSizeT numElems, i, length; + TCL_HASH_TYPE bytesNeeded = 0; const char *elem, *start; char *dst; Tcl_Obj **elemPtrs; @@ -3465,11 +3466,11 @@ UpdateStringOfList( flagPtr[i] = (i ? TCL_DONT_QUOTE_HASH : 0); elem = TclGetStringFromObj(elemPtrs[i], &length); bytesNeeded += TclScanElement(elem, length, flagPtr+i); - if (bytesNeeded < 0) { + if (bytesNeeded > INT_MAX) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } } - if (bytesNeeded > INT_MAX - numElems + 1) { + if (bytesNeeded + numElems > INT_MAX + 1U) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } bytesNeeded += numElems - 1; diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 7ab6eae..bae7bc6 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -106,8 +106,8 @@ static Tcl_ThreadDataKey precisionKey; */ static void ClearHash(Tcl_HashTable *tablePtr); -static void FreeProcessGlobalValue(ClientData clientData); -static void FreeThreadHash(ClientData clientData); +static void FreeProcessGlobalValue(void *clientData); +static void FreeThreadHash(void *clientData); static int GetEndOffsetFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, size_t endValue, Tcl_WideInt *indexPtr); static Tcl_HashTable * GetThreadHash(Tcl_ThreadDataKey *keyPtr); @@ -1017,7 +1017,7 @@ Tcl_ScanCountedElement( *---------------------------------------------------------------------- */ -int +unsigned int TclScanElement( const char *src, /* String to convert to Tcl list element. */ int length, /* Number of bytes in src, or -1. */ @@ -1033,7 +1033,7 @@ TclScanElement( int extra = 0; /* Count of number of extra bytes needed for * formatted element, assuming we use escape * sequences in formatting. */ - int bytesNeeded; /* Buffer length computed to complete the + unsigned int bytesNeeded; /* Buffer length computed to complete the * element formatting in the selected mode. */ #if COMPAT int preferEscape = 0; /* Use preferences to track whether to use */ @@ -1297,7 +1297,7 @@ TclScanElement( *flagPtr = CONVERT_NONE; overflowCheck: - if (bytesNeeded < 0) { + if (bytesNeeded > INT_MAX) { Tcl_Panic("TclScanElement: string length overflow"); } return bytesNeeded; @@ -1575,7 +1575,8 @@ Tcl_Merge( { #define LOCAL_SIZE 64 char localFlags[LOCAL_SIZE], *flagPtr = NULL; - int i, bytesNeeded = 0; + int i; + unsigned int bytesNeeded = 0; char *result, *dst; /* @@ -1601,11 +1602,11 @@ Tcl_Merge( for (i = 0; i < argc; i++) { flagPtr[i] = ( i ? TCL_DONT_QUOTE_HASH : 0 ); bytesNeeded += TclScanElement(argv[i], -1, &flagPtr[i]); - if (bytesNeeded < 0) { + if (bytesNeeded > INT_MAX) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } } - if (bytesNeeded > INT_MAX - argc + 1) { + if (bytesNeeded + argc > INT_MAX + 1U) { Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX); } bytesNeeded += argc; @@ -3391,7 +3392,7 @@ Tcl_PrintDouble( #if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 char * TclPrecTraceProc( - ClientData clientData, + void *clientData, Tcl_Interp *interp, /* Interpreter containing variable. */ const char *name1, /* Name of variable. */ const char *name2, /* Second part of variable name. */ @@ -3643,7 +3644,7 @@ GetWideForIndex( * representing an index. */ { int numType; - ClientData cd; + void *cd; int code = TclGetNumberFromObj(NULL, objPtr, &cd, &numType); if (code == TCL_OK) { @@ -3757,7 +3758,7 @@ GetEndOffsetFromObj( { Tcl_ObjInternalRep *irPtr; Tcl_WideInt offset = -1; /* Offset in the "end-offset" expression - 1 */ - ClientData cd; + void *cd; while ((irPtr = TclFetchInternalRep(objPtr, &endOffsetType)) == NULL) { Tcl_ObjInternalRep ir; @@ -4251,7 +4252,7 @@ GetThreadHash( static void FreeThreadHash( - ClientData clientData) + void *clientData) { Tcl_HashTable *tablePtr = (Tcl_HashTable *)clientData; @@ -4273,7 +4274,7 @@ FreeThreadHash( static void FreeProcessGlobalValue( - ClientData clientData) + void *clientData) { ProcessGlobalValue *pgvPtr = (ProcessGlobalValue *)clientData; |