summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-08-20 13:50:32 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-08-20 13:50:32 (GMT)
commit0009e78e1575784f367ef17fc6f4558832b855c9 (patch)
tree30c272c5f0c026b9bf7916a27eb60dba5641f781
parentc39fa63642ec703842ef984663c6fa78845f6ae6 (diff)
downloadtcl-0009e78e1575784f367ef17fc6f4558832b855c9.zip
tcl-0009e78e1575784f367ef17fc6f4558832b855c9.tar.gz
tcl-0009e78e1575784f367ef17fc6f4558832b855c9.tar.bz2
Fix [0af9450e56]: test incr-1.31 fails
-rw-r--r--generic/tclCompCmds.c2
-rw-r--r--generic/tclCompCmdsGR.c22
-rw-r--r--tests/incr.test2
3 files changed, 12 insertions, 14 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index a422072..16d5d50 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -608,11 +608,13 @@ TclCompileCatchCmd(
cmdTokenPtr = TokenAfter(parsePtr->tokenPtr);
if (parsePtr->numWords >= 3) {
resultNameTokenPtr = TokenAfter(cmdTokenPtr);
+ /* DGP */
resultIndex = LocalScalarFromToken(resultNameTokenPtr, envPtr);
if (resultIndex < 0) {
return TCL_ERROR;
}
+ /* DKF */
if (parsePtr->numWords == 4) {
optsNameTokenPtr = TokenAfter(resultNameTokenPtr);
optsIndex = LocalScalarFromToken(optsNameTokenPtr, envPtr);
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index b32440c..101c2ef 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -416,7 +416,7 @@ TclCompileIfCmd(
for (j = jumpEndFixupArray.next; j > 0; j--) {
jumpIndex = (j - 1); /* i.e. process the closest jump first. */
if (TclFixupForwardJumpToHere(envPtr,
- jumpEndFixupArray.fixup+jumpIndex, 127)) {
+ jumpEndFixupArray.fixup + jumpIndex, 127)) {
/*
* Adjust the immediately preceding "ifFalse" jump. We moved it's
* target (just after this jump) down three bytes.
@@ -479,7 +479,8 @@ TclCompileIncrCmd(
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *varTokenPtr, *incrTokenPtr;
- int isScalar, localIndex, haveImmValue, immValue;
+ int isScalar, localIndex, haveImmValue;
+ Tcl_WideInt immValue;
if ((parsePtr->numWords != 2) && (parsePtr->numWords != 3)) {
return TCL_ERROR;
@@ -506,17 +507,12 @@ TclCompileIncrCmd(
Tcl_Obj *intObj = Tcl_NewStringObj(word, numBytes);
Tcl_IncrRefCount(intObj);
- code = TclGetIntFromObj(NULL, intObj, &immValue);
- if ( (code == TCL_OK)
- && (-127 <= immValue) && (immValue <= 127)
- /* avoid overflow during string to int conversion (wide 0xFFFFFFFF to signed int -1): */
+ code = Tcl_GetWideIntFromObj(NULL, intObj, &immValue);
+ if ((code == TCL_OK) && (
#ifndef TCL_WIDE_INT_IS_LONG
- && ( (immValue >= 0)
- || (intObj->typePtr != &tclWideIntType)
- || ((-127 <= intObj->internalRep.wideValue) && (intObj->internalRep.wideValue <= 127))
- )
+ intObj->typePtr == &tclWideIntType ||
#endif
- ) {
+ intObj->typePtr == &tclIntType) && (-127 <= immValue) && (immValue <= 127)) {
haveImmValue = 1;
}
TclDecrRefCount(intObj);
@@ -2436,11 +2432,11 @@ TclCompileReturnCmd(
* General syntax: [return ?-option value ...? ?result?]
* An even number of words means an explicit result argument is present.
*/
- int level, code, objc, status = TCL_OK;
+ int level, code, status = TCL_OK;
int size;
int numWords = parsePtr->numWords;
int explicitResult = (0 == (numWords % 2));
- int numOptionWords = numWords - 1 - explicitResult;
+ int objc, numOptionWords = numWords - 1 - explicitResult;
Tcl_Obj *returnOpts, **objv;
Tcl_Token *wordTokenPtr = TokenAfter(parsePtr->tokenPtr);
diff --git a/tests/incr.test b/tests/incr.test
index 33ace2e..ff328b7 100644
--- a/tests/incr.test
+++ b/tests/incr.test
@@ -236,7 +236,7 @@ test incr-1.30 {TclCompileIncrCmd: array var, braced (no subs)} -setup {
incr {array($foo)}
} -result 5
-test incr-1.31 {no overflow in TclCompileIncrCmd and Tcl_IncrObjCmd, bug [7179c6724cd38271]} knownBug {
+test incr-1.31 {no overflow in TclCompileIncrCmd and Tcl_IncrObjCmd, bug [7179c6724cd38271]} {
# TclCompileIncrCmd: compiled incr TEBC with immutable constant offs (INST_INCR_*_IMM instructions):
lappend res [set i 0; incr i 0x7FFFFFFF]
lappend res [set i 0; incr i 0xFFFFFF80]