From 2fa8967c62a728986e69c0adfcc433c8da2d6dd4 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Jan 2022 14:19:04 +0000 Subject: Proposed fix for [26f1328a86]: sizeof(int) < sizeof(void*) -> Crash --- generic/tclCompile.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 03b4a90..997f08e 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -1509,22 +1509,22 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData 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 -- cgit v0.12 From 2171b321cf1ec2d7c671d02dfea59860bccc06f2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Jan 2022 15:50:30 +0000 Subject: Fix [69218ab7b]: TEBCResume(): buffer over-read in INST_STR_MAP --- generic/tclExecute.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 7e014d4..aa5730a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5855,7 +5855,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) { -- cgit v0.12 From 05dc6d00c28c40fef2b65cf96d5753927599c4d5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Jan 2022 16:33:51 +0000 Subject: Fix [da6f155ca4]: STRING_SIZE() macro: parenthesize numChars usage. Fix more macro's like this. --- generic/tclCkalloc.c | 2 +- generic/tclDate.c | 4 ++-- generic/tclExecute.c | 14 +++++++------- generic/tclGetDate.y | 4 ++-- generic/tclIORChan.c | 2 +- generic/tclIORTrans.c | 2 +- generic/tclInt.h | 2 +- generic/tclOOInt.h | 2 +- generic/tclStringRep.h | 2 +- generic/tclTrace.c | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 48832d9..8c83aeb 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) ((unsigned) ((TclOffset(MemTag, string) + 1) + bytesInString)) +#define TAG_SIZE(bytesInString) ((unsigned) ((TclOffset(MemTag, string) + 1) + (bytesInString))) static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set * by "memory tag" command). */ diff --git a/generic/tclDate.c b/generic/tclDate.c index aa199c3..23cf336 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/tclExecute.c b/generic/tclExecute.c index 7e014d4..5dc506a 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() \ @@ -8462,24 +8462,24 @@ ExecuteExtendedBinaryMathOp( { #define LONG_RESULT(l) \ if (Tcl_IsShared(valuePtr)) { \ - TclNewLongObj(objResultPtr, l); \ + TclNewLongObj(objResultPtr, (l)); \ return objResultPtr; \ } else { \ - Tcl_SetLongObj(valuePtr, l); \ + Tcl_SetLongObj(valuePtr, (l)); \ return NULL; \ } #define WIDE_RESULT(w) \ if (Tcl_IsShared(valuePtr)) { \ return Tcl_NewWideIntObj(w); \ } else { \ - Tcl_SetWideIntObj(valuePtr, w); \ + Tcl_SetWideIntObj(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) \ diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index e6748a4..7e26b37 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/tclIORChan.c b/generic/tclIORChan.c index c48c904..8e358e0 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -200,7 +200,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)) #ifdef TCL_THREADS /* diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 039b594..e0c39ad 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -216,7 +216,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)) #ifdef TCL_THREADS /* diff --git a/generic/tclInt.h b/generic/tclInt.h index 491abe6..1954a13 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4958,7 +4958,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((char *) (ptr)) #endif diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h index 44316ac..f061bc6 100644 --- a/generic/tclOOInt.h +++ b/generic/tclOOInt.h @@ -561,7 +561,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) /* * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h index 25b854e..59e9499 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -67,7 +67,7 @@ typedef struct String { #define STRING_MAXCHARS \ (int)(((size_t)UINT_MAX - 1 - TclOffset(String, unicode))/sizeof(Tcl_UniChar)) #define STRING_SIZE(numChars) \ - (TclOffset(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar))) + (TclOffset(String, unicode) + (((numChars) + 1) * sizeof(Tcl_UniChar))) #define stringCheckLimits(numChars) \ do { \ if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \ diff --git a/generic/tclTrace.c b/generic/tclTrace.c index c82fc14..5ce4b95 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -160,8 +160,8 @@ typedef struct StringTraceData { #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) /* *---------------------------------------------------------------------- -- cgit v0.12 From 32ab46ae406d7fd3db0516dd45f38c7c48c6bd3c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Jan 2022 21:39:40 +0000 Subject: Fix [fba9c1fc12]: pointer arithmetic using NULL in PrintParse() --- generic/tclTest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tclTest.c b/generic/tclTest.c index 5774dfc..ed016fe 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -3596,8 +3596,9 @@ PrintParse( Tcl_NewIntObj(tokenPtr->numComponents)); } Tcl_ListObjAppendElement(NULL, objPtr, + parsePtr->commandStart ? Tcl_NewStringObj(parsePtr->commandStart + parsePtr->commandSize, - -1)); + -1) : Tcl_NewObj()); } /* -- cgit v0.12 From e874b759fc95fea19afd03d71388ed379872493f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Jan 2022 11:12:40 +0000 Subject: Suggested fix for [bca10e3790]: Undefined behavior in ResultAdd(). Make functions like ResultAdd() equal in tclIOGt.c and tclIOTrans.c --- generic/tclIOGT.c | 8 ++++---- generic/tclIORTrans.c | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c index dadcb53..6b1c341 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); @@ -1361,13 +1361,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. */ @@ -1424,7 +1424,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/tclIORTrans.c b/generic/tclIORTrans.c index e0c39ad..eecd412 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -85,22 +85,22 @@ static const Tcl_ChannelType tclRTransformType = { * layers upon reading from the channel, plus the functions to manage such. */ -typedef struct _ResultBuffer_ { +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) @@ -2934,7 +2934,7 @@ TimerRun( *---------------------------------------------------------------------- */ -static void +static inline void ResultInit( ResultBuffer *rPtr) /* Reference to the structure to * initialize. */ @@ -2959,7 +2959,7 @@ ResultInit( *---------------------------------------------------------------------- */ -static void +static inline void ResultClear( ResultBuffer *rPtr) /* Reference to the buffer to clear out */ { @@ -2990,11 +2990,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) { /* @@ -3038,11 +3038,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; -- cgit v0.12 From d679a49bc0da1e368daa6af07fcf72af2e3dceb4 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Jan 2022 11:46:50 +0000 Subject: Fix [6cb3db4965]: pointer arithmetic using NULL in InitArgsAndLocals() --- generic/tclProc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclProc.c b/generic/tclProc.c index 642294c..7921d38 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -1428,7 +1428,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; @@ -1436,6 +1435,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) { /* -- cgit v0.12 From 1bc44ec32ab03ebaec021f52129ee1fefcac7850 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Jan 2022 12:22:51 +0000 Subject: Fix [816913a65e]: GrowStringBuffer(): signed integer overflow. And a few similar situations in other place --- generic/tclBinary.c | 2 +- generic/tclCkalloc.c | 2 +- generic/tclCompile.c | 2 +- generic/tclObj.c | 2 +- generic/tclProc.c | 2 +- generic/tclStringObj.c | 6 +++--- generic/tclStringRep.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 0296770..6f36d54 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -189,7 +189,7 @@ typedef struct ByteArray { } ByteArray; #define BYTEARRAY_SIZE(len) \ - ((unsigned) (TclOffset(ByteArray, bytes) + (len))) + (((unsigned)TclOffset(ByteArray, bytes) + (len))) #define GET_BYTEARRAY(objPtr) \ ((ByteArray *) (objPtr)->internalRep.twoPtrValue.ptr1) #define SET_BYTEARRAY(objPtr, baPtr) \ diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 8c83aeb..20285eb 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) ((unsigned) ((TclOffset(MemTag, string) + 1) + (bytesInString))) +#define TAG_SIZE(bytesInString) ((unsigned) ((TclOffset(MemTag, string) + 1U) + (bytesInString))) static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set * by "memory tag" command). */ diff --git a/generic/tclCompile.c b/generic/tclCompile.c index eb2e16b..4a50089 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -3010,7 +3010,7 @@ TclFindCompiledLocal( if (create || (name == NULL)) { localVar = procPtr->numCompiledLocals; - localPtr = ckalloc(TclOffset(CompiledLocal, name) + nameBytes + 1); + localPtr = ckalloc(TclOffset(CompiledLocal, name) + 1U + nameBytes); if (procPtr->firstLocalPtr == NULL) { procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr; } else { diff --git a/generic/tclObj.c b/generic/tclObj.c index 0950dcd..1fd674f 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -576,7 +576,7 @@ TclContinuationsEnter( ThreadSpecificData *tsdPtr = TclGetContLineTable(); Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry); - ContLineLoc *clLocPtr = (ContLineLoc *)ckalloc(TclOffset(ContLineLoc, loc) + (num + 1) *sizeof(int)); + ContLineLoc *clLocPtr = (ContLineLoc *)ckalloc(TclOffset(ContLineLoc, loc) + (num + 1U) *sizeof(int)); if (!newEntry) { /* diff --git a/generic/tclProc.c b/generic/tclProc.c index 7921d38..a533878 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -600,7 +600,7 @@ TclCreateProc( */ localPtr = (CompiledLocal *)ckalloc( - TclOffset(CompiledLocal, name) + fieldValues[0]->length + 1); + TclOffset(CompiledLocal, name) + 1U + fieldValues[0]->length); if (procPtr->firstLocalPtr == NULL) { procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr; } else { diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 75b449d..edfcb9f 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -151,7 +151,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) { /* @@ -164,7 +164,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) { @@ -173,7 +173,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 59e9499..c0adc10 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -67,7 +67,7 @@ typedef struct String { #define STRING_MAXCHARS \ (int)(((size_t)UINT_MAX - 1 - TclOffset(String, unicode))/sizeof(Tcl_UniChar)) #define STRING_SIZE(numChars) \ - (TclOffset(String, unicode) + (((numChars) + 1) * sizeof(Tcl_UniChar))) + (TclOffset(String, unicode) + (((numChars) + 1U) * sizeof(Tcl_UniChar))) #define stringCheckLimits(numChars) \ do { \ if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \ -- cgit v0.12 From c513699e2c1d661da77c76813d7bdac494bfae91 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 14 Jan 2022 15:44:02 +0000 Subject: Fix [b241e4ccc0]: Error while building with Tcl 8.7a5... --- generic/tclTomMathDecls.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 -- cgit v0.12 From 9bcfb6703d6eaa02bfcaad401aa83ce48309d4a1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 14 Jan 2022 22:34:06 +0000 Subject: Proposed fix for [6474fbd934]: Tcl 8.7a5: why utf-8 is different? --- generic/tclEncoding.c | 3 --- tests/encoding.test | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 57c6148..037beed 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2323,9 +2323,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/tests/encoding.test b/tests/encoding.test index c6f4e02..75e0dcc 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -349,61 +349,61 @@ test encoding-15.6 {UtfToUtfProc emoji character output} { set y [encoding convertto 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 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 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 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 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 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 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 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 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 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 utf-8 \xF0\xA0\xA1\xC2] -- cgit v0.12