summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvLine.c
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2001-07-03 06:03:43 (GMT)
committerhobbs <hobbs@noemail.net>2001-07-03 06:03:43 (GMT)
commitf44c22955d661238e30d8005cc67b7733fb5fd3d (patch)
treed82a322c1b1966e7a46b7a95f56775e4d6722eac /generic/tkCanvLine.c
parent3a83d90975fc03e07eab7bb72710585c52eeae9a (diff)
downloadtk-f44c22955d661238e30d8005cc67b7733fb5fd3d.zip
tk-f44c22955d661238e30d8005cc67b7733fb5fd3d.tar.gz
tk-f44c22955d661238e30d8005cc67b7733fb5fd3d.tar.bz2
* generic/tkCanvArc.c:
* generic/tkCanvBmap.c: * generic/tkCanvLine.c: * generic/tkCanvPoly.c: * generic/tkCanvText.c: * generic/tkCanvWind.c: * generic/tkRectOval.c: corrected argument handling in Create<Item> functions that could lead to ABRs or FMRs and corrected names of argc/argv to objc/objv. FossilOrigin-Name: 3f8a55343c45de15bfeb8794b4c28537b170b719
Diffstat (limited to 'generic/tkCanvLine.c')
-rw-r--r--generic/tkCanvLine.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index 708490d..9a0c369 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.8 2000/10/24 23:51:33 ericm Exp $
+ * RCS: @(#) $Id: tkCanvLine.c,v 1.9 2001/07/03 06:03:44 hobbs Exp $
*/
#include <stdio.h>
@@ -83,13 +83,13 @@ static int ArrowheadPostscript _ANSI_ARGS_((Tcl_Interp *interp,
static void ComputeLineBbox _ANSI_ARGS_((Tk_Canvas canvas,
LineItem *linePtr));
static int ConfigureLine _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- Tcl_Obj *CONST argv[], int flags));
+ Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tcl_Obj *CONST objv[], int flags));
static int ConfigureArrows _ANSI_ARGS_((Tk_Canvas canvas,
LineItem *linePtr));
static int CreateLine _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, Tcl_Obj *CONST argv[]));
+ int objc, Tcl_Obj *CONST objv[]));
static void DeleteLine _ANSI_ARGS_((Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display));
static void DisplayLine _ANSI_ARGS_((Tk_Canvas canvas,
@@ -100,7 +100,7 @@ static int GetLineIndex _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *obj, int *indexPtr));
static int LineCoords _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- int argc, Tcl_Obj *CONST argv[]));
+ int objc, Tcl_Obj *CONST objv[]));
static void LineDeleteCoords _ANSI_ARGS_((Tk_Canvas canvas,
Tk_Item *itemPtr, int first, int last));
static void LineInsert _ANSI_ARGS_((Tk_Canvas canvas,
@@ -291,13 +291,13 @@ Tk_ItemType tkLineType = {
*/
static int
-CreateLine(interp, canvas, itemPtr, argc, argv)
+CreateLine(interp, canvas, itemPtr, objc, objv)
Tcl_Interp *interp; /* Interpreter for error reporting. */
Tk_Canvas canvas; /* Canvas to hold new item. */
Tk_Item *itemPtr; /* Record to hold new item; header
* has been initialized by caller. */
- int argc; /* Number of arguments in argv. */
- Tcl_Obj *CONST argv[]; /* Arguments describing line. */
+ int objc; /* Number of arguments in objv. */
+ Tcl_Obj *CONST objv[]; /* Arguments describing line. */
{
LineItem *linePtr = (LineItem *) itemPtr;
int i;
@@ -330,17 +330,16 @@ CreateLine(interp, canvas, itemPtr, argc, argv)
* start with a digit or a minus sign followed by a digit.
*/
- for (i = 0; i < argc; i++) {
- char *arg = Tcl_GetStringFromObj(argv[i], NULL);
- if ((arg[0] == '-') && (arg[1] >= 'a')
- && (arg[1] <= 'z')) {
+ for (i = 0; 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, argv) != TCL_OK)) {
+ if (i && (LineCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) {
goto error;
}
- if (ConfigureLine(interp, canvas, itemPtr, argc-i, argv+i, 0) == TCL_OK) {
+ if (ConfigureLine(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) {
return TCL_OK;
}
@@ -368,21 +367,21 @@ CreateLine(interp, canvas, itemPtr, argc, argv)
*/
static int
-LineCoords(interp, canvas, itemPtr, argc, argv)
+LineCoords(interp, canvas, itemPtr, objc, objv)
Tcl_Interp *interp; /* Used for error reporting. */
Tk_Canvas canvas; /* Canvas containing item. */
Tk_Item *itemPtr; /* Item whose coordinates are to be
* read or modified. */
- int argc; /* Number of coordinates supplied in
- * argv. */
- Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1,
+ int objc; /* Number of coordinates supplied in
+ * objv. */
+ Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1,
* x2, y2, ... */
{
LineItem *linePtr = (LineItem *) itemPtr;
int i, numPoints;
double *coordPtr;
- if (argc == 0) {
+ if (objc == 0) {
int numCoords;
Tcl_Obj *subobj, *obj = Tcl_NewObj();
@@ -405,27 +404,27 @@ LineCoords(interp, canvas, itemPtr, argc, argv)
Tcl_SetObjResult(interp, obj);
return TCL_OK;
}
- if (argc == 1) {
- if (Tcl_ListObjGetElements(interp, argv[0], &argc,
- (Tcl_Obj ***) &argv) != TCL_OK) {
+ if (objc == 1) {
+ if (Tcl_ListObjGetElements(interp, objv[0], &objc,
+ (Tcl_Obj ***) &objv) != TCL_OK) {
return TCL_ERROR;
}
}
- if (argc & 1) {
+ if (objc & 1) {
Tcl_AppendResult(interp,
"odd number of coordinates specified for line",
(char *) NULL);
return TCL_ERROR;
- } else if (argc < 4) {
+ } else if (objc < 4) {
Tcl_AppendResult(interp,
"too few coordinates specified for line",
(char *) NULL);
return TCL_ERROR;
} else {
- numPoints = argc/2;
+ numPoints = objc/2;
if (linePtr->numPoints != numPoints) {
coordPtr = (double *) ckalloc((unsigned)
- (sizeof(double) * argc));
+ (sizeof(double) * objc));
if (linePtr->coordPtr != NULL) {
ckfree((char *) linePtr->coordPtr);
}
@@ -433,8 +432,8 @@ LineCoords(interp, canvas, itemPtr, argc, argv)
linePtr->numPoints = numPoints;
}
coordPtr = linePtr->coordPtr;
- for (i = 0; i <argc; i++) {
- if (Tk_CanvasGetCoordFromObj(interp, canvas, argv[i],
+ for (i = 0; i <objc; i++) {
+ if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[i],
coordPtr++) != TCL_OK) {
return TCL_ERROR;
}
@@ -481,12 +480,12 @@ LineCoords(interp, canvas, itemPtr, argc, argv)
*/
static int
-ConfigureLine(interp, canvas, itemPtr, argc, argv, flags)
+ConfigureLine(interp, canvas, itemPtr, objc, objv, flags)
Tcl_Interp *interp; /* Used for error reporting. */
Tk_Canvas canvas; /* Canvas containing itemPtr. */
Tk_Item *itemPtr; /* Line item to reconfigure. */
- int argc; /* Number of elements in argv. */
- Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */
+ int objc; /* Number of elements in objv. */
+ Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */
int flags; /* Flags to pass to Tk_ConfigureWidget. */
{
LineItem *linePtr = (LineItem *) itemPtr;
@@ -497,7 +496,7 @@ ConfigureLine(interp, canvas, itemPtr, argc, argv, flags)
Tk_State state;
tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv,
+ if (Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, (char **) objv,
(char *) linePtr, flags|TK_CONFIG_OBJS) != TCL_OK) {
return TCL_ERROR;
}
@@ -981,7 +980,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
Tcl_Obj *obj; /* New coordinates to be inserted. */
{
LineItem *linePtr = (LineItem *) itemPtr;
- int length, argc, i;
+ int length, objc, i;
double *new, *coordPtr;
Tk_State state = itemPtr->state;
Tcl_Obj **objv;
@@ -990,8 +989,8 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
state = ((TkCanvas *)canvas)->canvas_state;
}
- if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &argc, &objv) != TCL_OK)
- || !argc || argc&1) {
+ if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &objc, &objv) != TCL_OK)
+ || !objc || objc&1) {
return;
}
length = 2*linePtr->numPoints;
@@ -1009,11 +1008,11 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0];
linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
}
- new = (double *) ckalloc((unsigned)(sizeof(double) * (length + argc)));
+ new = (double *) ckalloc((unsigned)(sizeof(double) * (length + objc)));
for(i=0; i<beforeThis; i++) {
new[i] = linePtr->coordPtr[i];
}
- for(i=0; i<argc; i++) {
+ for(i=0; i<objc; i++) {
if (Tcl_GetDoubleFromObj((Tcl_Interp *) NULL,objv[i],
new+(i+beforeThis))!=TCL_OK) {
Tcl_ResetResult(((TkCanvas *)canvas)->interp);
@@ -1023,11 +1022,11 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
}
for(i=beforeThis; i<length; i++) {
- new[i+argc] = linePtr->coordPtr[i];
+ new[i+objc] = linePtr->coordPtr[i];
}
if(linePtr->coordPtr) ckfree((char *)linePtr->coordPtr);
linePtr->coordPtr = new;
- linePtr->numPoints = (length + argc)/2;
+ linePtr->numPoints = (length + objc)/2;
if ((length>3) && (state != TK_STATE_HIDDEN)) {
/*
@@ -1040,14 +1039,14 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
*/
itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW;
- if (beforeThis>0) {beforeThis -= 2; argc+=2; }
- if ((beforeThis+argc)<length) argc+=2;
+ if (beforeThis>0) {beforeThis -= 2; objc+=2; }
+ if ((beforeThis+objc)<length) objc+=2;
if (linePtr->smooth) {
if(beforeThis>0) {
- beforeThis-=2; argc+=2;
+ beforeThis-=2; objc+=2;
}
- if((beforeThis+argc+2)<length) {
- argc+=2;
+ if((beforeThis+objc+2)<length) {
+ objc+=2;
}
}
itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis];
@@ -1059,7 +1058,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
TkIncludePoint(itemPtr, coordPtr);
}
}
- if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+argc)>=length)) {
+ if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+objc)>=length)) {
/* include old last arrow */
for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
i++, coordPtr += 2) {
@@ -1067,7 +1066,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
}
}
coordPtr = linePtr->coordPtr+beforeThis+2;
- for(i=2; i<argc; i+=2) {
+ for(i=2; i<objc; i+=2) {
TkIncludePoint(itemPtr, coordPtr);
coordPtr+=2;
}
@@ -1094,7 +1093,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj)
TkIncludePoint(itemPtr, coordPtr);
}
}
- if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+argc)<(length-2))) {
+ if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+objc)<(length-2))) {
/* include new right arrow */
for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
i++, coordPtr += 2) {