From 3c0c59407f61fb9c78ced15b50d084b3670ca7b8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 Oct 2020 11:29:22 +0000 Subject: Fix warning on MSVC: warning C4307: '+': integral constant overflow --- generic/tclInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 2e88348..c536aee 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4851,7 +4851,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; (objPtr) = Tcl_NewWideIntObj(w) #define TclNewIndexObj(objPtr, w) \ - (objPtr) = Tcl_NewWideIntObj((Tcl_WideInt)((w) + 1) - 1) + (objPtr) = (w == TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w) #define TclNewDoubleObj(objPtr, d) \ (objPtr) = Tcl_NewDoubleObj(d) -- cgit v0.12 From 8ac4aee0fc7e4d4020c874ab41fecad788d1c848 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 20 Oct 2020 10:31:34 +0000 Subject: One more attempt to fix the MSVC++ warning for Debug builds --- generic/tclInt.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index c536aee..2a0dfa6 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4816,11 +4816,12 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; #define TclNewIndexObj(objPtr, w) \ do { \ + size_t _w = (w); \ TclIncrObjsAllocated(); \ TclAllocObjStorage(objPtr); \ (objPtr)->refCount = 0; \ (objPtr)->bytes = NULL; \ - (objPtr)->internalRep.wideValue = (Tcl_WideInt)((w) + 1) - 1; \ + (objPtr)->internalRep.wideValue = ((_w) == TCL_INDEX_NONE) ? -1 : (Tcl_WideInt)(_w); \ (objPtr)->typePtr = &tclIntType; \ TCL_DTRACE_OBJ_CREATE(objPtr); \ } while (0) @@ -4851,7 +4852,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; (objPtr) = Tcl_NewWideIntObj(w) #define TclNewIndexObj(objPtr, w) \ - (objPtr) = (w == TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w) + (objPtr) = ((w) == TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w) #define TclNewDoubleObj(objPtr, d) \ (objPtr) = Tcl_NewDoubleObj(d) -- cgit v0.12 -- cgit v0.12 From da7ec341ce01a8f3499ecb556c739ef4dfa9c6e4 Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 26 Nov 2020 00:30:43 +0000 Subject: grammar --- doc/Tcl.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Tcl.n b/doc/Tcl.n index 48a3488..0f46f73 100644 --- a/doc/Tcl.n +++ b/doc/Tcl.n @@ -224,7 +224,7 @@ is reached. The upper bits of the Unicode character will be 0. .RS .PP The range U+00D800\(enU+00DFFF is reserved for surrogates, which -are illegal on its own. Therefore, such sequences will result in +are illegal on their own. Therefore, such sequences will result in the replacement character U+FFFD. Surrogate pairs should be encoded as single \e\fBU\fIhhhhhhhh\fR character. .RE -- cgit v0.12 From e6d3b1557cc89901800f050c7a8fcc5fe20c99ab Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 26 Nov 2020 00:38:21 +0000 Subject: silence warning re: sign-compare --- generic/tclInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 3a759ca..92945ca 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4854,7 +4854,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; (objPtr) = Tcl_NewWideIntObj(w) #define TclNewIndexObj(objPtr, w) \ - (objPtr) = ((w) == TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w) + (objPtr) = (((size_t)w) == TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideIntObj(w) #define TclNewDoubleObj(objPtr, d) \ (objPtr) = Tcl_NewDoubleObj(d) -- cgit v0.12 From 888a59788321731a3060797cac7db475eb6d9028 Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 26 Nov 2020 03:26:05 +0000 Subject: use new TIP 494 64bit/#define in code comment to be consistent w/ code --- generic/tclStringObj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 9f46b9d..1ac0aeb 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -1162,7 +1162,7 @@ Tcl_AppendToObj( const char *bytes, /* Points to the bytes to append to the * object. */ size_t length) /* The number of bytes to append from "bytes". - * If -1, then append all bytes up to NUL + * If TCL_INDEX_NONE, then append all bytes up to NUL * byte. */ { Tcl_AppendLimitedToObj(objPtr, bytes, length, TCL_INDEX_NONE, NULL); -- cgit v0.12 From 5e62e86d4c48da0f90984d1d69a7ecc8160659d7 Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 26 Nov 2020 03:27:15 +0000 Subject: squelch -Wunused warning --- generic/tclExecute.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 60f8928..05c1ceb 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -9336,6 +9336,7 @@ EvalStatsCmd( char *litTableStats; LiteralEntry *entryPtr; Tcl_Obj *objPtr; + (void)unused; #define Percent(a,b) ((a) * 100.0 / (b)) -- cgit v0.12 From 4a6876c53700885e4b6c5b9613d59784387c0b82 Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 26 Nov 2020 03:34:47 +0000 Subject: squelch warning by using proper(?) format specifiers; intent needs TBD, so committing to branch for review --- generic/tclExecute.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 05c1ceb..466e89e 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5356,14 +5356,14 @@ TEBCresume( case INST_STR_FIND: objResultPtr = TclStringFirst(OBJ_UNDER_TOS, OBJ_AT_TOS, 0); - TRACE(("%.20s %.20s => %d\n", + TRACE(("%.20s %.20s => %p\n", O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), O2S(objResultPtr))); NEXT_INST_F(1, 2, 1); case INST_STR_FIND_LAST: objResultPtr = TclStringLast(OBJ_UNDER_TOS, OBJ_AT_TOS, INT_MAX - 1); - TRACE(("%.20s %.20s => %d\n", + TRACE(("%.20s %.20s => %p\n", O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), O2S(objResultPtr))); NEXT_INST_F(1, 2, 1); -- cgit v0.12 From c53412abcf8c4ce4eb65bde9e5c72d5d5611b5ad Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 26 Nov 2020 03:49:18 +0000 Subject: adjust for() loop controls to squelch sign-compare warning, move maxSizeDecade assignment to maintain identical functionality --- generic/tclExecute.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 466e89e..91bcb91 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -9612,12 +9612,13 @@ EvalStatsCmd( break; } } - for (i = 31; i >= 0; i--) { + for (i = 31; i; i--) { if (statsPtr->srcCount[i] > 0) { - maxSizeDecade = i; - break; + break; /* maxSizeDecade to consume 'i' value + * below... */ } } + maxSizeDecade = i; sum = 0; for (i = minSizeDecade; i <= maxSizeDecade; i++) { decadeHigh = (1 << (i+1)) - 1; @@ -9635,12 +9636,13 @@ EvalStatsCmd( break; } } - for (i = 31; i >= 0; i--) { + for (i = 31; i; i--) { if (statsPtr->byteCodeCount[i] > 0) { - maxSizeDecade = i; - break; + break; /* maxSizeDecade to consume 'i' value + * below... */ } } + maxSizeDecade = i; sum = 0; for (i = minSizeDecade; i <= maxSizeDecade; i++) { decadeHigh = (1 << (i+1)) - 1; @@ -9658,12 +9660,13 @@ EvalStatsCmd( break; } } - for (i = 31; i >= 0; i--) { + for (i = 31; i; i--) { if (statsPtr->lifetimeCount[i] > 0) { - maxSizeDecade = i; - break; + break; /* maxSizeDecade to consume 'i' value + * below... */ } } + maxSizeDecade = i; sum = 0; for (i = minSizeDecade; i <= maxSizeDecade; i++) { decadeHigh = (1 << (i+1)) - 1; -- cgit v0.12 From 42b1424fc5d7d2f09ff77fa4b4a30da726e45627 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 27 Nov 2020 11:28:03 +0000 Subject: Fix compilation error --- generic/tclExecute.c | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 32d6458..910a751 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -9336,7 +9336,6 @@ EvalStatsCmd( char *litTableStats; LiteralEntry *entryPtr; Tcl_Obj *objPtr; - (void)unused; #define Percent(a,b) ((a) * 100.0 / (b)) -- cgit v0.12 From c9c1696a2d8c2c3d094e54b96defd269c0687692 Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 6 Dec 2020 18:39:21 +0000 Subject: allow NULL for indexPtr to say "am not interested in index, just membership in set of possibilities" for Tcl_GetIndexFromObj() --- doc/GetIndex.3 | 8 ++++---- generic/tclIndexObj.c | 31 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/GetIndex.3 b/doc/GetIndex.3 index 8591c56..111ae62 100644 --- a/doc/GetIndex.3 +++ b/doc/GetIndex.3 @@ -56,8 +56,8 @@ OR-ed combination of bits providing additional information for operation. The only bits that are currently defined are \fBTCL_EXACT\fR and \fBTCL_INDEX_TEMP_TABLE\fR. .AP int *indexPtr out -The index of the string in \fItablePtr\fR that matches the value of -\fIobjPtr\fR is returned here. +If not NULL, the index of the string in \fItablePtr\fR that matches +the value of \fIobjPtr\fR is returned here. .BE .SH DESCRIPTION .PP @@ -70,8 +70,8 @@ the strings in \fItablePtr\fR to find a match. A match occurs if \fItablePtr\fR, or if it is a non-empty unique abbreviation for exactly one of the strings in \fItablePtr\fR and the \fBTCL_EXACT\fR flag was not specified; in either case -the index of the matching entry is stored at \fI*indexPtr\fR -and \fBTCL_OK\fR is returned. +\fBTCL_OK\fR is returned. If \fI*indexPtr\fR is not NULL the index +of the matching entry is stored there. .PP If there is no matching entry, \fBTCL_ERROR\fR is returned and an error message is left in \fIinterp\fR's diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 89582b7..c3092c9 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -166,11 +166,12 @@ GetIndexFromObjList( * Results: * If the value of objPtr is identical to or a unique abbreviation for * one of the entries in tablePtr, then the return value is TCL_OK and - * the index of the matching entry is stored at *indexPtr. If there isn't - * a proper match, then TCL_ERROR is returned and an error message is - * left in interp's result (unless interp is NULL). The msg argument is - * used in the error message; for example, if msg has the value "option" - * then the error message will say something like 'bad option "foo": must + * the index of the matching entry is stored at *indexPtr + * (unless indexPtr is NULL). If there isn't a proper match, then + * TCL_ERROR is returned and an error message is left in interp's + * result (unless interp is NULL). The msg argument is used in the + * error message; for example, if msg has the value "option" then + * the error message will say something like 'bad option "foo": must * be ...' * * Side effects: @@ -212,15 +213,17 @@ Tcl_GetIndexFromObjStruct( */ if (!(flags & TCL_INDEX_TEMP_TABLE)) { - irPtr = TclFetchIntRep(objPtr, &indexType); - if (irPtr) { - indexRep = (IndexRep *)irPtr->twoPtrValue.ptr1; - if (indexRep->tablePtr==tablePtr && indexRep->offset==offset) { - *indexPtr = indexRep->index; - return TCL_OK; + irPtr = TclFetchIntRep (objPtr, &indexType); + if (irPtr) { + indexRep = (IndexRep *) irPtr->twoPtrValue.ptr1; + if (indexRep->tablePtr == tablePtr && indexRep->offset == offset) { + if (indexPtr != NULL) { + *indexPtr = indexRep->index; + } + return TCL_OK; + } } } - } /* * Lookup the value of the object in the table. Accept unique @@ -291,7 +294,9 @@ Tcl_GetIndexFromObjStruct( indexRep->index = index; } - *indexPtr = index; + if(indexPtr != NULL) { + *indexPtr = index; + } return TCL_OK; error: -- cgit v0.12 From 902547c2b25bc92a576879d666aaf79c6e635aab Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 6 Dec 2020 20:57:32 +0000 Subject: comment grammar --- generic/tcl.decls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index dc57324..eacfb28 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -24,8 +24,8 @@ hooks {tclPlat tclInt tclIntPlat} scspec EXTERN # Declare each of the functions in the public Tcl interface. Note that -# the an index should never be reused for a different function in order -# to preserve backwards compatibility. +# in order to preserve backwards compatibility an index should +# never be reused for a different function declare 0 { int Tcl_PkgProvideEx(Tcl_Interp *interp, const char *name, -- cgit v0.12 From 933584b14430d2c9df09702eb344ff261bd40776 Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 6 Dec 2020 20:58:21 +0000 Subject: Period. --- generic/tcl.decls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index eacfb28..4362c4c 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -25,7 +25,7 @@ scspec EXTERN # Declare each of the functions in the public Tcl interface. Note that # in order to preserve backwards compatibility an index should -# never be reused for a different function +# never be reused for a different function. declare 0 { int Tcl_PkgProvideEx(Tcl_Interp *interp, const char *name, -- cgit v0.12