diff options
| author | dgp <dgp@users.sourceforge.net> | 2018-02-15 17:21:46 (GMT) |
|---|---|---|
| committer | dgp <dgp@users.sourceforge.net> | 2018-02-15 17:21:46 (GMT) |
| commit | cce4368acee1315cdc42e9d8c5db59a8f479edf7 (patch) | |
| tree | b2a4f41ecf27460a31caf03b2d7e86e9407f1d8b | |
| parent | 7a1cc7e3b33b8f9f64a8e50228c7e10187a67397 (diff) | |
| download | tcl-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.
| -rw-r--r-- | generic/tclUtil.c | 11 | ||||
| -rw-r--r-- | tests/util.test | 6 |
2 files changed, 1 insertions, 16 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; } diff --git a/tests/util.test b/tests/util.test index d186523..35fc642 100644 --- a/tests/util.test +++ b/tests/util.test @@ -729,12 +729,6 @@ test util-9.43 {TclGetIntForIndex} -body { test util-9.44 {TclGetIntForIndex} -body { string index a 0+1000000000000 } -returnCodes error -match glob -result * -test util-9.45 {TclGetIntForIndex} { - string index abcd end+2305843009213693950 -} {} -test util-9.46 {TclGetIntForIndex} { - string index abcd end+4294967294 -} {} test util-10.1 {Tcl_PrintDouble - rounding} {ieeeFloatingPoint} { convertDouble 0x0000000000000000 |
