mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Print placeholder args when printing error message for user function invoked with incorrect number of arguments.
This commit is contained in:
16
src/expr.c
16
src/expr.c
@@ -626,6 +626,18 @@ debug_exit_userfunc(expr_node *node, Value *ans, int r, Value *locals, int nargs
|
||||
fprintf(ErrFp, "\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_placeholders(int n)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<n; i++) {
|
||||
if (i > 0) {
|
||||
fprintf(ErrFp, ", ");
|
||||
}
|
||||
fprintf(ErrFp, "?");
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* eval_userfunc - evaluate a user-defined function */
|
||||
@@ -667,12 +679,12 @@ eval_userfunc(expr_node *node, Value *locals, Value *ans, int *nonconst)
|
||||
|
||||
/* Make sure we have the right number of arguments */
|
||||
if (node->num_kids < f->nargs) {
|
||||
DBG(fprintf(ErrFp, "%s(...) => %s\n", fname, GetErr(E_2FEW_ARGS)));
|
||||
DBG(fprintf(ErrFp, "%s(", fname); print_placeholders(node->num_kids); fprintf(ErrFp, ") => %s\n", GetErr(E_2FEW_ARGS)));
|
||||
Eprint("%s(): %s", f->name, GetErr(E_2FEW_ARGS));
|
||||
return E_2FEW_ARGS;
|
||||
}
|
||||
if (node->num_kids > f->nargs) {
|
||||
DBG(fprintf(ErrFp, "%s(...) => %s\n", fname, GetErr(E_2MANY_ARGS)));
|
||||
DBG(fprintf(ErrFp, "%s(", fname); print_placeholders(node->num_kids); fprintf(ErrFp, ") => %s\n", GetErr(E_2MANY_ARGS)));
|
||||
Eprint("%s(): %s", f->name, GetErr(E_2MANY_ARGS));
|
||||
return E_2MANY_ARGS;
|
||||
}
|
||||
|
||||
@@ -5833,10 +5833,10 @@ max()
|
||||
|
||||
fset dooby(x) 1
|
||||
set zxk dooby()
|
||||
dooby(...) => Not enough arguments
|
||||
dooby() => Not enough arguments
|
||||
../tests/test.rem(1123): dooby(): Not enough arguments
|
||||
set zxk dooby(1, 2)
|
||||
dooby(...) => Too many arguments
|
||||
dooby(?, ?) => Too many arguments
|
||||
../tests/test.rem(1124): dooby(): Too many arguments
|
||||
set zxk dooby(1)
|
||||
Entering UserFN dooby(1)
|
||||
|
||||
Reference in New Issue
Block a user