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 | aa23371ad970074cb736062b7818877657b8243b (patch) | |
tree | cea6b362d1fc7f6315ccc14561204ab0e5ef465d /generic/tclCmdIL.c | |
parent | 3c7e5cc3a228b2a86bc56bad4fc6961a21500fc0 (diff) | |
download | tcl-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.c | 13 |
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; |