diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-01-15 17:07:07 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-01-15 17:07:07 (GMT) |
| commit | 55f5b1c3506c8460a36e62c977c9bcbabc90c4d6 (patch) | |
| tree | 4c01ab102847babe5336d11432f809e909056ff8 | |
| parent | a4d601c42a5294611e2a71df75444505b6ece484 (diff) | |
| parent | 2f374ff67ee30bcc15752b48e36729c583615a12 (diff) | |
| download | tcl-55f5b1c3506c8460a36e62c977c9bcbabc90c4d6.zip tcl-55f5b1c3506c8460a36e62c977c9bcbabc90c4d6.tar.gz tcl-55f5b1c3506c8460a36e62c977c9bcbabc90c4d6.tar.bz2 | |
Merge 8.7
| -rw-r--r-- | generic/tclCkalloc.c | 16 | ||||
| -rw-r--r-- | generic/tclCompile.c | 2 | ||||
| -rw-r--r-- | generic/tclCompile.h | 18 | ||||
| -rw-r--r-- | generic/tclDate.c | 4 | ||||
| -rw-r--r-- | generic/tclEncoding.c | 3 | ||||
| -rw-r--r-- | generic/tclExecute.c | 42 | ||||
| -rw-r--r-- | generic/tclGetDate.y | 4 | ||||
| -rw-r--r-- | generic/tclIOGT.c | 8 | ||||
| -rw-r--r-- | generic/tclIORChan.c | 70 | ||||
| -rw-r--r-- | generic/tclIORTrans.c | 98 | ||||
| -rw-r--r-- | generic/tclInt.h | 2 | ||||
| -rw-r--r-- | generic/tclOOInt.h | 2 | ||||
| -rw-r--r-- | generic/tclObj.c | 2 | ||||
| -rw-r--r-- | generic/tclProc.c | 4 | ||||
| -rw-r--r-- | generic/tclStringObj.c | 6 | ||||
| -rw-r--r-- | generic/tclStringRep.h | 2 | ||||
| -rw-r--r-- | generic/tclTest.c | 3 | ||||
| -rw-r--r-- | generic/tclTomMathDecls.h | 10 | ||||
| -rw-r--r-- | generic/tclTrace.c | 4 | ||||
| -rw-r--r-- | tests/encoding.test | 20 |
20 files changed, 160 insertions, 160 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index f2394b1..d0fa300 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -41,7 +41,7 @@ typedef struct MemTag { * last field in the structure. */ } MemTag; -#define TAG_SIZE(bytesInString) ((offsetof(MemTag, string) + 1) + bytesInString) +#define TAG_SIZE(bytesInString) ((offsetof(MemTag, string) + 1U) + (bytesInString)) static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set * by "memory tag" command). */ @@ -131,10 +131,10 @@ static int ckallocInit = 0; * Prototypes for procedures defined in this file: */ -static int CheckmemCmd(ClientData clientData, +static int CheckmemCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int MemoryCmd(ClientData clientData, +static int MemoryCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static void ValidateMemory(struct mem_header *memHeaderP, @@ -177,7 +177,7 @@ TclInitDbCkalloc(void) int TclDumpMemoryInfo( - ClientData clientData, + void *clientData, int flags) { char buf[1024]; @@ -810,7 +810,7 @@ Tcl_AttemptRealloc( */ static int MemoryCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Obj values of arguments. */ @@ -980,13 +980,13 @@ MemoryCmd( * *---------------------------------------------------------------------- */ -static int CheckmemCmd(ClientData clientData, +static int CheckmemCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int CheckmemCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Interpreter for evaluation. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Obj values of arguments. */ @@ -1240,7 +1240,7 @@ Tcl_ValidateAllMemory( int TclDumpMemoryInfo( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), TCL_UNUSED(int) /*flags*/) { return 1; diff --git a/generic/tclCompile.c b/generic/tclCompile.c index c89fedb..f7479f0 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -3065,7 +3065,7 @@ TclFindCompiledLocal( if (create || (name == NULL)) { localVar = procPtr->numCompiledLocals; - localPtr = (CompiledLocal *)ckalloc(offsetof(CompiledLocal, name) + nameBytes + 1); + localPtr = (CompiledLocal *)ckalloc(offsetof(CompiledLocal, name) + 1U + nameBytes); if (procPtr->firstLocalPtr == NULL) { procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr; } else { diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 96a3541..30b364d 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -1495,22 +1495,22 @@ MODULE_SCOPE int TclPushProcCallFrame(void *clientData, # define TclGetInt1AtPtr(p) ((int) *((signed char *) p)) #else # define TclGetInt1AtPtr(p) \ - (((int) *((char *) p)) | ((*(p) & 0200) ? (-256) : 0)) + ((int) ((*((char *) p)) | ((*(p) & 0200) ? (-256) : 0))) #endif #define TclGetInt4AtPtr(p) \ - (((int) (TclGetUInt1AtPtr(p) << 24)) | \ - (*((p)+1) << 16) | \ - (*((p)+2) << 8) | \ - (*((p)+3))) + ((int) ((TclGetUInt1AtPtr(p) << 24) | \ + (*((p)+1) << 16) | \ + (*((p)+2) << 8) | \ + (*((p)+3)))) #define TclGetUInt1AtPtr(p) \ ((unsigned int) *(p)) #define TclGetUInt4AtPtr(p) \ - ((unsigned int) (*(p) << 24) | \ - (*((p)+1) << 16) | \ - (*((p)+2) << 8) | \ - (*((p)+3))) + ((unsigned int) ((*(p) << 24) | \ + (*((p)+1) << 16) | \ + (*((p)+2) << 8) | \ + (*((p)+3)))) /* * Macros used to compute the minimum and maximum of two integers. The ANSI C diff --git a/generic/tclDate.c b/generic/tclDate.c index c9c1c3e..7688f2c 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -185,9 +185,9 @@ typedef struct DateInfo { #define TM_YEAR_BASE 1900 -#define HOUR(x) ((int) (60 * x)) +#define HOUR(x) ((int) (60 * (x))) #define SECSPERDAY (24L * 60L * 60L) -#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0)) +#define IsLeapYear(x) (((x) % 4 == 0) && ((x) % 100 != 0 || (x) % 400 == 0)) /* * An entry in the lexical lookup table. diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 3d0225b..5e2ef39 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2421,9 +2421,6 @@ UtfToUtfProc( src = saveSrc; break; } - if (!(flags & TCL_ENCODING_MODIFIED)) { - ch = 0xFFFD; - } cesu8: *dst++ = (char) (((ch >> 12) | 0xE0) & 0xEF); *dst++ = (char) (((ch >> 6) | 0x80) & 0xBF); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 765b726..d03f1cb 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -193,10 +193,10 @@ typedef struct TEBCdata { #define PUSH_TAUX_OBJ(objPtr) \ do { \ if (auxObjList) { \ - objPtr->length += auxObjList->length; \ + (objPtr)->length += auxObjList->length; \ } \ - objPtr->internalRep.twoPtrValue.ptr1 = auxObjList; \ - auxObjList = objPtr; \ + (objPtr)->internalRep.twoPtrValue.ptr1 = auxObjList; \ + auxObjList = (objPtr); \ } while (0) #define POP_TAUX_OBJ() \ @@ -505,7 +505,7 @@ VarHashCreateVar( * TclGetNumberFromObj(). The ANSI C "prototype" is: * * MODULE_SCOPE int GetNumberFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, - * ClientData *ptrPtr, int *tPtr); + * void **ptrPtr, int *tPtr); */ #define GetNumberFromObj(interp, objPtr, ptrPtr, tPtr) \ @@ -669,7 +669,7 @@ static const size_t Exp64ValueSize = sizeof(Exp64Value) / sizeof(Tcl_WideInt); */ #ifdef TCL_COMPILE_STATS -static int EvalStatsCmd(ClientData clientData, +static int EvalStatsCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #endif /* TCL_COMPILE_STATS */ @@ -1365,7 +1365,7 @@ Tcl_ExprObj( static int CopyCallback( - ClientData data[], + void *data[], TCL_UNUSED(Tcl_Interp *), int result) { @@ -1423,7 +1423,7 @@ Tcl_NRExprObj( static int ExprObjCallback( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -1809,7 +1809,7 @@ TclIncrObj( Tcl_Obj *valuePtr, Tcl_Obj *incrPtr) { - ClientData ptr1, ptr2; + void *ptr1, *ptr2; int type1, type2; mp_int value, incr; mp_err err; @@ -2019,7 +2019,7 @@ TclNRExecuteByteCode( static int TEBCresume( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -3704,7 +3704,7 @@ TEBCresume( } if (TclIsVarDirectModifyable(varPtr)) { - ClientData ptr; + void *ptr; int type; objPtr = varPtr->value.objPtr; @@ -5538,7 +5538,9 @@ TEBCresume( p = ustring1; end = ustring1 + length; for (; ustring1 < end; ustring1++) { - if ((*ustring1 == *ustring2) && (length2==1 || + if ((*ustring1 == *ustring2) && + /* Fix bug [69218ab7b]: restrict max compare length. */ + (end-ustring1 >= length2) && (length2==1 || memcmp(ustring1, ustring2, sizeof(Tcl_UniChar) * length2) == 0)) { if (p != ustring1) { @@ -5743,7 +5745,7 @@ TEBCresume( */ { - ClientData ptr1, ptr2; + void *ptr1, *ptr2; int type1, type2; Tcl_WideInt w1, w2, wResult; @@ -7924,7 +7926,7 @@ TEBCresume( static int FinalizeOONext( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -7950,7 +7952,7 @@ FinalizeOONext( static int FinalizeOONextFilter( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -8096,14 +8098,14 @@ ExecuteExtendedBinaryMathOp( if (Tcl_IsShared(valuePtr)) { \ return Tcl_NewWideIntObj(w); \ } else { \ - TclSetIntObj(valuePtr, w); \ + TclSetIntObj(valuePtr, (w)); \ return NULL; \ } #define BIG_RESULT(b) \ if (Tcl_IsShared(valuePtr)) { \ return Tcl_NewBignumObj(b); \ } else { \ - Tcl_SetBignumObj(valuePtr, b); \ + Tcl_SetBignumObj(valuePtr, (b)); \ return NULL; \ } #define DOUBLE_RESULT(d) \ @@ -8116,7 +8118,7 @@ ExecuteExtendedBinaryMathOp( } int type1, type2; - ClientData ptr1, ptr2; + void *ptr1, *ptr2; double d1, d2, dResult; Tcl_WideInt w1, w2, wResult; mp_int big1, big2, bigResult, bigRemainder; @@ -8818,7 +8820,7 @@ ExecuteExtendedUnaryMathOp( int opcode, /* What operation to perform. */ Tcl_Obj *valuePtr) /* The operand on the stack. */ { - ClientData ptr = NULL; + void *ptr = NULL; int type; Tcl_WideInt w; mp_int big; @@ -8898,7 +8900,7 @@ TclCompareTwoNumbers( Tcl_Obj *value2Ptr) { int type1 = TCL_NUMBER_NAN, type2 = TCL_NUMBER_NAN, compare; - ClientData ptr1, ptr2; + void *ptr1, *ptr2; mp_int big1, big2; double d1, d2, tmp; Tcl_WideInt w1, w2; @@ -9213,7 +9215,7 @@ IllegalExprOperandType( Tcl_Obj *opndPtr) /* Points to the operand holding the value * with the illegal type. */ { - ClientData ptr; + void *ptr; int type; const unsigned char opcode = *pc; const char *description, *op = "unknown"; diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 44757da..0a5a11e 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -136,9 +136,9 @@ typedef struct DateInfo { #define TM_YEAR_BASE 1900 -#define HOUR(x) ((int) (60 * x)) +#define HOUR(x) ((int) (60 * (x))) #define SECSPERDAY (24L * 60L * 60L) -#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0)) +#define IsLeapYear(x) (((x) % 4 == 0) && ((x) % 100 != 0 || (x) % 400 == 0)) /* * An entry in the lexical lookup table. diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c index f03fcca..6194187 100644 --- a/generic/tclIOGT.c +++ b/generic/tclIOGT.c @@ -108,7 +108,7 @@ typedef struct ResultBuffer ResultBuffer; static inline void ResultClear(ResultBuffer *r); static inline void ResultInit(ResultBuffer *r); static inline int ResultEmpty(ResultBuffer *r); -static inline int ResultCopy(ResultBuffer *r, unsigned char *buf, +static inline size_t ResultCopy(ResultBuffer *r, unsigned char *buf, size_t toRead); static inline void ResultAdd(ResultBuffer *r, unsigned char *buf, size_t toWrite); @@ -1368,13 +1368,13 @@ ResultEmpty( *---------------------------------------------------------------------- */ -static inline int +static inline size_t ResultCopy( ResultBuffer *r, /* The buffer to read from. */ unsigned char *buf, /* The buffer to copy into. */ size_t toRead) /* Number of requested bytes. */ { - if (r->used == 0) { + if (ResultEmpty(r)) { /* * Nothing to copy in the case of an empty buffer. */ @@ -1431,7 +1431,7 @@ ResultAdd( unsigned char *buf, /* The buffer to read from. */ size_t toWrite) /* The number of bytes in 'buf'. */ { - if (r->used + toWrite > r->allocated) { + if ((r->used + toWrite + 1) > r->allocated) { /* * Extension of the internal buffer is required. */ diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index fe383be..a69bf65 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -31,35 +31,35 @@ * Signatures of all functions used in the C layer of the reflection. */ -static int ReflectClose(ClientData clientData, +static int ReflectClose(void *clientData, Tcl_Interp *interp, int flags); -static int ReflectInput(ClientData clientData, char *buf, +static int ReflectInput(void *clientData, char *buf, int toRead, int *errorCodePtr); -static int ReflectOutput(ClientData clientData, const char *buf, +static int ReflectOutput(void *clientData, const char *buf, int toWrite, int *errorCodePtr); -static void ReflectWatch(ClientData clientData, int mask); -static int ReflectBlock(ClientData clientData, int mode); +static void ReflectWatch(void *clientData, int mask); +static int ReflectBlock(void *clientData, int mode); #if TCL_THREADS -static void ReflectThread(ClientData clientData, int action); +static void ReflectThread(void *clientData, int action); static int ReflectEventRun(Tcl_Event *ev, int flags); -static int ReflectEventDelete(Tcl_Event *ev, ClientData cd); +static int ReflectEventDelete(Tcl_Event *ev, void *cd); #endif -static long long ReflectSeekWide(ClientData clientData, +static long long ReflectSeekWide(void *clientData, long long offset, int mode, int *errorCodePtr); #ifndef TCL_NO_DEPRECATED -static int ReflectSeek(ClientData clientData, long offset, +static int ReflectSeek(void *clientData, long offset, int mode, int *errorCodePtr); #endif -static int ReflectGetOption(ClientData clientData, +static int ReflectGetOption(void *clientData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); -static int ReflectSetOption(ClientData clientData, +static int ReflectSetOption(void *clientData, Tcl_Interp *interp, const char *optionName, const char *newValue); -static int ReflectTruncate(ClientData clientData, +static int ReflectTruncate(void *clientData, long long length); -static void TimerRunRead(ClientData clientData); -static void TimerRunWrite(ClientData clientData); +static void TimerRunRead(void *clientData); +static void TimerRunWrite(void *clientData); /* * The C layer channel type/driver definition used by the reflection. @@ -220,7 +220,7 @@ typedef enum { #define IMPLIES(a,b) ((!(a)) || (b)) #define NEGIMPL(a,b) -#define HAS(x,f) (x & FLAG(f)) +#define HAS(x,f) ((x) & FLAG(f)) #if TCL_THREADS /* @@ -408,7 +408,7 @@ TCL_DECLARE_MUTEX(rcForwardMutex) static void ForwardOpToHandlerThread(ReflectedChannel *rcPtr, ForwardedOperation op, const void *param); static int ForwardProc(Tcl_Event *evPtr, int mask); -static void SrcExitProc(ClientData clientData); +static void SrcExitProc(void *clientData); #define FreeReceivedError(p) \ if ((p)->base.mustFree) { \ @@ -507,7 +507,7 @@ static const char *msg_dstlost = "-code 1 -level 0 -errorcode NONE -errorinfo int TclChanCreateObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -809,7 +809,7 @@ ReflectEventRun( static int ReflectEventDelete( Tcl_Event *ev, - ClientData cd) + void *cd) { /* OWNER thread * @@ -829,7 +829,7 @@ ReflectEventDelete( int TclChanPostEventObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -1012,7 +1012,7 @@ TclChanPostEventObjCmd( static void TimerRunRead( - ClientData clientData) + void *clientData) { ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; rcPtr->readTimer = NULL; @@ -1021,7 +1021,7 @@ TimerRunRead( static void TimerRunWrite( - ClientData clientData) + void *clientData) { ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; rcPtr->writeTimer = NULL; @@ -1169,7 +1169,7 @@ TclChanCaughtErrorBypass( static int ReflectClose( - ClientData clientData, + void *clientData, Tcl_Interp *interp, int flags) { @@ -1329,7 +1329,7 @@ ReflectClose( static int ReflectInput( - ClientData clientData, + void *clientData, char *buf, int toRead, int *errorCodePtr) @@ -1436,7 +1436,7 @@ ReflectInput( static int ReflectOutput( - ClientData clientData, + void *clientData, const char *buf, int toWrite, int *errorCodePtr) @@ -1565,7 +1565,7 @@ ReflectOutput( static long long ReflectSeekWide( - ClientData clientData, + void *clientData, long long offset, int seekMode, int *errorCodePtr) @@ -1642,7 +1642,7 @@ ReflectSeekWide( #ifndef TCL_NO_DEPRECATED static int ReflectSeek( - ClientData clientData, + void *clientData, long offset, int seekMode, int *errorCodePtr) @@ -1678,7 +1678,7 @@ ReflectSeek( static void ReflectWatch( - ClientData clientData, + void *clientData, int mask) { ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; @@ -1750,7 +1750,7 @@ ReflectWatch( static int ReflectBlock( - ClientData clientData, + void *clientData, int nonblocking) { ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; @@ -1817,7 +1817,7 @@ ReflectBlock( static void ReflectThread( - ClientData clientData, + void *clientData, int action) { ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; @@ -1854,7 +1854,7 @@ ReflectThread( static int ReflectSetOption( - ClientData clientData, /* Channel to query */ + void *clientData, /* Channel to query */ Tcl_Interp *interp, /* Interpreter to leave error messages in */ const char *optionName, /* Name of requested option */ const char *newValue) /* The new value */ @@ -1926,7 +1926,7 @@ ReflectSetOption( static int ReflectGetOption( - ClientData clientData, /* Channel to query */ + void *clientData, /* Channel to query */ Tcl_Interp *interp, /* Interpreter to leave error messages in */ const char *optionName, /* Name of reuqested option */ Tcl_DString *dsPtr) /* String to place the result into */ @@ -2078,7 +2078,7 @@ ReflectGetOption( static int ReflectTruncate( - ClientData clientData, /* Channel to query */ + void *clientData, /* Channel to query */ long long length) /* Length to truncate to. */ { ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; @@ -2644,7 +2644,7 @@ MarkDead( static void DeleteReflectedChannelMap( - ClientData clientData, /* The per-interpreter data structure. */ + void *clientData, /* The per-interpreter data structure. */ Tcl_Interp *interp) /* The interpreter being deleted. */ { ReflectedChannelMap *rcmPtr = (ReflectedChannelMap *)clientData; @@ -2823,7 +2823,7 @@ GetThreadReflectedChannelMap(void) static void DeleteThreadReflectedChannelMap( - TCL_UNUSED(ClientData)) + TCL_UNUSED(void *)) { Tcl_HashSearch hSearch; /* Search variable. */ Tcl_HashEntry *hPtr; /* Search variable. */ @@ -3409,7 +3409,7 @@ ForwardProc( static void SrcExitProc( - ClientData clientData) + void *clientData) { ForwardingEvent *evPtr = (ForwardingEvent *)clientData; ForwardingResult *resultPtr; diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 7dba42d..dc6c9a7 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -31,29 +31,29 @@ * Signatures of all functions used in the C layer of the reflection. */ -static int ReflectClose(ClientData clientData, +static int ReflectClose(void *clientData, Tcl_Interp *interp, int flags); -static int ReflectInput(ClientData clientData, char *buf, +static int ReflectInput(void *clientData, char *buf, int toRead, int *errorCodePtr); -static int ReflectOutput(ClientData clientData, const char *buf, +static int ReflectOutput(void *clientData, const char *buf, int toWrite, int *errorCodePtr); -static void ReflectWatch(ClientData clientData, int mask); -static int ReflectBlock(ClientData clientData, int mode); -static long long ReflectSeekWide(ClientData clientData, +static void ReflectWatch(void *clientData, int mask); +static int ReflectBlock(void *clientData, int mode); +static long long ReflectSeekWide(void *clientData, long long offset, int mode, int *errorCodePtr); #ifndef TCL_NO_DEPRECATED -static int ReflectSeek(ClientData clientData, long offset, +static int ReflectSeek(void *clientData, long offset, int mode, int *errorCodePtr); #endif -static int ReflectGetOption(ClientData clientData, +static int ReflectGetOption(void *clientData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); -static int ReflectSetOption(ClientData clientData, +static int ReflectSetOption(void *clientData, Tcl_Interp *interp, const char *optionName, const char *newValue); -static int ReflectHandle(ClientData clientData, int direction, - ClientData *handle); -static int ReflectNotify(ClientData clientData, int mask); +static int ReflectHandle(void *clientData, int direction, + void **handle); +static int ReflectNotify(void *clientData, int mask); /* * The C layer channel type/driver definition used by the reflection. @@ -91,20 +91,20 @@ static const Tcl_ChannelType tclRTransformType = { typedef struct { unsigned char *buf; /* Reference to the buffer area. */ - int allocated; /* Allocated size of the buffer area. */ - int used; /* Number of bytes in the buffer, + size_t allocated; /* Allocated size of the buffer area. */ + size_t used; /* Number of bytes in the buffer, * <= allocated. */ } ResultBuffer; #define ResultLength(r) ((r)->used) /* static int ResultLength(ResultBuffer *r); */ -static void ResultClear(ResultBuffer *r); -static void ResultInit(ResultBuffer *r); -static void ResultAdd(ResultBuffer *r, unsigned char *buf, - int toWrite); -static int ResultCopy(ResultBuffer *r, unsigned char *buf, - int toRead); +static inline void ResultClear(ResultBuffer *r); +static inline void ResultInit(ResultBuffer *r); +static inline void ResultAdd(ResultBuffer *r, unsigned char *buf, + size_t toWrite); +static inline size_t ResultCopy(ResultBuffer *r, unsigned char *buf, + size_t toRead); #define RB_INCREMENT (512) @@ -220,7 +220,7 @@ typedef enum { #define IMPLIES(a,b) ((!(a)) || (b)) #define NEGIMPL(a,b) -#define HAS(x,f) (x & FLAG(f)) +#define HAS(x,f) ((x) & FLAG(f)) #if TCL_THREADS /* @@ -363,7 +363,7 @@ TCL_DECLARE_MUTEX(rtForwardMutex) static void ForwardOpToOwnerThread(ReflectedTransform *rtPtr, ForwardedOperation op, const void *param); static int ForwardProc(Tcl_Event *evPtr, int mask); -static void SrcExitProc(ClientData clientData); +static void SrcExitProc(void *clientData); #define FreeReceivedError(p) \ do { \ @@ -402,7 +402,7 @@ static void ForwardSetObjError(ForwardParam *p, Tcl_Obj *objPtr); static ReflectedTransformMap * GetThreadReflectedTransformMap(void); static void DeleteThreadReflectedTransformMap( - ClientData clientData); + void *clientData); #endif /* TCL_THREADS */ #define SetChannelErrorStr(c,msgStr) \ @@ -428,7 +428,7 @@ static int InvokeTclMethod(ReflectedTransform *rtPtr, Tcl_Obj *argTwoObj, Tcl_Obj **resultObjPtr); static ReflectedTransformMap * GetReflectedTransformMap(Tcl_Interp *interp); -static void DeleteReflectedTransformMap(ClientData clientData, +static void DeleteReflectedTransformMap(void *clientData, Tcl_Interp *interp); /* @@ -458,7 +458,7 @@ static const char *msg_dstlost = static void TimerKill(ReflectedTransform *rtPtr); static void TimerSetup(ReflectedTransform *rtPtr); -static void TimerRun(ClientData clientData); +static void TimerRun(void *clientData); static int TransformRead(ReflectedTransform *rtPtr, int *errorCodePtr, Tcl_Obj *bufObj); static int TransformWrite(ReflectedTransform *rtPtr, @@ -503,7 +503,7 @@ static int TransformLimit(ReflectedTransform *rtPtr, int TclChanPushObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -748,7 +748,7 @@ TclChanPushObjCmd( int TclChanPopObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -884,7 +884,7 @@ UnmarshallErrorResult( static int ReflectClose( - ClientData clientData, + void *clientData, Tcl_Interp *interp, int flags) { @@ -1063,7 +1063,7 @@ ReflectClose( static int ReflectInput( - ClientData clientData, + void *clientData, char *buf, int toRead, int *errorCodePtr) @@ -1256,7 +1256,7 @@ ReflectInput( static int ReflectOutput( - ClientData clientData, + void *clientData, const char *buf, int toWrite, int *errorCodePtr) @@ -1329,7 +1329,7 @@ ReflectOutput( static long long ReflectSeekWide( - ClientData clientData, + void *clientData, long long offset, int seekMode, int *errorCodePtr) @@ -1411,7 +1411,7 @@ ReflectSeekWide( #ifndef TCL_NO_DEPRECATED static int ReflectSeek( - ClientData clientData, + void *clientData, long offset, int seekMode, int *errorCodePtr) @@ -1447,7 +1447,7 @@ ReflectSeek( static void ReflectWatch( - ClientData clientData, + void *clientData, int mask) { ReflectedTransform *rtPtr = (ReflectedTransform *)clientData; @@ -1498,7 +1498,7 @@ ReflectWatch( static int ReflectBlock( - ClientData clientData, + void *clientData, int nonblocking) { ReflectedTransform *rtPtr = (ReflectedTransform *)clientData; @@ -1531,7 +1531,7 @@ ReflectBlock( static int ReflectSetOption( - ClientData clientData, /* Channel to query */ + void *clientData, /* Channel to query */ Tcl_Interp *interp, /* Interpreter to leave error messages in */ const char *optionName, /* Name of requested option */ const char *newValue) /* The new value */ @@ -1573,7 +1573,7 @@ ReflectSetOption( static int ReflectGetOption( - ClientData clientData, /* Channel to query */ + void *clientData, /* Channel to query */ Tcl_Interp *interp, /* Interpreter to leave error messages in */ const char *optionName, /* Name of reuqested option */ Tcl_DString *dsPtr) /* String to place the result into */ @@ -1622,9 +1622,9 @@ ReflectGetOption( static int ReflectHandle( - ClientData clientData, + void *clientData, int direction, - ClientData *handlePtr) + void **handlePtr) { ReflectedTransform *rtPtr = (ReflectedTransform *)clientData; @@ -1658,7 +1658,7 @@ ReflectHandle( static int ReflectNotify( - ClientData clientData, + void *clientData, int mask) { ReflectedTransform *rtPtr = (ReflectedTransform *)clientData; @@ -2147,7 +2147,7 @@ GetReflectedTransformMap( static void DeleteReflectedTransformMap( - ClientData clientData, /* The per-interpreter data structure. */ + void *clientData, /* The per-interpreter data structure. */ Tcl_Interp *interp) /* The interpreter being deleted. */ { ReflectedTransformMap *rtmPtr; /* The map */ @@ -2310,7 +2310,7 @@ GetThreadReflectedTransformMap(void) static void DeleteThreadReflectedTransformMap( - TCL_UNUSED(ClientData)) + TCL_UNUSED(void *)) { Tcl_HashSearch hSearch; /* Search variable. */ Tcl_HashEntry *hPtr; /* Search variable. */ @@ -2759,7 +2759,7 @@ ForwardProc( static void SrcExitProc( - ClientData clientData) + void *clientData) { ForwardingEvent *evPtr = (ForwardingEvent *)clientData; ForwardingResult *resultPtr; @@ -2899,7 +2899,7 @@ TimerSetup( static void TimerRun( - ClientData clientData) + void *clientData) { ReflectedTransform *rtPtr = (ReflectedTransform *)clientData; @@ -2924,7 +2924,7 @@ TimerRun( *---------------------------------------------------------------------- */ -static void +static inline void ResultInit( ResultBuffer *rPtr) /* Reference to the structure to * initialize. */ @@ -2949,7 +2949,7 @@ ResultInit( *---------------------------------------------------------------------- */ -static void +static inline void ResultClear( ResultBuffer *rPtr) /* Reference to the buffer to clear out */ { @@ -2980,11 +2980,11 @@ ResultClear( *---------------------------------------------------------------------- */ -static void +static inline void ResultAdd( ResultBuffer *rPtr, /* The buffer to extend */ unsigned char *buf, /* The buffer to read from */ - int toWrite) /* The number of bytes in 'buf' */ + size_t toWrite) /* The number of bytes in 'buf' */ { if ((rPtr->used + toWrite + 1) > rPtr->allocated) { /* @@ -3028,11 +3028,11 @@ ResultAdd( *---------------------------------------------------------------------- */ -static int +static inline size_t ResultCopy( ResultBuffer *rPtr, /* The buffer to read from */ unsigned char *buf, /* The buffer to copy into */ - int toRead) /* Number of requested bytes */ + size_t toRead) /* Number of requested bytes */ { int copied; diff --git a/generic/tclInt.h b/generic/tclInt.h index ea83055..b82a473 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -5192,7 +5192,7 @@ typedef struct NRE_callback { #define TCLNR_FREE(interp, ptr) TclSmallFreeEx((interp), (ptr)) #else #define TCLNR_ALLOC(interp, ptr) \ - (ptr = ((ClientData) ckalloc(sizeof(NRE_callback)))) + ((ptr) = ((void *)ckalloc(sizeof(NRE_callback)))) #define TCLNR_FREE(interp, ptr) ckfree(ptr) #endif diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h index 007cbfd..521152e 100644 --- a/generic/tclOOInt.h +++ b/generic/tclOOInt.h @@ -631,7 +631,7 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr); #define FOREACH(var,ary) \ for(i=0 ; i<(ary).num; i++) if ((ary).list[i] == NULL) { \ continue; \ - } else if (var = (ary).list[i], 1) + } else if ((var) = (ary).list[i], 1) /* * A variation where the array is an array of structs. There's no issue with diff --git a/generic/tclObj.c b/generic/tclObj.c index 92c6655..16a95cd 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -567,7 +567,7 @@ TclContinuationsEnter( ThreadSpecificData *tsdPtr = TclGetContLineTable(); Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry); - ContLineLoc *clLocPtr = (ContLineLoc *)ckalloc(offsetof(ContLineLoc, loc) + (num + 1) *sizeof(int)); + ContLineLoc *clLocPtr = (ContLineLoc *)ckalloc(offsetof(ContLineLoc, loc) + (num + 1U) *sizeof(int)); if (!newEntry) { /* diff --git a/generic/tclProc.c b/generic/tclProc.c index 306f04c..72a3c2a 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -633,7 +633,7 @@ TclCreateProc( */ localPtr = (CompiledLocal *)ckalloc( - offsetof(CompiledLocal, name) + fieldValues[0]->length + 1); + offsetof(CompiledLocal, name) + 1U + fieldValues[0]->length); if (procPtr->firstLocalPtr == NULL) { procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr; } else { @@ -1438,7 +1438,6 @@ InitArgsAndLocals( numArgs = procPtr->numArgs; argCt = framePtr->objc - skip; /* Set it to the number of args to the * procedure. */ - argObjs = framePtr->objv + skip; if (numArgs == 0) { if (argCt) { goto incorrectArgs; @@ -1446,6 +1445,7 @@ InitArgsAndLocals( goto correctArgs; } } + argObjs = framePtr->objv + skip; imax = ((argCt < numArgs-1) ? argCt : numArgs-1); for (i = 0; i < imax; i++, varPtr++, defPtr ? defPtr++ : defPtr) { /* diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 5b8f3a6..a1d6602 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -148,7 +148,7 @@ GrowStringBuffer( if (flag == 0 || stringPtr->allocated > 0) { if (needed <= INT_MAX / 2) { attempt = 2 * needed; - ptr = (char *)attemptckrealloc(objPtr->bytes, attempt + 1); + ptr = (char *)attemptckrealloc(objPtr->bytes, attempt + 1U); } if (ptr == NULL) { /* @@ -161,7 +161,7 @@ GrowStringBuffer( int growth = (int) ((extra > limit) ? limit : extra); attempt = needed + growth; - ptr = (char *)attemptckrealloc(objPtr->bytes, attempt + 1); + ptr = (char *)attemptckrealloc(objPtr->bytes, attempt + 1U); } } if (ptr == NULL) { @@ -170,7 +170,7 @@ GrowStringBuffer( */ attempt = needed; - ptr = (char *)ckrealloc(objPtr->bytes, attempt + 1); + ptr = (char *)ckrealloc(objPtr->bytes, attempt + 1U); } objPtr->bytes = ptr; stringPtr->allocated = attempt; diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h index e01ba2d..672210a 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -67,7 +67,7 @@ typedef struct { #define STRING_MAXCHARS \ (int)(((size_t)UINT_MAX - 1 - offsetof(String, unicode))/sizeof(Tcl_UniChar)) #define STRING_SIZE(numChars) \ - (offsetof(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar))) + (offsetof(String, unicode) + (((numChars) + 1U) * sizeof(Tcl_UniChar))) #define stringCheckLimits(numChars) \ do { \ if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \ diff --git a/generic/tclTest.c b/generic/tclTest.c index 0ac79a6..06a0834 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -3574,8 +3574,9 @@ PrintParse( Tcl_NewIntObj(tokenPtr->numComponents)); } Tcl_ListObjAppendElement(NULL, objPtr, + parsePtr->commandStart ? Tcl_NewStringObj(parsePtr->commandStart + parsePtr->commandSize, - -1)); + -1) : Tcl_NewObj()); } /* diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 1b2c05f..8d12adf 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -167,11 +167,11 @@ MODULE_SCOPE mp_err TclBN_mp_set_int(mp_int *a, unsigned long b); #define s_mp_toom_sqr TclBN_mp_toom_sqr #endif /* !TCL_WITH_EXTERNAL_TOMMATH */ -#define mp_init_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_init_ul") TclBN_mp_init_u64(a,(unsigned int)(b))) -#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_u64((a),((unsigned int)(b))),MP_OKAY)) -#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (TclBN_mp_set_u64((a),(long)(b)),MP_OKAY)) -#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_u64") (TclBN_mp_set_u64((a),(b)),MP_OKAY)) -#define mp_unsigned_bin_size(mp) (MP_DEPRECATED_PRAGMA("replaced by mp_ubin_size") (int)TclBN_mp_ubin_size(mp)) +#define mp_init_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_init_ul") mp_init_u64(a,(unsigned int)(b))) +#define mp_set_int(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (mp_set_u64((a),((unsigned int)(b))),MP_OKAY)) +#define mp_set_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_ul") (mp_set_u64((a),(long)(b)),MP_OKAY)) +#define mp_set_long_long(a,b) (MP_DEPRECATED_PRAGMA("replaced by mp_set_u64") (mp_set_u64((a),(b)),MP_OKAY)) +#define mp_unsigned_bin_size(mp) (MP_DEPRECATED_PRAGMA("replaced by mp_ubin_size") (int)mp_ubin_size(mp)) #undef TCL_STORAGE_CLASS #ifdef BUILD_tcl diff --git a/generic/tclTrace.c b/generic/tclTrace.c index acb0fa4..68a9013 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -159,8 +159,8 @@ typedef struct { #define FOREACH_COMMAND_TRACE(interp, name, clientData) \ (clientData) = NULL; \ - while ((clientData = Tcl_CommandTraceInfo(interp, name, 0, \ - TraceCommandProc, clientData)) != NULL) + while (((clientData) = Tcl_CommandTraceInfo((interp), (name), 0, \ + TraceCommandProc, (clientData))) != NULL) /* *---------------------------------------------------------------------- diff --git a/tests/encoding.test b/tests/encoding.test index 5f9557b..c6865d9 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -351,61 +351,61 @@ test encoding-15.6 {UtfToUtfProc emoji character output} { set y [encoding convertto -nothrow utf-8 \uDE02\uD83D\uDE02\uD83D] binary scan $y H* z list [string length $y] $z -} {10 efbfbdf09f9882efbfbd} +} {10 edb882f09f9882eda0bd} test encoding-15.7 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\uD83D set y [encoding convertto -nothrow utf-8 \uDE02\uD83D\uD83D] binary scan $y H* z list [string length $x] [string length $y] $z -} {3 9 efbfbdefbfbdefbfbd} +} {3 9 edb882eda0bdeda0bd} test encoding-15.8 {UtfToUtfProc emoji character output} { set x \uDE02\uD83Dé set y [encoding convertto -nothrow utf-8 \uDE02\uD83Dé] binary scan $y H* z list [string length $x] [string length $y] $z -} {3 8 efbfbdefbfbdc3a9} +} {3 8 edb882eda0bdc3a9} test encoding-15.9 {UtfToUtfProc emoji character output} { set x \uDE02\uD83DX set y [encoding convertto -nothrow utf-8 \uDE02\uD83DX] binary scan $y H* z list [string length $x] [string length $y] $z -} {3 7 efbfbdefbfbd58} +} {3 7 edb882eda0bd58} test encoding-15.10 {UtfToUtfProc high surrogate character output} { set x \uDE02é set y [encoding convertto -nothrow utf-8 \uDE02é] binary scan $y H* z list [string length $x] [string length $y] $z -} {2 5 efbfbdc3a9} +} {2 5 edb882c3a9} test encoding-15.11 {UtfToUtfProc low surrogate character output} { set x \uDA02é set y [encoding convertto -nothrow utf-8 \uDA02é] binary scan $y H* z list [string length $x] [string length $y] $z -} {2 5 efbfbdc3a9} +} {2 5 eda882c3a9} test encoding-15.12 {UtfToUtfProc high surrogate character output} { set x \uDE02Y set y [encoding convertto -nothrow utf-8 \uDE02Y] binary scan $y H* z list [string length $x] [string length $y] $z -} {2 4 efbfbd59} +} {2 4 edb88259} test encoding-15.13 {UtfToUtfProc low surrogate character output} { set x \uDA02Y set y [encoding convertto -nothrow utf-8 \uDA02Y] binary scan $y H* z list [string length $x] [string length $y] $z -} {2 4 efbfbd59} +} {2 4 eda88259} test encoding-15.14 {UtfToUtfProc high surrogate character output} { set x \uDE02 set y [encoding convertto -nothrow utf-8 \uDE02] binary scan $y H* z list [string length $x] [string length $y] $z -} {1 3 efbfbd} +} {1 3 edb882} test encoding-15.15 {UtfToUtfProc low surrogate character output} { set x \uDA02 set y [encoding convertto -nothrow utf-8 \uDA02] binary scan $y H* z list [string length $x] [string length $y] $z -} {1 3 efbfbd} +} {1 3 eda882} test encoding-15.16 {UtfToUtfProc: Invalid 4-byte UTF-8, see [ed29806ba]} { set x \xF0\xA0\xA1\xC2 set y [encoding convertfrom -nothrow utf-8 \xF0\xA0\xA1\xC2] |
