summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvLine.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2003-02-09 07:48:22 (GMT)
committerhobbs <hobbs>2003-02-09 07:48:22 (GMT)
commit9d1525754196bc3da08fd80f693f7cd24c50ab10 (patch)
treec6933d15bed38ac3ee37519fe2b9700aeee30333 /generic/tkCanvLine.c
parentd3f940de47f1e49a943a67d56fa64aaa543bd4bc (diff)
downloadtk-9d1525754196bc3da08fd80f693f7cd24c50ab10.zip
tk-9d1525754196bc3da08fd80f693f7cd24c50ab10.tar.gz
tk-9d1525754196bc3da08fd80f693f7cd24c50ab10.tar.bz2
* generic/tkCanvArc.c (CreateArc): Rework canvas create item
* generic/tkCanvBmap.c (CreateBitmap): type coords handling to be * generic/tkCanvImg.c (CreateImage): consistent across types * generic/tkCanvPoly.c (CreatePolygon): and not pass empty coords * generic/tkCanvLine.c (CreateLine): to item creation procs. * generic/tkCanvText.c (CreateText): * generic/tkCanvWind.c (CreateWinItem): * generic/tkCanvas.c (CanvasWidgetCmd CANV_CREATE): * generic/tkRectOval.c (CreateRectOval): * tests/canvRect.test: * tests/canvText.test: * tests/canvas.test:
Diffstat (limited to 'generic/tkCanvLine.c')
-rw-r--r--generic/tkCanvLine.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index f597843..d8be008 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvLine.c,v 1.12 2003/01/08 23:02:28 drh Exp $
+ * RCS: @(#) $Id: tkCanvLine.c,v 1.13 2003/02/09 07:48:22 hobbs Exp $
*/
#include <stdio.h>
@@ -302,6 +302,10 @@ CreateLine(interp, canvas, itemPtr, objc, objv)
LineItem *linePtr = (LineItem *) itemPtr;
int i;
+ if (objc == 0) {
+ panic("canvas did not pass any coords\n");
+ }
+
/*
* Carry out initialization that is needed to set defaults and to
* allow proper cleanup after errors during the the remainder of
@@ -330,13 +334,13 @@ CreateLine(interp, canvas, itemPtr, objc, objv)
* start with a digit or a minus sign followed by a digit.
*/
- for (i = 0; i < objc; i++) {
+ for (i = 1; i < objc; i++) {
char *arg = Tcl_GetString(objv[i]);
if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) {
break;
}
}
- if (i && (LineCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) {
+ if (LineCoords(interp, canvas, itemPtr, i, objv) != TCL_OK) {
goto error;
}
if (ConfigureLine(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) {
@@ -411,14 +415,15 @@ LineCoords(interp, canvas, itemPtr, objc, objv)
}
}
if (objc & 1) {
- Tcl_AppendResult(interp,
- "odd number of coordinates specified for line",
- (char *) NULL);
+ char buf[64 + TCL_INTEGER_SPACE];
+ sprintf(buf, "wrong # coordinates: expected an even number, got %d",
+ objc);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_ERROR;
} else if (objc < 4) {
- Tcl_AppendResult(interp,
- "too few coordinates specified for line",
- (char *) NULL);
+ char buf[64 + TCL_INTEGER_SPACE];
+ sprintf(buf, "wrong # coordinates: expected at least 4, got %d", objc);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_ERROR;
} else {
numPoints = objc/2;