summaryrefslogtreecommitdiffstats
path: root/generic/tkTextIndex.c
diff options
context:
space:
mode:
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;
}