Index: TODO =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- TODO (.../TODO) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ TODO (.../TODO) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -2034,6 +2034,10 @@ - simplified error handling: removed NsfVarErrMsg() and NsfErrMsg() and replaced it by NsfPrintError() +- testx.xotcl: fix messages when test fails +- further cleanup of error procs: eliminated NsfObjErrArgCnt() +- improve error message, when too many arguments are passed + TODO: - "-returns" Index: generic/nsf.c =================================================================== diff -u -r05303f65fdb9de786d8405ec199e9c59df7f1765 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- generic/nsf.c (.../nsf.c) (revision 05303f65fdb9de786d8405ec199e9c59df7f1765) +++ generic/nsf.c (.../nsf.c) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -256,6 +256,7 @@ static void ParamDefsFree(NsfParamDefs *paramDefs); static int ParamSetFromAny(Tcl_Interp *interp, register Tcl_Obj *objPtr); + /* prototypes for alias management */ static int AliasDelete(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object); static Tcl_Obj *AliasGet(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object); @@ -1226,9 +1227,10 @@ if (cmd && *methodName == ':') { CONST char *procName = Tcl_GetCommandName(interp, cmd); size_t objNameLength = strlen(methodName) - strlen(procName) - 2; - Tcl_DString ds, *dsPtr = &ds; if (objNameLength > 0) { + Tcl_DString ds, *dsPtr = &ds; + /* obtain parent name */ Tcl_DStringInit(dsPtr); Tcl_DStringAppend(dsPtr, methodName, objNameLength); regObject = GetObjectFromNsName(interp, Tcl_DStringValue(dsPtr), fromClassNS); @@ -7575,7 +7577,7 @@ Tcl_DString ds, *dsPtr = &ds; DSTRING_INIT(dsPtr); - Tcl_DStringAppend(dsPtr, className, strlen(className)-strlen(mn)-2); + Tcl_DStringAppend(dsPtr, className, strlen(className) - strlen(mn) - 2); cl = (NsfClass *)GetObjectFromString(interp, Tcl_DStringValue(dsPtr)); DSTRING_FREE(dsPtr); } @@ -10974,7 +10976,7 @@ NsfObject *object = cd->object; if (!object) return NsfObjErrType(interp, objv[0], "object", ObjStr(objv[0])); - if (objc > 2) return NsfObjErrArgCnt(interp, object->cmdName, objv[0], "?value?"); + if (objc > 2) return NsfObjWrongArgs(interp, "wrong # args", object->cmdName, objv[0], "?value?"); if (cd->paramsPtr && objc == 2) { Tcl_Obj *outObjPtr; @@ -11089,8 +11091,8 @@ /*fprintf(stderr, "inserting listElements[%d] '%s'\n", nrPosArgs, ObjStr(listElements[nrPosArgs]));*/ *out = listElements[nrPosArgs]; - } else if (objc<=1) { - return NsfObjErrArgCnt(interp, objv[0], NULL, "option"); + } else if (objc <= 1) { + return NsfObjWrongArgs(interp, "wrong # args", objv[0], NULL, "option"); } else { /*fprintf(stderr, "copying %%1: '%s'\n", ObjStr(objv[firstPosArg]));*/ *out = objv[firstPosArg]; @@ -12054,7 +12056,7 @@ Tcl_DString ds, *dsPtr = &ds; DSTRING_INIT(dsPtr); Tcl_DStringAppend(dsPtr, "Invalid argument '", -1); - Tcl_DStringAppend(dsPtr, ObjStr(objv[pcPtr->lastobjc]), -1); + Tcl_DStringAppend(dsPtr, ObjStr(objv[pcPtr->lastobjc+1]), -1); Tcl_DStringAppend(dsPtr, "', maybe too many arguments;", -1); return ArgumentError(interp, Tcl_DStringValue(dsPtr), paramPtr, object ? object->cmdName : NULL, @@ -13193,13 +13195,8 @@ } if (newCmd) { - Tcl_DString ds, *dsPtr = &ds; + AliasAdd(interp, object->cmdName, methodName, cl == NULL, ObjStr(cmdName)); - Tcl_DStringInit(dsPtr); - Tcl_DStringAppend(dsPtr, ObjStr(cmdName), -1); - AliasAdd(interp, object->cmdName, methodName, cl == NULL, Tcl_DStringValue(dsPtr)); - Tcl_DStringFree(dsPtr); - if (withFrame == FrameMethodIdx) { Tcl_Command_flags(newCmd) |= NSF_CMD_NONLEAF_METHOD; /*fprintf(stderr, "setting aliased for cmd %p %s flags %.6x, tcd = %p\n", Index: generic/nsf.decls =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- generic/nsf.decls (.../nsf.decls) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ generic/nsf.decls (.../nsf.decls) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -114,20 +114,16 @@ int objc, Tcl_Obj *CONST objv[], int flags) } declare 27 generic { - int NsfObjErrArgCnt(Tcl_Interp *interp, Tcl_Obj *cmdName, Tcl_Obj *methodName, - char *arglist) -} -declare 28 generic { int NsfAddObjectMethod(Tcl_Interp *interp, struct Nsf_Object *obj, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags) } -declare 29 generic { +declare 28 generic { int NsfAddClassMethod(Tcl_Interp *interp, struct Nsf_Class *cl, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags) } -declare 30 generic { +declare 29 generic { int NsfCreate(Tcl_Interp *in, Nsf_Class *class, Tcl_Obj *name, ClientData data, int objc, Tcl_Obj *CONST objv[]) } Index: generic/nsfDecls.h =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- generic/nsfDecls.h (.../nsfDecls.h) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ generic/nsfDecls.h (.../nsfDecls.h) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -178,31 +178,25 @@ Tcl_Obj *arg, int objc, Tcl_Obj *CONST objv[], int flags); #endif -#ifndef NsfObjErrArgCnt_TCL_DECLARED -#define NsfObjErrArgCnt_TCL_DECLARED -/* 27 */ -EXTERN int NsfObjErrArgCnt(Tcl_Interp *interp, Tcl_Obj *cmdName, - Tcl_Obj *methodName, char *arglist); -#endif #ifndef NsfAddObjectMethod_TCL_DECLARED #define NsfAddObjectMethod_TCL_DECLARED -/* 28 */ +/* 27 */ EXTERN int NsfAddObjectMethod(Tcl_Interp *interp, struct Nsf_Object *obj, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); #endif #ifndef NsfAddClassMethod_TCL_DECLARED #define NsfAddClassMethod_TCL_DECLARED -/* 29 */ +/* 28 */ EXTERN int NsfAddClassMethod(Tcl_Interp *interp, struct Nsf_Class *cl, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); #endif #ifndef NsfCreate_TCL_DECLARED #define NsfCreate_TCL_DECLARED -/* 30 */ +/* 29 */ EXTERN int NsfCreate(Tcl_Interp *in, Nsf_Class *class, Tcl_Obj *name, ClientData data, int objc, Tcl_Obj *CONST objv[]); @@ -243,10 +237,9 @@ int (*nsfErrBadVal) (Tcl_Interp *interp, char *context, char *expected, CONST char *value); /* 24 */ int (*nsfNextObjCmd) (ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); /* 25 */ int (*nsfCallMethodWithArgs) (ClientData cd, Tcl_Interp *interp, Tcl_Obj *method, Tcl_Obj *arg, int objc, Tcl_Obj *CONST objv[], int flags); /* 26 */ - int (*nsfObjErrArgCnt) (Tcl_Interp *interp, Tcl_Obj *cmdName, Tcl_Obj *methodName, char *arglist); /* 27 */ - int (*nsfAddObjectMethod) (Tcl_Interp *interp, struct Nsf_Object *obj, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 28 */ - int (*nsfAddClassMethod) (Tcl_Interp *interp, struct Nsf_Class *cl, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 29 */ - int (*nsfCreate) (Tcl_Interp *in, Nsf_Class *class, Tcl_Obj *name, ClientData data, int objc, Tcl_Obj *CONST objv[]); /* 30 */ + int (*nsfAddObjectMethod) (Tcl_Interp *interp, struct Nsf_Object *obj, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 27 */ + int (*nsfAddClassMethod) (Tcl_Interp *interp, struct Nsf_Class *cl, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 28 */ + int (*nsfCreate) (Tcl_Interp *in, Nsf_Class *class, Tcl_Obj *name, ClientData data, int objc, Tcl_Obj *CONST objv[]); /* 29 */ } NsfStubs; #ifdef __cplusplus @@ -368,21 +361,17 @@ #define NsfCallMethodWithArgs \ (nsfStubsPtr->nsfCallMethodWithArgs) /* 26 */ #endif -#ifndef NsfObjErrArgCnt -#define NsfObjErrArgCnt \ - (nsfStubsPtr->nsfObjErrArgCnt) /* 27 */ -#endif #ifndef NsfAddObjectMethod #define NsfAddObjectMethod \ - (nsfStubsPtr->nsfAddObjectMethod) /* 28 */ + (nsfStubsPtr->nsfAddObjectMethod) /* 27 */ #endif #ifndef NsfAddClassMethod #define NsfAddClassMethod \ - (nsfStubsPtr->nsfAddClassMethod) /* 29 */ + (nsfStubsPtr->nsfAddClassMethod) /* 28 */ #endif #ifndef NsfCreate #define NsfCreate \ - (nsfStubsPtr->nsfCreate) /* 30 */ + (nsfStubsPtr->nsfCreate) /* 29 */ #endif #endif /* defined(USE_NSF_STUBS) && !defined(USE_NSF_STUB_PROCS) */ Index: generic/nsfError.c =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- generic/nsfError.c (.../nsfError.c) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ generic/nsfError.c (.../nsfError.c) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -134,11 +134,6 @@ } int -NsfObjErrArgCnt(Tcl_Interp *interp, Tcl_Obj *cmdName, Tcl_Obj *methodName, char *arglist) { - return NsfObjWrongArgs(interp, "wrong # args:", cmdName, methodName, arglist); -} - -int NsfErrBadVal(Tcl_Interp *interp, char *context, char *expected, CONST char *value) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, context, ": expected ", expected, " but got '", Index: generic/nsfStubInit.c =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- generic/nsfStubInit.c (.../nsfStubInit.c) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ generic/nsfStubInit.c (.../nsfStubInit.c) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -63,10 +63,9 @@ NsfErrBadVal, /* 24 */ NsfNextObjCmd, /* 25 */ NsfCallMethodWithArgs, /* 26 */ - NsfObjErrArgCnt, /* 27 */ - NsfAddObjectMethod, /* 28 */ - NsfAddClassMethod, /* 29 */ - NsfCreate, /* 30 */ + NsfAddObjectMethod, /* 27 */ + NsfAddClassMethod, /* 28 */ + NsfCreate, /* 29 */ }; /* !END!: Do not edit above this line. */ Index: library/xotcl/library/store/XOTclGdbm/xotclgdbm.c =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- library/xotcl/library/store/XOTclGdbm/xotclgdbm.c (.../xotclgdbm.c) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ library/xotcl/library/store/XOTclGdbm/xotclgdbm.c (.../xotclgdbm.c) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -36,7 +36,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 2) - return NsfObjErrArgCnt(in, obj->cmdName, "open filename"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "open filename"); /* name not in hashtab - create new db */ if (NsfGetObjClientData(obj)) @@ -72,7 +72,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "close"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "close"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -95,7 +95,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "names"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "names"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -132,7 +132,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc <2 || objc > 3) - return NsfObjErrArgCnt(in, obj->cmdName, "set key ?value?"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "set key ?value?"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -176,7 +176,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 2) - return NsfObjErrArgCnt(in, obj->cmdName, "exists variable"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "exists variable"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -203,7 +203,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 2) - return NsfObjErrArgCnt(in, obj->cmdName, "unset key"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "unset key"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -231,7 +231,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "firstkey"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "firstkey"); db = (db_t*) NsfGetObjClientData(obj); if (!db) { @@ -269,7 +269,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "nextkey"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "nextkey"); db = (db_t*) NsfGetObjClientData(obj); if (!db) Index: library/xotcl/library/store/XOTclSdbm/xotclsdbm.c =================================================================== diff -u -r531982261a0deb399b608a42d4469af3d3041399 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- library/xotcl/library/store/XOTclSdbm/xotclsdbm.c (.../xotclsdbm.c) (revision 531982261a0deb399b608a42d4469af3d3041399) +++ library/xotcl/library/store/XOTclSdbm/xotclsdbm.c (.../xotclsdbm.c) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -38,7 +38,7 @@ */ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 2) - return NsfObjErrArgCnt(in, obj->cmdName, "open filename"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "open filename"); /* * check mode string if given @@ -116,7 +116,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "close"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "close"); db = (db_t*) NsfGetObjClientData(obj); if (!db) { @@ -142,7 +142,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "names"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "names"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -177,7 +177,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc <2 || objc > 3) - return NsfObjErrArgCnt(in, obj->cmdName, "set key ?value?"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "set key ?value?"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -224,7 +224,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 2) - return NsfObjErrArgCnt(in, obj->cmdName, "exists variable"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "exists variable"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -251,7 +251,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 2) - return NsfObjErrArgCnt(in, obj->cmdName, "unset key"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "unset key"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -287,7 +287,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "firstkey"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "firstkey"); db = (db_t*) NsfGetObjClientData(obj); if (!db) @@ -315,7 +315,7 @@ if (!obj) return NsfObjErrType(in, obj->cmdName, "Object", ""); if (objc != 1) - return NsfObjErrArgCnt(in, obj->cmdName, "nextkey"); + return NsfObjWrongArgs(in, "wrong # args:", obj->cmdName, "nextkey"); db = (db_t*) NsfGetObjClientData(obj); if (!db) Index: library/xotcl/tests/testx.xotcl =================================================================== diff -u -r4899325051e5df71749b5137ee27227f85d92cf3 -rbb18837f55b64ecdaf970c9e77624bc30f4c417a --- library/xotcl/tests/testx.xotcl (.../testx.xotcl) (revision 4899325051e5df71749b5137ee27227f85d92cf3) +++ library/xotcl/tests/testx.xotcl (.../testx.xotcl) (revision bb18837f55b64ecdaf970c9e77624bc30f4c417a) @@ -3997,7 +3997,7 @@ o y 4 56 5 } m errorCheck $m \ - {Invalid argument '56', maybe too many arguments; should be "::o y ?-x value? ?-a value? a b"} \ + {Invalid argument '5', maybe too many arguments; should be "::o y ?-x value? ?-a value? a b"} \ "wrong \# check 1" catch {