summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-02-15 17:21:46 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-02-15 17:21:46 (GMT)
commitcce4368acee1315cdc42e9d8c5db59a8f479edf7 (patch)
treeb2a4f41ecf27460a31caf03b2d7e86e9407f1d8b /generic
parent7a1cc7e3b33b8f9f64a8e50228c7e10187a67397 (diff)
downloadtcl-cce4368acee1315cdc42e9d8c5db59a8f479edf7.zip
tcl-cce4368acee1315cdc42e9d8c5db59a8f479edf7.tar.gz
tcl-cce4368acee1315cdc42e9d8c5db59a8f479edf7.tar.bz2
Revert recent commit that changed behavior of TclGetIntForIndex() for a
small subset of cases of overflow in index arithmetic. This changed the public behavior of indexes. I favor what's being done. I only want to do the complete work on a feature branch (coming soon), and consider what aspects may benefit from a TIP, and how we should future-proof the work against expanding ranges for valid index values in Tcl 9. This touches on issues partially raised in TIP 297.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclUtil.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index e90477f..9557aac 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3585,16 +3585,7 @@ TclGetIntForIndex(
* be converted to one, use it.
*/
- Tcl_WideInt value = endValue + objPtr->internalRep.wideValue;
- if (endValue > 0 && value < objPtr->internalRep.wideValue) {
- *indexPtr = INT_MAX; /* numerical overflow */
- } else if (value < INT_MIN || (endValue < 0 && value > objPtr->internalRep.wideValue)) {
- *indexPtr = INT_MIN; /* numerical underflow or value < INT_MIN */
- } else if (value > INT_MAX) {
- *indexPtr = INT_MAX;/* value > INT_MAX */
- } else {
- *indexPtr = (int) value;
- }
+ *indexPtr = endValue + (int)objPtr->internalRep.wideValue;
return TCL_OK;
}