summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2018-10-08 12:00:00 (GMT)
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2018-10-08 12:00:00 (GMT)
commitfa194741f8b801f258aed9fbb6b1448dce97173b (patch)
tree9a66113a3440c396e5d97ccf8224a0453eca6561
parent9b8c9769c0b7ad4e232550609f8e99d3d5b24f3c (diff)
downloadblt-fa194741f8b801f258aed9fbb6b1448dce97173b.zip
blt-fa194741f8b801f258aed9fbb6b1448dce97173b.tar.gz
blt-fa194741f8b801f258aed9fbb6b1448dce97173b.tar.bz2
Correct numargs checks and output error message
Many other commands not fixed in *Op.C files.
-rw-r--r--generic/tkbltGrAxisOp.C48
-rw-r--r--generic/tkbltGrElemOp.C59
-rw-r--r--generic/tkbltGrMarkerOp.C42
3 files changed, 121 insertions, 28 deletions
diff --git a/generic/tkbltGrAxisOp.C b/generic/tkbltGrAxisOp.C
index e467d53..fb3277e 100644
--- a/generic/tkbltGrAxisOp.C
+++ b/generic/tkbltGrAxisOp.C
@@ -98,8 +98,10 @@ static int CgetOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId option");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -112,8 +114,10 @@ static int ConfigureOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId ?option value?...");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -126,8 +130,10 @@ static int ActivateOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -160,8 +166,10 @@ static int CreateOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
if (graphPtr->createAxis(objc, objv) != TCL_OK)
return TCL_ERROR;
@@ -174,8 +182,10 @@ static int DeleteOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -194,8 +204,10 @@ static int InvTransformOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId scoord");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -208,8 +220,10 @@ static int LimitsOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -222,8 +236,10 @@ static int MarginOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -237,6 +253,10 @@ static int NamesOp(ClientData clientData, Tcl_Interp* interp,
{
Graph* graphPtr = (Graph*)clientData;
Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
+ if (objc<3) {
+ Tcl_WrongNumArgs(interp, 3, objv, "?pattern...?");
+ return TCL_ERROR;
+ }
if (objc == 3) {
Tcl_HashSearch cursor;
for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->axes_.table, &cursor); hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
@@ -267,8 +287,10 @@ static int TransformOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId coord");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -281,8 +303,10 @@ static int TypeOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
@@ -295,8 +319,10 @@ static int ViewOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "axisId");
return TCL_ERROR;
+ }
Axis* axisPtr;
if (graphPtr->getAxis(objv[3], &axisPtr) != TCL_OK)
diff --git a/generic/tkbltGrElemOp.C b/generic/tkbltGrElemOp.C
index af6fc0c..7235a8e 100644
--- a/generic/tkbltGrElemOp.C
+++ b/generic/tkbltGrElemOp.C
@@ -89,8 +89,8 @@ static int CgetOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "cget option");
+ if (objc!=5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId option");
return TCL_ERROR;
}
@@ -113,8 +113,10 @@ static int ConfigureOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId ?option value...?");
return TCL_ERROR;
+ }
Element* elemPtr;
if (graphPtr->getElement(objv[3], &elemPtr) != TCL_OK)
@@ -140,6 +142,11 @@ static int ActivateOp(ClientData clientData, Tcl_Interp* interp,
{
Graph* graphPtr = (Graph*)clientData;
+ if (objc<3) {
+ Tcl_WrongNumArgs(interp, 3, objv, "?elemId? ?index...?");
+ return TCL_ERROR;
+ }
+
// List all the currently active elements
if (objc == 3) {
Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
@@ -211,8 +218,10 @@ static int ClosestOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<5)
+ if (objc<5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "x y ?elemName?...");
return TCL_ERROR;
+ }
GraphOptions* gops = (GraphOptions*)graphPtr->ops_;
ClosestSearch* searchPtr = &gops->search;
@@ -283,8 +292,11 @@ static int CreateOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId");
return TCL_ERROR;
+ }
if (graphPtr->createElement(objc, objv) != TCL_OK)
return TCL_ERROR;
@@ -299,6 +311,10 @@ static int CreateOp(ClientData clientData, Tcl_Interp* interp,
static int DeactivateOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId...");
+ return TCL_ERROR;
+ }
Graph* graphPtr = (Graph*)clientData;
for (int ii=3; ii<objc; ii++) {
Element* elemPtr;
@@ -320,6 +336,10 @@ static int DeactivateOp(ClientData clientData, Tcl_Interp* interp,
static int DeleteOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId...");
+ return TCL_ERROR;
+ }
Graph* graphPtr = (Graph*)clientData;
for (int ii=3; ii<objc; ii++) {
Element* elemPtr;
@@ -339,8 +359,11 @@ static int ExistsOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId");
return TCL_ERROR;
+ }
Tcl_HashEntry *hPtr =
Tcl_FindHashEntry(&graphPtr->elements_.table, Tcl_GetString(objv[3]));
@@ -353,6 +376,11 @@ static int LowerOp(ClientData clientData, Tcl_Interp* interp,
{
Graph* graphPtr = (Graph*)clientData;
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId...");
+ return TCL_ERROR;
+ }
+
// Move the links of lowered elements out of the display list into
// a temporary list
Chain* chain = new Chain();
@@ -400,6 +428,11 @@ static int NamesOp(ClientData clientData, Tcl_Interp* interp,
{
Graph* graphPtr = (Graph*)clientData;
+ if (objc<3) {
+ Tcl_WrongNumArgs(interp, 3, objv, "?pattern...?");
+ return TCL_ERROR;
+ }
+
Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
if (objc == 3) {
Tcl_HashSearch iter;
@@ -433,6 +466,11 @@ static int RaiseOp(ClientData clientData, Tcl_Interp* interp,
{
Graph* graphPtr = (Graph*)clientData;
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId...");
+ return TCL_ERROR;
+ }
+
Chain* chain = new Chain();
for (int ii=3; ii<objc; ii++) {
Element* elemPtr;
@@ -476,8 +514,10 @@ static int ShowOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "?nameList?");
return TCL_ERROR;
+ }
int elemObjc;
Tcl_Obj** elemObjv;
@@ -535,8 +575,11 @@ static int TypeOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "elemId");
return TCL_ERROR;
+ }
Element* elemPtr;
if (graphPtr->getElement(objv[3], &elemPtr) != TCL_OK)
diff --git a/generic/tkbltGrMarkerOp.C b/generic/tkbltGrMarkerOp.C
index 20933ab..917052d 100644
--- a/generic/tkbltGrMarkerOp.C
+++ b/generic/tkbltGrMarkerOp.C
@@ -157,8 +157,10 @@ static int CgetOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "markerId option");
return TCL_ERROR;
+ }
Marker* markerPtr;
if (GetMarkerFromObj(interp, graphPtr, objv[3], &markerPtr) != TCL_OK)
@@ -179,8 +181,10 @@ static int ConfigureOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "markerId ?option value...?");
return TCL_ERROR;
+ }
Marker* markerPtr;
if (GetMarkerFromObj(interp, graphPtr, objv[3], &markerPtr) != TCL_OK)
@@ -219,15 +223,22 @@ static int BindOp(ClientData clientData, Tcl_Interp* interp,
}
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
+ } else if (objc >= 4) {
+ return graphPtr->bindTable_->configure(graphPtr->markerTag(Tcl_GetString(objv[3])), objc - 4, objv + 4);
+ } else {
+ Tcl_WrongNumArgs(interp, 3, objv, "markerId ?tag? ?sequence? ?command?");
+ return TCL_ERROR;
}
-
- return graphPtr->bindTable_->configure(graphPtr->markerTag(Tcl_GetString(objv[3])), objc - 4, objv + 4);
}
static int CreateOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 2, objv, "markerId ?type? ?option value...?");
+ return TCL_ERROR;
+ }
if (CreateMarker(graphPtr, interp, objc, objv) != TCL_OK)
return TCL_ERROR;
// set in CreateMarker
@@ -243,6 +254,11 @@ static int DeleteOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
+
+ if (objc<4) {
+ Tcl_WrongNumArgs(interp, 2, objv, "markerId...");
+ return TCL_ERROR;
+ }
for (int ii=3; ii<objc; ii++) {
Marker* markerPtr;
if (GetMarkerFromObj(NULL, graphPtr, objv[ii], &markerPtr) != TCL_OK) {
@@ -264,8 +280,10 @@ static int ExistsOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "markerId");
return TCL_ERROR;
+ }
Tcl_HashEntry* hPtr =
Tcl_FindHashEntry(&graphPtr->markers_.table, Tcl_GetString(objv[3]));
@@ -278,8 +296,10 @@ static int FindOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=8) {
+ Tcl_WrongNumArgs(interp, 3, objv, "searchtype left top right bottom");
return TCL_ERROR;
+ }
const char* string = Tcl_GetString(objv[3]);
int mode;
@@ -378,8 +398,10 @@ static int RelinkOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4 && objc!=5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "markerId ?placeId?");
return TCL_ERROR;
+ }
Marker* markerPtr;
if (GetMarkerFromObj(interp, graphPtr, objv[3], &markerPtr) != TCL_OK)
@@ -411,8 +433,10 @@ static int TypeOp(ClientData clientData, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Graph* graphPtr = (Graph*)clientData;
- if (objc<4)
+ if (objc!=4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "markerId");
return TCL_ERROR;
+ }
Marker* markerPtr;
if (GetMarkerFromObj(interp, graphPtr, objv[3], &markerPtr) != TCL_OK)
@@ -450,7 +474,7 @@ static int GetMarkerFromObj(Tcl_Interp* interp, Graph* graphPtr,
}
if (interp) {
Tcl_AppendResult(interp, "can't find marker \"", string,
- "\" in \"", Tk_PathName(graphPtr->tkwin_), NULL);
+ "\" in \"", Tk_PathName(graphPtr->tkwin_), "\"", NULL);
}
return TCL_ERROR;