summaryrefslogtreecommitdiffstats
path: root/generic/tkTextIndex.c
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2012-07-23 13:59:40 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2012-07-23 13:59:40 (GMT)
commit8e22eb240dbf4a13c6d6b5b8267751a3f860c51e (patch)
tree9c0e2a2eb71e34b866e450452627d96c4af9cd52 /generic/tkTextIndex.c
parent46e7eae0c2d02ec44e847b96dd0df9ebbcdce3ac (diff)
downloadtk-8e22eb240dbf4a13c6d6b5b8267751a3f860c51e.zip
tk-8e22eb240dbf4a13c6d6b5b8267751a3f860c51e.tar.gz
tk-8e22eb240dbf4a13c6d6b5b8267751a3f860c51e.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;
}