diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-18 22:18:06 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-18 22:18:06 (GMT) |
commit | 3dd30ce854309c3433f211cacf5c430b9e8d0005 (patch) | |
tree | cea6b362d1fc7f6315ccc14561204ab0e5ef465d /generic/tclUtil.c | |
parent | 257a1027899b2e8dc1cfec0d19b966d43d5f9cb2 (diff) | |
download | tcl-3dd30ce854309c3433f211cacf5c430b9e8d0005.zip tcl-3dd30ce854309c3433f211cacf5c430b9e8d0005.tar.gz tcl-3dd30ce854309c3433f211cacf5c430b9e8d0005.tar.bz2 |
Clamp output of TclIndexDecode() between -1 (TCL_INDEX_NONE) and INT_MAX. Use this to produce slightly better error-message for lsort -index
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index a2670d5..04fc2af 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -4159,10 +4159,14 @@ TclIndexDecode( int encoded, /* Value to decode */ int endValue) /* Meaning of "end" to use, > TCL_INDEX_END */ { - if (encoded <= TCL_INDEX_END) { - return (encoded - TCL_INDEX_END) + endValue; + if (encoded > TCL_INDEX_END) { + return encoded; } - return encoded; + endValue += encoded - TCL_INDEX_END; + if (endValue >= 0) { + return endValue; + } + return TCL_INDEX_NONE; } /* |