diff options
| -rw-r--r-- | generic/tclUtil.c | 10 | ||||
| -rw-r--r-- | tests/indexObj.test | 24 |
2 files changed, 16 insertions, 18 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index e82eea2..b87b5d6 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3706,18 +3706,12 @@ GetEndOffsetFromObj( * as endValue will have to adjust accordingly. */ *widePtr = (endValue == -1) ? WIDE_MAX : endValue + 1; - } else if (offset == WIDE_MIN) { - /* -1 - position before first */ - *widePtr = -1; } else if (offset < 0) { /* end-(n-1) - Different signs, sum cannot overflow */ *widePtr = endValue + offset + 1; - } else if (offset < WIDE_MAX) { - /* 0:WIDE_MAX-1 - plain old index. */ - *widePtr = offset; } else { - /* Huh, what case remains here? */ - *widePtr = WIDE_MAX; + /* 0:WIDE_MAX - plain old index. */ + *widePtr = offset; } return TCL_OK; diff --git a/tests/indexObj.test b/tests/indexObj.test index cf0f7df..c3f0676 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -20,7 +20,6 @@ testConstraint testindexobj [llength [info commands testindexobj]] testConstraint testgetintforindex [llength [info commands testgetintforindex]] testConstraint testparseargs [llength [info commands testparseargs]] testConstraint has64BitLengths [expr {$tcl_platform(pointerSize) == 8}] -testConstraint has32BitLengths [expr {$tcl_platform(pointerSize) == 4}] test indexObj-1.1 {exact match} testindexobj { testindexobj 1 1 xyz abc def xyz alm @@ -228,19 +227,24 @@ test indexObj-8.12 {Tcl_GetIntForIndex end} testgetintforindex { test indexObj-8.13 {Tcl_GetIntForIndex end} testgetintforindex { testgetintforindex end -2 } -2 -test indexObj-8.14 {Tcl_GetIntForIndex end+1} -constraints { - testgetintforindex has64BitLengths -} -body { +test indexObj-8.14 {Tcl_GetIntForIndex end+1} testgetintforindex { testgetintforindex end+1 -1 -} -result 9223372036854775807 -test indexObj-8.14.32bits {Tcl_GetIntForIndex end+1} -constraints { - testgetintforindex has32BitLengths -} -body { - testgetintforindex end+1 -1 -} -result 2147483647 +} [expr {[testConstraint has64BitLengths] ? 9223372036854775807 : 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 +} [expr {[testConstraint has64BitLengths] ? -9223372036854775808 : -2147483648}] +test indexObj-8.17 {Tcl_GetIntForIndex integer} testgetintforindex { + testgetintforindex -2 -1 +} [expr {[testConstraint has64BitLengths] ? -9223372036854775808 : -2147483648}] +test indexObj-8.18 {Tcl_GetIntForIndex n-m} testgetintforindex { + testgetintforindex 2-3 -1 +} [expr {[testConstraint has64BitLengths] ? -9223372036854775808 : -2147483648}] +test indexObj-8.19 {Tcl_GetIntForIndex n-m} testgetintforindex { + testgetintforindex 2-3 0 +} -1 # cleanup ::tcltest::cleanupTests |
