summaryrefslogtreecommitdiffstats
path: root/generic/tkTextIndex.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-07-23 13:59:40 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-07-23 13:59:40 (GMT)
commit22a0b0ed3f7f0da75210a6d854fc4a7703b3c640 (patch)
tree46a3064598e4a36c7ca561f9c08f5d22de4b2b9e /generic/tkTextIndex.c
parent7c4fea3383697638df3c0d27196fc5ba61591ad7 (diff)
downloadtk-22a0b0ed3f7f0da75210a6d854fc4a7703b3c640.zip
tk-22a0b0ed3f7f0da75210a6d854fc4a7703b3c640.tar.gz
tk-22a0b0ed3f7f0da75210a6d854fc4a7703b3c640.tar.bz2
Much more cleaning up of result handling.
Diffstat (limited to 'generic/tkTextIndex.c')
-rw-r--r--generic/tkTextIndex.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index c11ce0b..4fe97eb 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -84,6 +84,7 @@ FreeTextIndexInternalRep(
* free. */
{
TkTextIndex *indexPtr = GET_TEXTINDEX(indexObjPtr);
+
if (indexPtr->textPtr != NULL) {
if (--indexPtr->textPtr->refCount == 0) {
/*
@@ -133,7 +134,6 @@ UpdateStringOfTextIndex(
{
char buffer[TK_POS_CHARS];
register int len;
-
const TkTextIndex *indexPtr = GET_TEXTINDEX(objPtr);
len = TkTextPrintIndex(indexPtr->textPtr, indexPtr, buffer);
@@ -148,8 +148,10 @@ SetTextIndexFromAny(
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
Tcl_Obj *objPtr) /* The object to convert. */
{
- Tcl_AppendResult(interp, "can't convert value to textindex except "
- "via TkTextGetIndexFromObj API", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't convert value to textindex except via"
+ " TkTextGetIndexFromObj API", -1));
+ Tcl_SetErrorCode(interp, "TK", "ILLEGAL_API_USAGE", NULL);
return TCL_ERROR;
}
@@ -835,10 +837,10 @@ GetIndex(
tagName = Tcl_GetHashKey(&sharedPtr->tagTable, hPtr);
}
}
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "text doesn't contain any characters tagged with \"",
- tagName, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "text doesn't contain any characters tagged with \"%s\"",
+ tagName));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_INDEX", NULL);
Tcl_DStringFree(&copy);
return TCL_ERROR;
}
@@ -1001,8 +1003,8 @@ GetIndex(
error:
Tcl_DStringFree(&copy);
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad text index \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad text index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", NULL);
return TCL_ERROR;
}