diff options
| author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-08-13 11:56:12 (GMT) |
|---|---|---|
| committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-08-13 11:56:12 (GMT) |
| commit | e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130 (patch) | |
| tree | 39da0c77e31060d81deb9f63f75cc5e0309855dd /generic/tclUtil.c | |
| parent | 5860a8926709c0d0c4fad457796af2b666a39ca1 (diff) | |
| download | tcl-e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130.zip tcl-e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130.tar.gz tcl-e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130.tar.bz2 | |
Merge in fix for end+1 indices.
Diffstat (limited to 'generic/tclUtil.c')
| -rw-r--r-- | generic/tclUtil.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index ff212b0..858a490 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3702,14 +3702,15 @@ GetEndOffsetFromObj( if (offset == WIDE_MAX) { /* - * Encodes end+1. This is distinguished from end+n as noted above + * Encodes end+1. This is distinguished from end+n as noted + * in function header. * NOTE: this may wrap around if the caller passes (as lset does) * listLen-1 as endValue and and listLen is 0. The -1 will be * interpreted as FF...FF and adding 1 will result in 0 which - * is what we want. 2's complements shenanigans but it is what - * it is ... + * is what we want. Callers like lset which pass in listLen-1 == -1 + * as endValue will have to adjust accordingly. */ - *widePtr = endValue + 1; + *widePtr = (endValue == -1) ? WIDE_MAX : endValue + 1; } else if (offset == WIDE_MIN) { /* -1 - position before first */ *widePtr = -1; |
