diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-06-21 14:52:44 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-06-21 14:52:44 (GMT) |
| commit | 7c2d72933f0d49aeac8e89082e833c41bda2b9f9 (patch) | |
| tree | 4f4e671d7ccf28e15e20081f6b1ae3749dfcafa3 | |
| parent | 09c0f6835523794621c9bae88e5ea3b955c14878 (diff) | |
| download | tcl-7c2d72933f0d49aeac8e89082e833c41bda2b9f9.zip tcl-7c2d72933f0d49aeac8e89082e833c41bda2b9f9.tar.gz tcl-7c2d72933f0d49aeac8e89082e833c41bda2b9f9.tar.bz2 | |
(partial) fix for [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a]. Tk needs some changes too
| -rw-r--r-- | generic/tclUtil.c | 5 | ||||
| -rw-r--r-- | tests/indexObj.test | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 30ae39a..074614f 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3660,6 +3660,9 @@ GetWideForIndex( if (numType == TCL_NUMBER_INT) { /* objPtr holds an integer in the signed wide range */ *widePtr = *(Tcl_WideInt *)cd; + if ((*widePtr < 0)) { + *widePtr = WIDE_MIN; + } return TCL_OK; } if (numType == TCL_NUMBER_BIG) { @@ -3966,7 +3969,7 @@ GetEndOffsetFromObj( offset = irPtr->wideValue; if (offset == WIDE_MAX) { - *widePtr = endValue + 1; + *widePtr = (endValue == (size_t)-1) ? WIDE_MAX : endValue + 1; } else if (offset == WIDE_MIN) { *widePtr = -1; } else if (endValue == (size_t)-1) { diff --git a/tests/indexObj.test b/tests/indexObj.test index 2c50200..1cf782a 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -211,10 +211,16 @@ test indexObj-8.13 {Tcl_GetIntForIndex end} testgetintforindex { } -2 test indexObj-8.14 {Tcl_GetIntForIndex end+1} testgetintforindex { testgetintforindex end+1 -1 -} 0 +} 2147483647 test indexObj-8.15 {Tcl_GetIntForIndex end+1} testgetintforindex { testgetintforindex end+1 -2 } -1 +test indexObj-8.16 {Tcl_GetIntForIndex integer} testgetintforindex { + testgetintforindex -1 -1 +} -2147483648 +test indexObj-8.17 {Tcl_GetIntForIndex integer} testgetintforindex { + testgetintforindex -2 -1 +} -2147483648 # cleanup ::tcltest::cleanupTests |
