diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-07-23 13:59:40 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-07-23 13:59:40 (GMT) |
commit | 571fd220b0be2da05b1a6e8bb32e0b9a447ed288 (patch) | |
tree | 46a3064598e4a36c7ca561f9c08f5d22de4b2b9e /generic/tkListbox.c | |
parent | ed7fb54396eee6e5122bfe611b2a14cf422970fa (diff) | |
download | tk-571fd220b0be2da05b1a6e8bb32e0b9a447ed288.zip tk-571fd220b0be2da05b1a6e8bb32e0b9a447ed288.tar.gz tk-571fd220b0be2da05b1a6e8bb32e0b9a447ed288.tar.bz2 |
Much more cleaning up of result handling.
Diffstat (limited to 'generic/tkListbox.c')
-rw-r--r-- | generic/tkListbox.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c index e8817af..355db5b 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -872,8 +872,10 @@ ListboxWidgetObjCmd( } if (index < 0 || index >= listPtr->nElements) { - Tcl_AppendResult(interp, "item number \"", - Tcl_GetString(objv[2]), "\" out of range", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "item number \"%s\" out of range", + Tcl_GetString(objv[2]))); + Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEMIDX", NULL); result = TCL_ERROR; break; } @@ -907,8 +909,10 @@ ListboxWidgetObjCmd( } if (index < 0 || index >= listPtr->nElements) { - Tcl_AppendResult(interp, "item number \"", Tcl_GetString(objv[2]), - "\" out of range", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "item number \"%s\" out of range", + Tcl_GetString(objv[2]))); + Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEMIDX", NULL); result = TCL_ERROR; break; } @@ -2742,18 +2746,12 @@ GetListboxIndex( start = stringRep + 1; y = strtol(start, &end, 0); if ((start == end) || (*end != ',')) { - Tcl_AppendResult(interp, "bad listbox index \"", stringRep, - "\": must be active, anchor, end, @x,y, or a number", - NULL); - return TCL_ERROR; + goto badIndex; } start = end+1; y = strtol(start, &end, 0); if ((start == end) || (*end != '\0')) { - Tcl_AppendResult(interp, "bad listbox index \"", stringRep, - "\": must be active, anchor, end, @x,y, or a number", - NULL); - return TCL_ERROR; + goto badIndex; } *indexPtr = NearestListboxElement(listPtr, y); return TCL_OK; @@ -2771,10 +2769,11 @@ GetListboxIndex( * Everything failed, nothing matched. Throw up an error message. */ - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad listbox index \"", - Tcl_GetString(indexObj), "\": must be active, anchor, ", - "end, @x,y, or a number", NULL); + badIndex: + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "bad listbox index \"%s\": must be active, anchor, end, @x,y," + " or a number", Tcl_GetString(indexObj))); + Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", NULL); return TCL_ERROR; } |