summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-18 22:18:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-18 22:18:06 (GMT)
commitaa23371ad970074cb736062b7818877657b8243b (patch)
treecea6b362d1fc7f6315ccc14561204ab0e5ef465d /generic/tclCmdIL.c
parent3c7e5cc3a228b2a86bc56bad4fc6961a21500fc0 (diff)
downloadtcl-aa23371ad970074cb736062b7818877657b8243b.zip
tcl-aa23371ad970074cb736062b7818877657b8243b.tar.gz
tcl-aa23371ad970074cb736062b7818877657b8243b.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/tclCmdIL.c')
-rw-r--r--generic/tclCmdIL.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 34e9382..a1a7f3e 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -4720,9 +4720,16 @@ SelectObjFromSublist(
return NULL;
}
if (currentObj == NULL) {
- Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf(
- "element %d missing from sublist \"%s\"",
- index, TclGetString(objPtr)));
+ if (index == TCL_INDEX_NONE) {
+ index = TCL_INDEX_END - infoPtr->indexv[i];
+ Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf(
+ "element end-%d missing from sublist \"%s\"",
+ index, TclGetString(objPtr)));
+ } else {
+ Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf(
+ "element %d missing from sublist \"%s\"",
+ index, TclGetString(objPtr)));
+ }
Tcl_SetErrorCode(infoPtr->interp, "TCL", "OPERATION", "LSORT",
"INDEXFAILED", NULL);
infoPtr->resultCode = TCL_ERROR;