summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2000-05-03 00:14:35 (GMT)
committerhobbs <hobbs>2000-05-03 00:14:35 (GMT)
commit4c8a9811534a3b4a2a4f18a8b336e32f09924f99 (patch)
tree5628ff7c339091fc70acb302e1df79ed6a1940e9 /generic
parentc976f22afb9a851655b7dca553a0ff0dff4175ac (diff)
downloadtcl-4c8a9811534a3b4a2a4f18a8b336e32f09924f99.zip
tcl-4c8a9811534a3b4a2a4f18a8b336e32f09924f99.tar.gz
tcl-4c8a9811534a3b4a2a4f18a8b336e32f09924f99.tar.bz2
* tests/compile.test:
* tests/init.test: * tests/proc.test: * tests/proc-old.test: * tests/rename.test: * generic/tclProc.c: reworked error return for procedures with incorrect args to be like the C Tcl_WrongNumArgs, where a "wrong # args: ..." message is printed out with the args list.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclProc.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c
index feff5a0..d2c8227 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.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: tclProc.c,v 1.23 1999/12/12 02:26:42 hobbs Exp $
+ * RCS: @(#) $Id: tclProc.c,v 1.24 2000/05/03 00:14:35 hobbs Exp $
*/
#include "tclInt.h"
@@ -840,6 +840,7 @@ TclObjInterpProc(clientData, interp, objc, objv)
register CompiledLocal *localPtr;
char *procName;
int nameLen, localCt, numArgs, argCt, i, result;
+ Tcl_Obj *objResult = Tcl_GetObjResult(interp);
/*
* This procedure generates an array "compiledLocals" that holds the
@@ -960,20 +961,32 @@ TclObjInterpProc(clientData, interp, objc, objv)
Tcl_IncrRefCount(objPtr); /* since the local variable now has
* another reference to object. */
} else {
- Tcl_ResetResult(interp);
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "no value given for parameter \"", localPtr->name,
- "\" to \"", Tcl_GetString(objv[0]), "\"", (char *) NULL);
- result = TCL_ERROR;
- goto procDone;
+ goto incorrectArgs;
}
varPtr++;
localPtr = localPtr->nextPtr;
}
if (argCt > 0) {
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "called \"", Tcl_GetString(objv[0]),
- "\" with too many arguments", (char *) NULL);
+ incorrectArgs:
+ /*
+ * Build up equivalent to Tcl_WrongNumArgs message for proc
+ */
+ Tcl_ResetResult(interp);
+ Tcl_AppendStringsToObj(objResult,
+ "wrong # args: should be \"", procName, (char *) NULL);
+ localPtr = procPtr->firstLocalPtr;
+ for (i = 1; i <= numArgs; i++) {
+ if (localPtr->defValuePtr != NULL) {
+ Tcl_AppendStringsToObj(objResult,
+ " ?", localPtr->name, "?", (char *) NULL);
+ } else {
+ Tcl_AppendStringsToObj(objResult,
+ " ", localPtr->name, (char *) NULL);
+ }
+ localPtr = localPtr->nextPtr;
+ }
+ Tcl_AppendStringsToObj(objResult, "\"", (char *) NULL);
+
result = TCL_ERROR;
goto procDone;
}