diff options
Diffstat (limited to 'extension/testarg.c')
-rw-r--r-- | extension/testarg.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/extension/testarg.c b/extension/testarg.c index 747dd515..42fd4dd6 100644 --- a/extension/testarg.c +++ b/extension/testarg.c @@ -1,31 +1,29 @@ #include "awk.h" static NODE * -do_check_arg(tree) -NODE *tree; +do_check_arg(int nargs) { int ret = 0, argc; NODE *arg1, *arg2, *arg3; argc = get_curfunc_arg_count(); - printf("arg count: defined = %d, supplied = %d\n", tree->param_cnt, argc); + printf("arg count: defined = %d, supplied = %d\n", + nargs, argc); - arg1 = get_scalar_argument(tree, 0, FALSE); - arg2 = get_array_argument(tree, 1, FALSE); - arg3 = get_scalar_argument(tree, 2, TRUE); /* optional */ + arg1 = get_scalar_argument(0, FALSE); + arg2 = get_array_argument(1, FALSE); + arg3 = get_scalar_argument(2, TRUE); /* optional */ if (argc > 3) { /* try to use an extra arg */ NODE *arg4; - arg4 = get_array_argument(tree, 3, TRUE); + arg4 = get_array_argument(3, TRUE); } if (arg3 != NULL) printf("3rd arg present\n\n"); else printf("no 3rd arg\n\n"); - /* Set the return value */ - set_value(tmp_number((AWKNUM) ret)); - /* Just to make the interpreter happy */ - return tmp_number((AWKNUM) 0); + /* Set the return value */ + return make_number((AWKNUM) ret); } /* dlload --- load new builtins in this library */ @@ -36,5 +34,5 @@ NODE *tree; void *dl; { make_builtin("check_arg", do_check_arg, 3); - return tmp_number((AWKNUM) 0); + return make_number((AWKNUM) 0); } |