diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-01-21 08:43:13 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-01-21 08:43:13 (GMT) |
commit | e433c571581eae56161e5c4dc8dcae36e31d8039 (patch) | |
tree | 36698f2a361c6024031bb23cd0e99685df4267d1 /generic/tclUtil.c | |
parent | b97786c85dbd70fd4445f8161b205d5dbc56e844 (diff) | |
download | tcl-e433c571581eae56161e5c4dc8dcae36e31d8039.zip tcl-e433c571581eae56161e5c4dc8dcae36e31d8039.tar.gz tcl-e433c571581eae56161e5c4dc8dcae36e31d8039.tar.bz2 |
Add test-cases for Tcl_GetIntForIndex(). This reveals a minor bug
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 86b6369..10153fb 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3647,15 +3647,12 @@ GetWideForIndex( if (numType == TCL_NUMBER_INT) { /* objPtr holds an integer in the signed wide range */ *widePtr = *(Tcl_WideInt *)cd; - if (*widePtr < -1) { - *widePtr = -1; - } return TCL_OK; } if (numType == TCL_NUMBER_BIG) { /* objPtr holds an integer outside the signed wide range */ /* Truncate to the signed wide range. */ - *widePtr = ((mp_isneg((mp_int *)cd)) ? -1 : WIDE_MAX); + *widePtr = ((mp_isneg((mp_int *)cd)) ? WIDE_MIN : WIDE_MAX); return TCL_OK; } } @@ -3706,7 +3703,7 @@ Tcl_GetIntForIndex( return TCL_ERROR; } if (indexPtr != NULL) { - if ((wide < 0) && (endValue > TCL_INDEX_END)) { + if ((wide < 0) && (endValue >= 0)) { *indexPtr = -1; } else if (wide > INT_MAX) { *indexPtr = INT_MAX; |