summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-07-30 07:46:19 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-07-30 07:46:19 (GMT)
commitca5623894dd113cd5642189574cf6c104c64cad8 (patch)
tree7e57204b12abc171ad343d007edecaf1b17cdf09 /generic
parent27b42b57118a651074b7f1fcc859fc4ae00090d0 (diff)
downloadtk-ca5623894dd113cd5642189574cf6c104c64cad8.zip
tk-ca5623894dd113cd5642189574cf6c104c64cad8.tar.gz
tk-ca5623894dd113cd5642189574cf6c104c64cad8.tar.bz2
Working towards making the error codes more consistent.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkArgv.c2
-rw-r--r--generic/tkBind.c11
-rw-r--r--generic/tkCanvArc.c4
-rw-r--r--generic/tkCanvBmap.c2
-rw-r--r--generic/tkCanvLine.c6
-rw-r--r--generic/tkCanvPoly.c4
-rw-r--r--generic/tkCanvText.c4
-rw-r--r--generic/tkCanvWind.c2
-rw-r--r--generic/tkCanvas.c2
-rw-r--r--generic/tkFont.c2
-rw-r--r--generic/tkGrab.c2
-rw-r--r--generic/tkGrid.c4
-rw-r--r--generic/tkImgBmap.c4
-rw-r--r--generic/tkImgPhoto.c67
-rw-r--r--generic/tkListbox.c4
-rw-r--r--generic/tkRectOval.c2
-rw-r--r--generic/tkText.c103
-rw-r--r--generic/tkTextIndex.c2
-rw-r--r--generic/tkTrig.c4
19 files changed, 113 insertions, 118 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index 56f628b..dbcfc7d 100644
--- a/generic/tkArgv.c
+++ b/generic/tkArgv.c
@@ -282,7 +282,7 @@ Tk_ParseArgv(
default:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad argument type %d in Tk_ArgvInfo", infoPtr->type));
- Tcl_SetErrorCode(interp, "TK", "ARG", "BAD_TYPE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
return TCL_ERROR;
}
}
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 58e91c4..974c1f9 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -2919,7 +2919,8 @@ HandleEventGenerate(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window id \"%s\" doesn't exist in this application",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW",
+ Tcl_GetString(objv[0]), NULL);
return TCL_ERROR;
}
@@ -3162,7 +3163,8 @@ HandleEventGenerate(
if (keysym == NoSymbol) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown keysym \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", value,
+ NULL);
return TCL_ERROR;
}
@@ -3170,7 +3172,8 @@ HandleEventGenerate(
if (event.general.xkey.keycode == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no keycode for keysym \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value,
+ NULL);
return TCL_ERROR;
}
if (!(flags & KEY)
@@ -3498,7 +3501,7 @@ NameToWindow(
badWindow:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad window name/identifier \"%s\"", name));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", name, NULL);
return TCL_ERROR;
}
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index d32c717..4e4c582 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -1997,7 +1997,7 @@ ArcToPostscript(
*/
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
@@ -2063,7 +2063,7 @@ StyleParseProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad -style option \"%s\": must be arc, chord, or pieslice",
value));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARCSTYLE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARC_STYLE", NULL);
*stylePtr = PIESLICE_STYLE;
return TCL_ERROR;
}
diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c
index 65c4b59..d7d54f4 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -991,7 +991,7 @@ BitmapToPostscript(
*/
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index ce51759..9d68c37 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -1800,7 +1800,7 @@ GetLineIndex(
badIndex:
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEMINDEX", "LINE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
return TCL_ERROR;
}
@@ -1918,7 +1918,7 @@ ParseArrowShape(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad arrow shape \"%s\": must be list with three numbers",
value));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROWSHAPE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW_SHAPE", NULL);
if (argv != NULL) {
ckfree(argv);
}
@@ -2433,7 +2433,7 @@ LineToPostscript(
done:
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index 7e2834d..f8ea42b 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -1732,7 +1732,7 @@ GetPolygonIndex(
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEMINDEX", "POLY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL);
return TCL_ERROR;
}
@@ -1981,7 +1981,7 @@ PolygonToPostscript(
done:
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index d972d48..eb8dfe3 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -1410,7 +1410,7 @@ GetTextIndex(
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEMINDEX", "TEXT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "TEXT", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -1641,7 +1641,7 @@ TextToPostscript(
done:
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
index 7ca7c9d..f183b35 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -904,7 +904,7 @@ CanvasPsWindow(
done:
if (result == TCL_OK) {
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
} else {
Tcl_DiscardInterpState(interpState);
}
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 97518f9..d6b6959 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -2317,7 +2317,7 @@ ConfigureCanvas(
if (argc2 != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad scrollRegion \"%s\"", canvasPtr->regionString));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLLREGION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLL_REGION", NULL);
badRegion:
ckfree(canvasPtr->regionString);
ckfree(argv2);
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 2e1ad01..2d74356 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -3325,7 +3325,7 @@ Tk_TextLayoutToPostscript(
}
}
Tcl_AppendToObj(psObj, ")]\n", -1);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
}
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index e825c7b..6a5fac6 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -552,7 +552,7 @@ Tk_Grab(
} else if (grabResult == GrabInvalidTime) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"grab failed: invalid time", -1));
- Tcl_SetErrorCode(interp, "TK", "GRAB", "BADTIME", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GRAB", "BAD_TIME", NULL);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"grab failed for unknown reason (code %d)", grabResult));
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index 6c5bbc1..c11d342 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -403,7 +403,7 @@ Tk_GridObjCmd(
/* This should not happen */
Tcl_SetObjResult(interp, Tcl_NewStringObj("internal error in grid", -1));
- Tcl_SetErrorCode(interp, "TK", "UNREACHABLE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
return TCL_ERROR;
}
@@ -1004,7 +1004,7 @@ GridRowColumnConfigureCommand(
if (lObjc == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("no %s indices specified",
(slotType == COLUMN) ? "column" : "row"));
- Tcl_SetErrorCode(interp, "TK", "GRID", "NOINDEX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GRID", "NO_INDEX", NULL);
Tcl_DecrRefCount(listCopy);
return TCL_ERROR;
}
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index f2558db..f57db55 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -1224,7 +1224,7 @@ ImgBmapPostscript(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unable to generate postscript for bitmaps larger than 60000"
" pixels", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "OUTSIZE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
return TCL_ERROR;
}
@@ -1304,7 +1304,7 @@ ImgBmapPostscript(
*/
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 3f25984..db59b86 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -575,7 +575,7 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside source image",
-1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "BAD_FROM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
return TCL_ERROR;
}
@@ -678,7 +678,7 @@ ImgPhotoCmd(
|| (options.fromY2 > masterPtr->height)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside image", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "BAD_FROM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
return TCL_ERROR;
}
@@ -793,7 +793,8 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s get: coordinates out of range",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "COORDINATES", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES",
+ NULL);
return TCL_ERROR;
}
@@ -890,8 +891,8 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"all elements of color list must have the same"
" number of elements", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "NON_RECTANGULAR",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NON_RECTANGULAR", NULL);
break;
}
@@ -1009,7 +1010,7 @@ ImgPhotoCmd(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't get image from a file in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "SAFE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "SAFE", NULL);
return TCL_ERROR;
}
@@ -1050,7 +1051,7 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside source image",
-1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "BAD_FROM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
Tcl_Close(NULL, chan);
return TCL_ERROR;
}
@@ -1166,7 +1167,8 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s transparency get: coordinates out of range",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "COORDINATES", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES",
+ NULL);
return TCL_ERROR;
}
@@ -1205,7 +1207,8 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s transparency set: coordinates out of range",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "COORDINATES", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES",
+ NULL);
return TCL_ERROR;
}
@@ -1270,7 +1273,7 @@ ImgPhotoCmd(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't write image to a file in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "SAFE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "SAFE", NULL);
return TCL_ERROR;
}
@@ -1297,7 +1300,7 @@ ImgPhotoCmd(
|| (options.fromY2 > masterPtr->height)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside image", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "BAD_FROM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
return TCL_ERROR;
}
@@ -1677,20 +1680,20 @@ ParseSubcommandOptions(
oneValueRequired:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"the \"%s\" option requires a value", expandedOption));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "MISSING_VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL);
return TCL_ERROR;
manyValuesRequired:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"the \"%s\" option requires one %s integer values",
expandedOption, (maxValues == 2) ? "or two": "to four"));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "MISSING_VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL);
return TCL_ERROR;
numberOutOfRange:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value(s) for the %s option must be %s", expandedOption, needed));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "BAD_VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_VALUE", NULL);
return TCL_ERROR;
unknownOrAmbiguousOption:
@@ -1710,7 +1713,7 @@ ParseSubcommandOptions(
bit <<= 1;
}
Tcl_SetObjResult(interp, msgObj);
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "BAD_OPTION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL);
return TCL_ERROR;
}
@@ -1767,8 +1770,8 @@ ImgPhotoConfigureMaster(
ckfree(args);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"value for \"-data\" missing", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "MISSING_VALUE",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "MISSING_VALUE", NULL);
return TCL_ERROR;
}
} else if ((args[j][1] == 'f') &&
@@ -1780,8 +1783,8 @@ ImgPhotoConfigureMaster(
ckfree(args);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"value for \"-format\" missing", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "MISSING_VALUE",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "MISSING_VALUE", NULL);
return TCL_ERROR;
}
}
@@ -1894,7 +1897,7 @@ ImgPhotoConfigureMaster(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't get image from a file in a safe interpreter",
-1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "SAFE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "SAFE", NULL);
goto errorExit;
}
@@ -2398,8 +2401,8 @@ MatchFileFormat(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"-file option isn't supported for %s images",
formatString));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "NOT_FILE_FORMAT",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NOT_FILE_FORMAT", NULL);
return TCL_ERROR;
}
}
@@ -2432,8 +2435,8 @@ MatchFileFormat(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"-file option isn't supported for %s images",
formatString));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "NOT_FILE_FORMAT",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NOT_FILE_FORMAT", NULL);
return TCL_ERROR;
}
}
@@ -2463,8 +2466,8 @@ MatchFileFormat(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't recognize data in image file \"%s\"",
fileName));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "UNRECOGNIZED_DATA",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE",
+ "UNRECOGNIZED_DATA", NULL);
}
return TCL_ERROR;
}
@@ -2537,8 +2540,8 @@ MatchStringFormat(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"-data option isn't supported for %s images",
formatString));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "NOT_DATA_FORMAT",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NOT_DATA_FORMAT", NULL);
return TCL_ERROR;
}
}
@@ -2564,8 +2567,8 @@ MatchStringFormat(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"-data option isn't supported for %s images",
formatString));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "NOT_DATA_FORMAT",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NOT_DATA_FORMAT", NULL);
return TCL_ERROR;
}
}
@@ -2587,8 +2590,8 @@ MatchStringFormat(
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't recognize image data", -1));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "UNRECOGNIZED_DATA",
- NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "UNRECOGNIZED_DATA", NULL);
}
return TCL_ERROR;
}
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index 355db5b..620f82f 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -875,7 +875,7 @@ ListboxWidgetObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"item number \"%s\" out of range",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEMIDX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL);
result = TCL_ERROR;
break;
}
@@ -912,7 +912,7 @@ ListboxWidgetObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"item number \"%s\" out of range",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEMIDX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL);
result = TCL_ERROR;
break;
}
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
index c233c6c..a51ca33 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -1415,7 +1415,7 @@ RectOvalToPostscript(
*/
(void) Tcl_RestoreInterpState(interp, interpState);
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
Tcl_DecrRefCount(pathObj);
return TCL_OK;
diff --git a/generic/tkText.c b/generic/tkText.c
index 28fa6cd..0970794 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -1262,7 +1262,7 @@ TextWidgetObjCmd(
if (objc > 3) {
name = Tcl_GetStringFromObj(objv[i], &length);
if (length > 1 && name[0] == '-') {
- if (strncmp("-displaychars", name, (unsigned)length)==0) {
+ if (strncmp("-displaychars", name, (unsigned) length) == 0) {
i++;
visible = 1;
name = Tcl_GetStringFromObj(objv[i], &length);
@@ -1669,7 +1669,7 @@ TextPeerCmd(
return TCL_ERROR;
}
- switch ((enum peerOptions)index) {
+ switch ((enum peerOptions) index) {
case PEER_CREATE:
if (objc < 4) {
Tcl_WrongNumArgs(interp, 3, objv, "pathName ?-option value ...?");
@@ -4620,7 +4620,7 @@ TextDumpCmd(
return TCL_ERROR;
}
str = Tcl_GetStringFromObj(objv[arg], &length);
- if (strncmp(str, "end", (unsigned)length) == 0) {
+ if (strncmp(str, "end", (unsigned) length) == 0) {
atEnd = 1;
}
}
@@ -5064,8 +5064,7 @@ TextEditCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int index;
-
+ int index, setModified, oldModified;
static const char *const editOptionStrings[] = {
"modified", "redo", "reset", "separator", "undo", NULL
};
@@ -5088,39 +5087,36 @@ TextEditCmd(
if (objc == 3) {
Tcl_SetObjResult(interp,
Tcl_NewBooleanObj(textPtr->sharedTextPtr->isDirty));
+ return TCL_OK;
} else if (objc != 4) {
Tcl_WrongNumArgs(interp, 3, objv, "?boolean?");
return TCL_ERROR;
- } else {
- int setModified, oldModified;
-
- if (Tcl_GetBooleanFromObj(interp, objv[3],
- &setModified) != TCL_OK) {
- return TCL_ERROR;
- }
+ } else if (Tcl_GetBooleanFromObj(interp, objv[3],
+ &setModified) != TCL_OK) {
+ return TCL_ERROR;
+ }
- /*
- * Set or reset the dirty info, and trigger a Modified event.
- */
+ /*
+ * Set or reset the dirty info, and trigger a Modified event.
+ */
- setModified = setModified ? 1 : 0;
+ setModified = setModified ? 1 : 0;
- oldModified = textPtr->sharedTextPtr->isDirty;
- textPtr->sharedTextPtr->isDirty = setModified;
- if (setModified) {
- textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_FIXED;
- } else {
- textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL;
- }
+ oldModified = textPtr->sharedTextPtr->isDirty;
+ textPtr->sharedTextPtr->isDirty = setModified;
+ if (setModified) {
+ textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_FIXED;
+ } else {
+ textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL;
+ }
- /*
- * Only issue the <<Modified>> event if the flag actually changed.
- * However, degree of modified-ness doesn't matter. [Bug 1799782]
- */
+ /*
+ * Only issue the <<Modified>> event if the flag actually changed.
+ * However, degree of modified-ness doesn't matter. [Bug 1799782]
+ */
- if ((!oldModified) != (!setModified)) {
- GenerateModifiedEvent(textPtr);
- }
+ if ((!oldModified) != (!setModified)) {
+ GenerateModifiedEvent(textPtr);
}
break;
case EDIT_REDO:
@@ -5215,11 +5211,10 @@ TextGetText(
if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) {
while (1) {
- int offset, last;
- TkTextSegment *segPtr;
+ int offset;
+ TkTextSegment *segPtr = TkTextIndexToSeg(&tmpIndex, &offset);
+ int last = segPtr->size, last2;
- segPtr = TkTextIndexToSeg(&tmpIndex, &offset);
- last = segPtr->size;
if (tmpIndex.linePtr == indexPtr2->linePtr) {
/*
* The last line that was requested must be handled carefully,
@@ -5229,21 +5224,17 @@ TextGetText(
if (indexPtr2->byteIndex == tmpIndex.byteIndex) {
break;
- } else {
- int last2 = indexPtr2->byteIndex - tmpIndex.byteIndex
- + offset;
-
- if (last2 < last) {
- last = last2;
- }
}
- }
- if (segPtr->typePtr == &tkTextCharType) {
- if (!visibleOnly || !TkTextIsElided(textPtr,&tmpIndex,NULL)) {
- Tcl_AppendToObj(resultPtr, segPtr->body.chars + offset,
- last - offset);
+ last2 = indexPtr2->byteIndex - tmpIndex.byteIndex + offset;
+ if (last2 < last) {
+ last = last2;
}
}
+ if (segPtr->typePtr == &tkTextCharType &&
+ !(visibleOnly && TkTextIsElided(textPtr,&tmpIndex,NULL))){
+ Tcl_AppendToObj(resultPtr, segPtr->body.chars + offset,
+ last - offset);
+ }
TkTextIndexForwBytes(textPtr, &tmpIndex, last-offset, &tmpIndex);
}
}
@@ -5271,7 +5262,10 @@ static void
GenerateModifiedEvent(
TkText *textPtr) /* Information about text widget. */
{
- union {XEvent general; XVirtualEvent virtual;} event;
+ union {
+ XEvent general;
+ XVirtualEvent virtual;
+ } event;
Tk_MakeWindowExist(textPtr->tkwin);
@@ -5407,14 +5401,9 @@ SearchPerform(
* wrap when given a negative search range).
*/
- if (searchSpecPtr->backwards) {
- if (TkTextIndexCmp(indexFromPtr, indexToPtr) == -1) {
- return TCL_OK;
- }
- } else {
- if (TkTextIndexCmp(indexFromPtr, indexToPtr) == 1) {
- return TCL_OK;
- }
+ if (TkTextIndexCmp(indexFromPtr, indexToPtr) ==
+ (searchSpecPtr->backwards ? -1 : 1)) {
+ return TCL_OK;
}
if (searchSpecPtr->lineIndexProc(interp, toPtr, searchSpecPtr,
@@ -5721,7 +5710,7 @@ SearchCore(
}
while (p >= startOfLine + firstOffset) {
if (p[0] == c && !strncmp(p, pattern,
- (unsigned)matchLength)) {
+ (unsigned) matchLength)) {
goto backwardsMatch;
}
p--;
@@ -5750,7 +5739,7 @@ SearchCore(
*/
p = startOfLine + lastOffset - firstNewLine - 1;
- if (strncmp(p, pattern, (unsigned)(firstNewLine + 1))) {
+ if (strncmp(p, pattern, (unsigned) firstNewLine + 1)) {
/*
* No match.
*/
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 4fe97eb..b04eef2 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -151,7 +151,7 @@ SetTextIndexFromAny(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't convert value to textindex except via"
" TkTextGetIndexFromObj API", -1));
- Tcl_SetErrorCode(interp, "TK", "ILLEGAL_API_USAGE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
return TCL_ERROR;
}
diff --git a/generic/tkTrig.c b/generic/tkTrig.c
index 5f4d267..3da1e5c 100644
--- a/generic/tkTrig.c
+++ b/generic/tkTrig.c
@@ -1441,7 +1441,7 @@ TkMakeBezierPostscript(
control[6], Tk_CanvasPsY(canvas, control[7]));
}
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
}
@@ -1552,7 +1552,7 @@ TkMakeRawCurvePostscript(
}
}
- Tcl_AppendResult(interp, Tcl_GetString(psObj), NULL);
+ Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
}