summaryrefslogtreecommitdiffstats
path: root/generic/tkListbox.c
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2012-07-23 13:59:40 (GMT)
committerdkf <dkf@noemail.net>2012-07-23 13:59:40 (GMT)
commitdb0b8cc05b59328e7eacfb833b975f732be99327 (patch)
tree46a3064598e4a36c7ca561f9c08f5d22de4b2b9e /generic/tkListbox.c
parent0818005fbf7d6865ab4bdd2c4f2e6695d821823a (diff)
downloadtk-db0b8cc05b59328e7eacfb833b975f732be99327.zip
tk-db0b8cc05b59328e7eacfb833b975f732be99327.tar.gz
tk-db0b8cc05b59328e7eacfb833b975f732be99327.tar.bz2
Much more cleaning up of result handling.
FossilOrigin-Name: 016ad9dac31d39cbc9ded6a6e8e75c11618318a8
Diffstat (limited to 'generic/tkListbox.c')
-rw-r--r--generic/tkListbox.c31
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;
}