summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkBind.c42
-rw-r--r--generic/tkBitmap.c17
-rw-r--r--generic/tkBusy.c4
-rw-r--r--generic/tkCanvArc.c9
-rw-r--r--generic/tkCanvBmap.c8
-rw-r--r--generic/tkCanvImg.c6
-rw-r--r--generic/tkCanvLine.c35
-rw-r--r--generic/tkCanvPoly.c2
-rw-r--r--generic/tkCanvPs.c81
-rw-r--r--generic/tkCanvText.c44
-rw-r--r--generic/tkCanvUtil.c35
-rw-r--r--generic/tkCanvWind.c14
-rw-r--r--generic/tkCanvas.c229
-rw-r--r--tests/canvas.test18
14 files changed, 321 insertions, 223 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 0c50368..c051c7a 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -2924,8 +2924,9 @@ HandleEventGenerate(
mainPtr = (TkWindow *) mainWin;
if ((tkwin == NULL)
|| (mainPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) {
- Tcl_AppendResult(interp, "window id \"", Tcl_GetString(objv[0]),
- "\" doesn't exist in this application", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window id \"%s\" doesn't exist in this application",
+ Tcl_GetString(objv[0])));
Tcl_SetErrorCode(interp, "TK", "EVENT", "FOREIGN_TARGET", NULL);
return TCL_ERROR;
}
@@ -3024,8 +3025,8 @@ HandleEventGenerate(
* is missing.
*/
- Tcl_AppendResult(interp, "value for \"", Tcl_GetString(optionPtr),
- "\" missing", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "value for \"%s\" missing", Tcl_GetString(optionPtr)));
Tcl_SetErrorCode(interp, "TK", "EVENT", "MISSING_VALUE", NULL);
return TCL_ERROR;
}
@@ -3167,16 +3168,16 @@ HandleEventGenerate(
value = Tcl_GetString(valuePtr);
keysym = TkStringToKeysym(value);
if (keysym == NoSymbol) {
- Tcl_AppendResult(interp, "unknown keysym \"", value, "\"",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "unknown keysym \"%s\"", value));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", NULL);
return TCL_ERROR;
}
TkpSetKeycodeAndState(tkwin, keysym, &event.general);
if (event.general.xkey.keycode == 0) {
- Tcl_AppendResult(interp, "no keycode for keysym \"", value,
- "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "no keycode for keysym \"%s\"", value));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", NULL);
return TCL_ERROR;
}
@@ -3406,8 +3407,9 @@ HandleEventGenerate(
continue;
badopt:
- Tcl_AppendResult(interp, name, " event doesn't accept \"",
- Tcl_GetString(optionPtr), "\" option", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s event doesn't accept \"%s\" option",
+ name, Tcl_GetString(optionPtr)));
Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_OPTION", NULL);
return TCL_ERROR;
}
@@ -3502,7 +3504,8 @@ NameToWindow(
return TCL_OK;
badWindow:
- Tcl_AppendResult(interp, "bad window name/identifier \"",name,"\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad window name/identifier \"%s\"", name));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", NULL);
return TCL_ERROR;
}
@@ -3566,8 +3569,8 @@ GetVirtualEventUid(
if (length < 5 || virtString[0] != '<' || virtString[1] != '<' ||
virtString[length - 2] != '>' || virtString[length - 1] != '>') {
- Tcl_AppendResult(interp, "virtual event \"", virtString,
- "\" is badly formed", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "virtual event \"%s\" is badly formed", virtString));
Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", NULL);
return NULL;
}
@@ -3937,8 +3940,9 @@ ParseEventDescription(
} else if (eventFlags & KEY) {
goto getKeysym;
} else if ((eventFlags & BUTTON) == 0) {
- Tcl_AppendResult(interp, "specified button \"", field,
- "\" for non-button event", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "specified button \"%s\" for non-button event",
+ field));
Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_BUTTON", NULL);
count = 0;
goto done;
@@ -3949,8 +3953,8 @@ ParseEventDescription(
getKeysym:
patPtr->detail.keySym = TkStringToKeysym(field);
if (patPtr->detail.keySym == NoSymbol) {
- Tcl_AppendResult(interp, "bad event type or keysym \"",
- field, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad event type or keysym \"%s\"", field));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", NULL);
count = 0;
goto done;
@@ -3959,8 +3963,8 @@ ParseEventDescription(
patPtr->eventType = KeyPress;
eventMask = KeyPressMask;
} else if ((eventFlags & KEY) == 0) {
- Tcl_AppendResult(interp, "specified keysym \"", field,
- "\" for non-key event", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "specified keysym \"%s\" for non-key event", field));
Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_KEY", NULL);
count = 0;
goto done;
diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c
index 5349fd5..1c28977 100644
--- a/generic/tkBitmap.c
+++ b/generic/tkBitmap.c
@@ -342,8 +342,9 @@ GetBitmap(
int result;
if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't specify bitmap with '@' in a",
- " safe interpreter", NULL);
+ Tcl_SetResult(interp,
+ "can't specify bitmap with '@' in a safe interpreter",
+ TCL_STATIC);
Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL);
goto error;
}
@@ -364,8 +365,8 @@ GetBitmap(
&bitmap, &dummy2, &dummy2);
if (result != BitmapSuccess) {
if (interp != NULL) {
- Tcl_AppendResult(interp, "error reading bitmap file \"",
- string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading bitmap file \"%s\"", string));
Tcl_SetErrorCode(interp, "TK", "BITMAP", "FILE_ERROR", NULL);
}
Tcl_DStringFree(&buffer);
@@ -386,8 +387,8 @@ GetBitmap(
if (bitmap == None) {
if (interp != NULL) {
- Tcl_AppendResult(interp, "bitmap \"", string,
- "\" not defined", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bitmap \"%s\" not defined", string));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "BITMAP", NULL);
}
goto error;
@@ -490,8 +491,8 @@ Tk_DefineBitmap(
predefHashPtr = Tcl_CreateHashEntry(&tsdPtr->predefBitmapTable,
name, &isNew);
if (!isNew) {
- Tcl_AppendResult(interp, "bitmap \"", name, "\" is already defined",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bitmap \"%s\" is already defined", name));
Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", NULL);
return TCL_ERROR;
}
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 5439969..8fd53fa 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -687,8 +687,8 @@ GetBusy(
}
hPtr = Tcl_FindHashEntry(busyTablePtr, (char *) tkwin);
if (hPtr == NULL) {
- Tcl_AppendResult(interp, "can't find busy window \"",
- Tcl_GetString(windowObj), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't find busy window \"%s\"", Tcl_GetString(windowObj)));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "BUSY", NULL);
return NULL;
}
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index d8a8062..434ca66 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -359,6 +359,8 @@ ArcCoords(
} else if (objc != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 4, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC",
+ NULL);
return TCL_ERROR;
}
}
@@ -376,6 +378,7 @@ ArcCoords(
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 4, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -2013,8 +2016,10 @@ StyleParseProc(
return TCL_OK;
}
- Tcl_AppendResult(interp, "bad -style option \"", value,
- "\": must be arc, chord, or pieslice", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad -style option \"%s\": must be arc, chord, or pieslice",
+ value));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARCSTYLE", NULL);
*stylePtr = PIESLICE_STYLE;
return TCL_ERROR;
}
diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c
index adaa184..bf4c78f 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -260,6 +260,8 @@ BitmapCoords(
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP",
+ NULL);
return TCL_ERROR;
}
}
@@ -273,6 +275,7 @@ BitmapCoords(
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -934,8 +937,9 @@ BitmapToPostscript(
}
if (width > 60000) {
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "can't generate Postscript",
- " for bitmaps more than 60000 pixels wide", NULL);
+ Tcl_SetResult(interp, "can't generate Postscript for bitmaps more"
+ " than 60000 pixels wide", TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
return TCL_ERROR;
}
rowsAtOnce = 60000/width;
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index b92659b..172f26d 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -245,10 +245,13 @@ ImageCoords(
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE",
+ NULL);
return TCL_ERROR;
}
}
- if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &imgPtr->x) != TCL_OK)
+ if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0],
+ &imgPtr->x) != TCL_OK)
|| (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1],
&imgPtr->y) != TCL_OK)) {
return TCL_ERROR;
@@ -257,6 +260,7 @@ ImageCoords(
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE", NULL);
return TCL_ERROR;
}
return TCL_OK;
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index e2dd8d3..d631c64 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -394,10 +394,12 @@ LineCoords(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected an even number, got %d",
objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
return TCL_ERROR;
} else if (objc < 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected at least 4, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
return TCL_ERROR;
}
@@ -1748,15 +1750,7 @@ GetLineIndex(
if (strncmp(string, "end", (unsigned) length) == 0) {
*indexPtr = 2*linePtr->numPoints;
} else {
- /*
- * Some of the paths here leave messages in interp->result, so we
- * have to clear it out before storing our own message.
- */
-
- badIndex:
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad index \"", string, "\"", NULL);
- return TCL_ERROR;
+ goto badIndex;
}
} else if (string[0] == '@') {
int i;
@@ -1797,6 +1791,17 @@ GetLineIndex(
}
}
return TCL_OK;
+
+ /*
+ * Some of the paths here leave messages in interp->result, so we have to
+ * clear it out before storing our own message.
+ */
+
+ badIndex:
+ Tcl_ResetResult(interp);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEMINDEX", "LINE", NULL);
+ return TCL_ERROR;
}
/*
@@ -1910,8 +1915,10 @@ ParseArrowShape(
syntaxError:
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad arrow shape \"", value,
- "\": must be list with three numbers", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad arrow shape \"%s\": must be list with three numbers",
+ value));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROWSHAPE", NULL);
if (argv != NULL) {
ckfree(argv);
}
@@ -2012,8 +2019,10 @@ ArrowParseProc(
return TCL_OK;
}
- Tcl_AppendResult(interp, "bad arrow spec \"", value,
- "\": must be none, first, last, or both", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad arrow spec \"%s\": must be none, first, last, or both",
+ value));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW", NULL);
*arrowPtr = ARROWS_NONE;
return TCL_ERROR;
}
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index 943ef0b..da47a3f 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -359,6 +359,7 @@ PolygonCoords(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected an even number, got %d",
objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "POLYGON", NULL);
return TCL_ERROR;
}
@@ -1731,6 +1732,7 @@ GetPolygonIndex(
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEMINDEX", "POLY", NULL);
return TCL_ERROR;
}
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index 69c9cfb..e259a71 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -166,6 +166,7 @@ TkCanvPostscriptCmd(
TkPostscriptInfo psInfo, *psInfoPtr = &psInfo;
Tk_PostscriptInfo oldInfoPtr;
int result;
+ int written;
Tk_Item *itemPtr;
#define STRING_LENGTH 400
char string[STRING_LENGTH+1];
@@ -321,8 +322,11 @@ TkCanvPostscriptCmd(
} else if (strncmp(psInfo.colorMode, "color", length) == 0) {
psInfo.colorLevel = 2;
} else {
- Tcl_AppendResult(interp, "bad color mode \"", psInfo.colorMode,
- "\": must be monochrome, gray, or color", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad color mode \"%s\": must be monochrome, gray, or color",
+ psInfo.colorMode));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "COLORMODE", NULL);
+ result = TCL_ERROR;
goto cleanup;
}
}
@@ -333,8 +337,9 @@ TkCanvPostscriptCmd(
*/
if (psInfo.channelName != NULL) {
- Tcl_AppendResult(interp, "can't specify both -file",
- " and -channel", NULL);
+ Tcl_SetResult(interp, "can't specify both -file and -channel",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "USAGE", NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -345,8 +350,9 @@ TkCanvPostscriptCmd(
*/
if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't specify -file in a",
- " safe interpreter", NULL);
+ Tcl_SetResult(interp, "can't specify -file in a safe interpreter",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "SAFE", NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -376,8 +382,10 @@ TkCanvPostscriptCmd(
goto cleanup;
}
if ((mode & TCL_WRITABLE) == 0) {
- Tcl_AppendResult(interp, "channel \"", psInfo.channelName,
- "\" wasn't opened for writing", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "channel \"%s\" wasn't opened for writing",
+ psInfo.channelName));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "UNWRITABLE",NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -475,8 +483,16 @@ TkCanvPostscriptCmd(
Tcl_AppendResult(interp, Tcl_GetString(preambleObj), NULL);
if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1);
- Tcl_ResetResult(canvasPtr->interp);
+ written = Tcl_WriteObj(psInfo.chan, Tcl_GetObjResult(interp));
+ Tcl_ResetResult(interp);
+ if (written == -1) {
+ channelWriteFailed:
+ Tcl_AppendResult(interp,
+ "problem writing postscript data to channel: ",
+ Tcl_PosixError(interp), NULL);
+ result = TCL_ERROR;
+ goto cleanup;
+ }
}
/*
@@ -522,8 +538,11 @@ TkCanvPostscriptCmd(
" lineto closepath clip newpath\n", NULL);
}
if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1);
- Tcl_ResetResult(canvasPtr->interp);
+ written = Tcl_WriteObj(psInfo.chan, Tcl_GetObjResult(interp));
+ Tcl_ResetResult(interp);
+ if (written == -1) {
+ goto channelWriteFailed;
+ }
}
/*
@@ -555,8 +574,11 @@ TkCanvPostscriptCmd(
}
Tcl_AppendResult(interp, "grestore\n", NULL);
if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1);
+ written = Tcl_WriteObj(psInfo.chan, Tcl_GetObjResult(interp));
Tcl_ResetResult(interp);
+ if (written == -1) {
+ goto channelWriteFailed;
+ }
}
}
@@ -570,8 +592,11 @@ TkCanvPostscriptCmd(
"%%Trailer\nend\n%%EOF\n", NULL);
}
if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1);
- Tcl_ResetResult(canvasPtr->interp);
+ Tcl_WriteObj(psInfo.chan, Tcl_GetObjResult(interp));
+ Tcl_ResetResult(interp);
+ if (written == -1) {
+ goto channelWriteFailed;
+ }
}
/*
@@ -747,8 +772,11 @@ Tk_PostscriptFont(
|| Tcl_GetDoubleFromObj(interp, objv[1], &size) != TCL_OK
|| size <= 0) {
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad font map entry for \"", name,
- "\": \"", Tcl_GetString(list), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad font map entry for \"%s\": \"%s\"",
+ name, Tcl_GetString(list)));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "FONTMAP",
+ NULL);
return TCL_ERROR;
}
@@ -1079,7 +1107,8 @@ GetPostscriptPoints(
return TCL_OK;
error:
- Tcl_AppendResult(interp, "bad distance \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad distance \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "POINTS", NULL);
return TCL_ERROR;
}
@@ -1287,10 +1316,10 @@ TkPostscriptImage(
if (bytesPerLine > 60000) {
Tcl_ResetResult(interp);
- sprintf(buffer,
- "Can't generate Postscript for images more than %d pixels wide",
- maxWidth);
- Tcl_AppendResult(interp, buffer, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't generate Postscript for images more than %d pixels wide",
+ maxWidth));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
ckfree(cdata.colors);
return TCL_ERROR;
}
@@ -1480,10 +1509,10 @@ Tk_PostscriptPhoto(
}
if (bytesPerLine > 60000) {
Tcl_ResetResult(interp);
- sprintf(buffer,
- "Can't generate Postscript for images more than %d pixels wide",
- maxWidth);
- Tcl_AppendResult(interp, buffer, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't generate Postscript for images more than %d pixels wide",
+ maxWidth));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
return TCL_ERROR;
}
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index 0861a21..a225646 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -338,29 +338,32 @@ TextCoords(
subobj = Tcl_NewDoubleObj(textPtr->y);
Tcl_ListObjAppendElement(interp, obj, subobj);
Tcl_SetObjResult(interp, obj);
- } else if (objc < 3) {
- if (objc == 1) {
- if (Tcl_ListObjGetElements(interp, objv[0], &objc,
- (Tcl_Obj ***) &objv) != TCL_OK) {
- return TCL_ERROR;
- } else if (objc != 2) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 2, got %d", objc));
- return TCL_ERROR;
- }
- }
- if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0],
- &textPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1],
- &textPtr->y) != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeTextBbox(canvas, textPtr);
- } else {
+ return TCL_OK;
+ } else if (objc > 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL);
return TCL_ERROR;
}
+
+ if (objc == 1) {
+ if (Tcl_ListObjGetElements(interp, objv[0], &objc,
+ (Tcl_Obj ***) &objv) != TCL_OK) {
+ return TCL_ERROR;
+ } else if (objc != 2) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "wrong # coordinates: expected 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL);
+ return TCL_ERROR;
+ }
+ }
+ if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0],
+ &textPtr->x) != TCL_OK)
+ || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1],
+ &textPtr->y) != TCL_OK)) {
+ return TCL_ERROR;
+ }
+ ComputeTextBbox(canvas, textPtr);
return TCL_OK;
}
@@ -1357,6 +1360,7 @@ GetTextIndex(
&& (strncmp(string, "sel.first", (unsigned) length) == 0)) {
if (textInfoPtr->selItemPtr != itemPtr) {
Tcl_SetResult(interp, "selection isn't in item", TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", NULL);
return TCL_ERROR;
}
*indexPtr = textInfoPtr->selectFirst;
@@ -1364,6 +1368,7 @@ GetTextIndex(
&& (strncmp(string, "sel.last", (unsigned) length) == 0)) {
if (textInfoPtr->selItemPtr != itemPtr) {
Tcl_SetResult(interp, "selection isn't in item", TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", NULL);
return TCL_ERROR;
}
*indexPtr = textInfoPtr->selectLast;
@@ -1403,6 +1408,7 @@ GetTextIndex(
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEMINDEX", "TEXT", NULL);
return TCL_ERROR;
}
return TCL_OK;
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
index 1a6a8c4..711d7aa 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -756,8 +756,9 @@ TkSmoothParseProc(
while (methods != NULL) {
if (strncmp(value, methods->smooth.name, length) == 0) {
if (smooth != NULL) {
- Tcl_AppendResult(interp, "ambiguous smooth method \"", value,
- "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "ambiguous smooth method \"%s\"", value));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "SMOOTH", NULL);
return TCL_ERROR;
}
smooth = &methods->smooth;
@@ -878,7 +879,7 @@ Tk_GetDash(
if ((unsigned) ABS(dash->number) > sizeof(char *)) {
ckfree(dash->pattern.pt);
}
- if (argc > (int)sizeof(char *)) {
+ if (argc > (int) sizeof(char *)) {
dash->pattern.pt = pt = ckalloc(argc);
} else {
pt = dash->pattern.array;
@@ -886,12 +887,12 @@ Tk_GetDash(
dash->number = argc;
largv = argv;
- while (argc>0) {
+ while (argc > 0) {
if (Tcl_GetInt(interp, *largv, &i) != TCL_OK || i < 1 || i>255) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "expected integer in the range 1..255 but got \"",
- *largv, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected integer in the range 1..255 but got \"%s\"",
+ *largv));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", NULL);
goto syntaxError;
}
*pt++ = i;
@@ -909,8 +910,10 @@ Tk_GetDash(
*/
badDashList:
- Tcl_AppendResult(interp, "bad dash list \"", value,
- "\": must be a list of integers or a format like \"-..\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad dash list \"%s\": must be a list of integers or a format like \"-..\"",
+ value));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", NULL);
syntaxError:
if (argv != NULL) {
ckfree(argv);
@@ -1252,9 +1255,9 @@ Tk_ChangeOutlineGC(
*
* Tk_ResetOutlineGC
*
- * Restores the GC to the situation before Tk_ChangeOutlineGC() was called.
- * This function should be called just after the dashed item is drawn,
- * because the GC is supposed to be read-only.
+ * Restores the GC to the situation before Tk_ChangeOutlineGC() was
+ * called. This function should be called just after the dashed item is
+ * drawn, because the GC is supposed to be read-only.
*
* Results:
* 1 if there is a stipple pattern, and 0 otherwise.
@@ -1731,7 +1734,7 @@ TkCanvTranslatePath(
* This is the loop that makes the four passes through the data.
*/
- for (j=0; j<4; j++){
+ for (j=0; j<4; j++) {
double xClip = limit[j];
int inside = a[0] < xClip;
double priorY = a[1];
@@ -1742,7 +1745,7 @@ TkCanvTranslatePath(
* rotated by 90 degrees clockwise.
*/
- for (i=0; i<numVertex; i++){
+ for (i=0; i<numVertex; i++) {
double x = a[i*2];
double y = a[i*2 + 1];
@@ -1833,7 +1836,7 @@ TkCanvTranslatePath(
* XPoints and translate the origin for the drawable.
*/
- for (i=0; i<numVertex; i++){
+ for (i=0; i<numVertex; i++) {
TranslateAndAppendCoords(canvPtr, a[i*2], a[i*2+1], outArr, i);
}
if (tempArr != staticSpace) {
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
index 0c54741..ef4cc03 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -259,6 +259,8 @@ WinItemCoords(
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW",
+ NULL);
return TCL_ERROR;
}
}
@@ -271,6 +273,7 @@ WinItemCoords(
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # coordinates: expected 0 or 2, got %d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -337,8 +340,7 @@ ConfigureWinItem(
*/
parent = Tk_Parent(winItemPtr->tkwin);
- for (ancestor = canvasTkwin; ;
- ancestor = Tk_Parent(ancestor)) {
+ for (ancestor = canvasTkwin ;; ancestor = Tk_Parent(ancestor)) {
if (ancestor == parent) {
break;
}
@@ -370,8 +372,10 @@ ConfigureWinItem(
return TCL_OK;
badWindow:
- Tcl_AppendResult(interp, "can't use ", Tk_PathName(winItemPtr->tkwin),
- " in a window item of this canvas", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use %s in a window item of this canvas",
+ Tk_PathName(winItemPtr->tkwin)));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
winItemPtr->tkwin = NULL;
return TCL_ERROR;
}
@@ -842,7 +846,7 @@ CanvasPsWindow(
Tcl_DStringInit(&buffer1);
Tcl_DStringInit(&buffer2);
Tcl_DStringGetResult(interp, &buffer2);
- sprintf(buffer, "%s postscript -prolog 0\n", Tk_PathName(tkwin));
+ sprintf(buffer, "%s postscript -prolog 0", Tk_PathName(tkwin));
result = Tcl_Eval(interp, buffer);
Tcl_DStringGetResult(interp, &buffer1);
Tcl_DStringResult(interp, &buffer2);
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 14d8261..0cb8ccb 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -928,8 +928,9 @@ CanvasWidgetCmd(
}
if (object == NULL) {
- Tcl_AppendResult(interp, "item \"", Tcl_GetString(objv[2]),
- "\" doesn't exist", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "item \"%s\" doesn't exist", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVASITEM", NULL);
result = TCL_ERROR;
goto done;
}
@@ -953,8 +954,9 @@ CanvasWidgetCmd(
}
if (object == 0) {
- Tcl_AppendResult(interp, "item \"", Tcl_GetString(objv[2]),
- "\" doesn't exist", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "item \"%s\" doesn't exist", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVASITEM", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1030,10 +1032,10 @@ CanvasWidgetCmd(
|KeyReleaseMask|PointerMotionMask|VirtualEventMask)) {
Tk_DeleteBinding(interp, canvasPtr->bindingTable,
object, Tcl_GetString(objv[3]));
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "requested illegal events; ",
- "only key, button, motion, enter, leave, and virtual",
- " events may be used", NULL);
+ Tcl_SetResult(interp, "requested illegal events;"
+ " only key, button, motion, enter, leave, and virtual"
+ " events may be used", TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_EVENTS", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1274,8 +1276,9 @@ CanvasWidgetCmd(
Tcl_MutexUnlock(&typeListMutex);
if (matchPtr == NULL) {
badType:
- Tcl_AppendResult(interp,
- "unknown or ambiguous item type \"", arg, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "unknown or ambiguous item type \"%s\"", arg));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVASITEM", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1545,8 +1548,10 @@ CanvasWidgetCmd(
}
}
if (itemPtr == NULL) {
- Tcl_AppendResult(interp, "can't find an indexable item \"",
- Tcl_GetString(objv[2]), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't find an indexable item \"%s\"",
+ Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "INDEXABLE_ITEM", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1647,8 +1652,10 @@ CanvasWidgetCmd(
} else {
FIRST_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done);
if (itemPtr == NULL) {
- Tcl_AppendResult(interp, "tag \"", Tcl_GetString(objv[3]),
- "\" doesn't match any items", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "tagOrId \"%s\" doesn't match any items",
+ Tcl_GetString(objv[3])));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1772,8 +1779,10 @@ CanvasWidgetCmd(
prevPtr = itemPtr;
}
if (prevPtr == NULL) {
- Tcl_AppendResult(interp, "tagOrId \"", Tcl_GetString(objv[3]),
- "\" doesn't match any items", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "tagOrId \"%s\" doesn't match any items",
+ Tcl_GetString(objv[3])));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1848,6 +1857,7 @@ CanvasWidgetCmd(
}
if ((xScale == 0.0) || (yScale == 0.0)) {
Tcl_SetResult(interp, "scale factor cannot be zero", TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_SCALE", NULL);
result = TCL_ERROR;
goto done;
}
@@ -1925,9 +1935,11 @@ CanvasWidgetCmd(
}
}
if (itemPtr == NULL) {
- Tcl_AppendResult(interp,
- "can't find an indexable and selectable item \"",
- Tcl_GetString(objv[3]), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't find an indexable and selectable item \"%s\"",
+ Tcl_GetString(objv[3])));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SELECTABLE_ITEM",
+ NULL);
result = TCL_ERROR;
goto done;
}
@@ -2019,6 +2031,7 @@ CanvasWidgetCmd(
int newX = 0; /* Initialization needed only to prevent gcc
* warnings. */
double fraction;
+ const char **args;
if (objc == 2) {
Tcl_SetObjResult(interp, ScrollFractions(
@@ -2026,39 +2039,37 @@ CanvasWidgetCmd(
canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin)
- canvasPtr->inset, canvasPtr->scrollX1,
canvasPtr->scrollX2));
- } else {
- const char **args = TkGetStringsFromObjs(objc, objv);
+ break;
+ }
- type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count);
- if (args != NULL) {
- ckfree(args);
- }
- switch (type) {
- case TK_SCROLL_ERROR:
- result = TCL_ERROR;
- goto done;
- case TK_SCROLL_MOVETO:
- newX = canvasPtr->scrollX1 - canvasPtr->inset
- + (int) (fraction * (canvasPtr->scrollX2
- - canvasPtr->scrollX1) + 0.5);
- break;
- case TK_SCROLL_PAGES:
- newX = (int) (canvasPtr->xOrigin + count * .9
+ args = TkGetStringsFromObjs(objc, objv);
+ type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count);
+ if (args != NULL) {
+ ckfree(args);
+ }
+ switch (type) {
+ case TK_SCROLL_ERROR:
+ result = TCL_ERROR;
+ goto done;
+ case TK_SCROLL_MOVETO:
+ newX = canvasPtr->scrollX1 - canvasPtr->inset
+ + (int) (fraction * (canvasPtr->scrollX2
+ - canvasPtr->scrollX1) + 0.5);
+ break;
+ case TK_SCROLL_PAGES:
+ newX = (int) (canvasPtr->xOrigin + count * .9
+ * (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset));
+ break;
+ case TK_SCROLL_UNITS:
+ if (canvasPtr->xScrollIncrement > 0) {
+ newX = canvasPtr->xOrigin + count*canvasPtr->xScrollIncrement;
+ } else {
+ newX = (int) (canvasPtr->xOrigin + count * .1
* (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset));
- break;
- case TK_SCROLL_UNITS:
- if (canvasPtr->xScrollIncrement > 0) {
- newX = canvasPtr->xOrigin
- + count*canvasPtr->xScrollIncrement;
- } else {
- newX = (int) (canvasPtr->xOrigin + count * .1
- * (Tk_Width(canvasPtr->tkwin)
- - 2*canvasPtr->inset));
- }
- break;
}
- CanvasSetOrigin(canvasPtr, newX, canvasPtr->yOrigin);
+ break;
}
+ CanvasSetOrigin(canvasPtr, newX, canvasPtr->yOrigin);
break;
}
case CANV_YVIEW: {
@@ -2066,6 +2077,7 @@ CanvasWidgetCmd(
int newY = 0; /* Initialization needed only to prevent gcc
* warnings. */
double fraction;
+ const char **args;
if (objc == 2) {
Tcl_SetObjResult(interp, ScrollFractions(
@@ -2073,40 +2085,36 @@ CanvasWidgetCmd(
canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin)
- canvasPtr->inset,
canvasPtr->scrollY1, canvasPtr->scrollY2));
- } else {
- const char **args = TkGetStringsFromObjs(objc, objv);
+ break;
+ }
- type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count);
- if (args != NULL) {
- ckfree(args);
- }
- switch (type) {
- case TK_SCROLL_ERROR:
- result = TCL_ERROR;
- goto done;
- case TK_SCROLL_MOVETO:
- newY = canvasPtr->scrollY1 - canvasPtr->inset
- + (int) (fraction*(canvasPtr->scrollY2
- - canvasPtr->scrollY1) + 0.5);
- break;
- case TK_SCROLL_PAGES:
- newY = (int) (canvasPtr->yOrigin + count * .9
- * (Tk_Height(canvasPtr->tkwin)
- - 2*canvasPtr->inset));
- break;
- case TK_SCROLL_UNITS:
- if (canvasPtr->yScrollIncrement > 0) {
- newY = canvasPtr->yOrigin
- + count*canvasPtr->yScrollIncrement;
- } else {
- newY = (int) (canvasPtr->yOrigin + count * .1
- * (Tk_Height(canvasPtr->tkwin)
- - 2*canvasPtr->inset));
- }
- break;
+ args = TkGetStringsFromObjs(objc, objv);
+ type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count);
+ if (args != NULL) {
+ ckfree(args);
+ }
+ switch (type) {
+ case TK_SCROLL_ERROR:
+ result = TCL_ERROR;
+ goto done;
+ case TK_SCROLL_MOVETO:
+ newY = canvasPtr->scrollY1 - canvasPtr->inset + (int) (
+ fraction*(canvasPtr->scrollY2-canvasPtr->scrollY1) + 0.5);
+ break;
+ case TK_SCROLL_PAGES:
+ newY = (int) (canvasPtr->yOrigin + count * .9
+ * (Tk_Height(canvasPtr->tkwin) - 2*canvasPtr->inset));
+ break;
+ case TK_SCROLL_UNITS:
+ if (canvasPtr->yScrollIncrement > 0) {
+ newY = canvasPtr->yOrigin + count*canvasPtr->yScrollIncrement;
+ } else {
+ newY = (int) (canvasPtr->yOrigin + count * .1
+ * (Tk_Height(canvasPtr->tkwin) - 2*canvasPtr->inset));
}
- CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, newY);
+ break;
}
+ CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, newY);
break;
}
}
@@ -2302,8 +2310,9 @@ ConfigureCanvas(
return TCL_ERROR;
}
if (argc2 != 4) {
- Tcl_AppendResult(interp, "bad scrollRegion \"",
- canvasPtr->regionString, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad scrollRegion \"%s\"", canvasPtr->regionString));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLLREGION", NULL);
badRegion:
ckfree(canvasPtr->regionString);
ckfree(argv2);
@@ -3583,8 +3592,11 @@ TagSearchScanExpr(
case '!': /* Negate next tag or subexpr */
if (looking_for_tag > 1) {
- Tcl_AppendResult(interp,
- "Too many '!' in tag search expression", NULL);
+ Tcl_SetResult(interp,
+ "too many '!' in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
+ "COMPLEXITY", NULL);
return TCL_ERROR;
}
looking_for_tag++;
@@ -3631,15 +3643,19 @@ TagSearchScanExpr(
*tag++ = c;
}
if (!found_endquote) {
- Tcl_AppendResult(interp,
- "Missing endquote in tag search expression",
- NULL);
+ Tcl_SetResult(interp,
+ "missing endquote in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
+ "ENDQUOTE", NULL);
return TCL_ERROR;
}
if (!(tag - searchPtr->rewritebuffer)) {
- Tcl_AppendResult(interp,
- "Null quoted tag string in tag search expression",
- NULL);
+ Tcl_SetResult(interp,
+ "null quoted tag string in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
+ "EMPTY", NULL);
return TCL_ERROR;
}
*tag++ = '\0';
@@ -3653,9 +3669,11 @@ TagSearchScanExpr(
case '|':
case '^':
case ')':
- Tcl_AppendResult(interp,
- "Unexpected operator in tag search expression",
- NULL);
+ Tcl_SetResult(interp,
+ "unexpected operator in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
+ "UNEXPECTED", NULL);
return TCL_ERROR;
default: /* Unquoted tag string */
@@ -3716,8 +3734,11 @@ TagSearchScanExpr(
case '&': /* AND operator */
c = searchPtr->string[searchPtr->stringIndex++];
if (c != '&') {
- Tcl_AppendResult(interp,
- "Singleton '&' in tag search expression", NULL);
+ Tcl_SetResult(interp,
+ "singleton '&' in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
+ "INCOMPLETE_OP", NULL);
return TCL_ERROR;
}
expr->uids[expr->index++] = searchUids->andUid;
@@ -3727,8 +3748,11 @@ TagSearchScanExpr(
case '|': /* OR operator */
c = searchPtr->string[searchPtr->stringIndex++];
if (c != '|') {
- Tcl_AppendResult(interp,
- "Singleton '|' in tag search expression", NULL);
+ Tcl_SetResult(interp,
+ "singleton '|' in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
+ "INCOMPLETE_OP", NULL);
return TCL_ERROR;
}
expr->uids[expr->index++] = searchUids->orUid;
@@ -3745,8 +3769,10 @@ TagSearchScanExpr(
goto breakwhile;
default: /* syntax error */
- Tcl_AppendResult(interp,
- "Invalid boolean operator in tag search expression",
+ Tcl_SetResult(interp,
+ "invalid boolean operator in tag search expression",
+ TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "BAD_OP",
NULL);
return TCL_ERROR;
}
@@ -3757,7 +3783,8 @@ TagSearchScanExpr(
if (found_tag && !looking_for_tag) {
return TCL_OK;
}
- Tcl_AppendResult(interp, "Missing tag in tag search expression", NULL);
+ Tcl_SetResult(interp, "missing tag in tag search expression", TCL_STATIC);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "NO_TAG", NULL);
return TCL_ERROR;
}
@@ -4339,8 +4366,8 @@ FindItems(
return TCL_ERROR;
}
if (halo < 0.0) {
- Tcl_AppendResult(interp, "can't have negative halo value \"",
- Tcl_GetString(objv[3]), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't have negative halo value \"%f\"", halo));
return TCL_ERROR;
}
} else {
diff --git a/tests/canvas.test b/tests/canvas.test
index f5b33cc..2b0da48 100644
--- a/tests/canvas.test
+++ b/tests/canvas.test
@@ -406,7 +406,7 @@ test canvas-10.2 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {&&c}
-} -returnCodes error -result {Unexpected operator in tag search expression}
+} -returnCodes error -result {unexpected operator in tag search expression}
test canvas-10.3 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -414,7 +414,7 @@ test canvas-10.3 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {!!c}
-} -returnCodes error -result {Too many '!' in tag search expression}
+} -returnCodes error -result {too many '!' in tag search expression}
test canvas-10.4 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -422,7 +422,7 @@ test canvas-10.4 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {b||}
-} -returnCodes error -result {Missing tag in tag search expression}
+} -returnCodes error -result {missing tag in tag search expression}
test canvas-10.5 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -430,7 +430,7 @@ test canvas-10.5 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {b&&(c||)}
-} -returnCodes error -result {Unexpected operator in tag search expression}
+} -returnCodes error -result {unexpected operator in tag search expression}
test canvas-10.6 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -438,7 +438,7 @@ test canvas-10.6 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {d&&""}
-} -returnCodes error -result {Null quoted tag string in tag search expression}
+} -returnCodes error -result {null quoted tag string in tag search expression}
test canvas-10.7 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -446,7 +446,7 @@ test canvas-10.7 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag "d&&\"tag with spaces"
-} -returnCodes error -result {Missing endquote in tag search expression}
+} -returnCodes error -result {missing endquote in tag search expression}
test canvas-10.8 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -454,7 +454,7 @@ test canvas-10.8 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -returnCodes error -body {
.c find withtag {a&&"tag with spaces"z}
-} -result {Invalid boolean operator in tag search expression}
+} -result {invalid boolean operator in tag search expression}
test canvas-10.9 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -462,7 +462,7 @@ test canvas-10.9 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {a&&b&c}
-} -returnCodes error -result {Singleton '&' in tag search expression}
+} -returnCodes error -result {singleton '&' in tag search expression}
test canvas-10.10 {check errors from tag expressions} -setup {
catch {destroy .c}
canvas .c
@@ -470,7 +470,7 @@ test canvas-10.10 {check errors from tag expressions} -setup {
.c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"]
} -body {
.c find withtag {a||b|c}
-} -returnCodes error -result {Singleton '|' in tag search expression}
+} -returnCodes error -result {singleton '|' in tag search expression}
test canvas-10.11 {backward compatility - strange tags that are not expressions} -setup {
catch {destroy .c}
canvas .c