source: trunk/essentials/sys-apps/gawk/extension/testarg.c

Last change on this file was 3076, checked in by bird, 18 years ago

gawk 3.1.5

File size: 1.0 KB
Line 
1#include "awk.h"
2
3static NODE *
4do_check_arg(tree)
5NODE *tree;
6{
7 int ret = 0, argc;
8 NODE *arg1, *arg2, *arg3;
9
10 argc = get_curfunc_arg_count();
11 printf("arg count: defined = %d, supplied = %d\n", tree->param_cnt, argc);
12
13 arg1 = get_scalar_argument(tree, 0, FALSE);
14 arg2 = get_array_argument(tree, 1, FALSE);
15 arg3 = get_scalar_argument(tree, 2, TRUE); /* optional */
16 if (argc > 3) { /* try to use an extra arg */
17 NODE *arg4;
18 arg4 = get_array_argument(tree, 3, TRUE);
19 }
20 if (arg3 != NULL)
21 printf("3rd arg present\n\n");
22 else
23 printf("no 3rd arg\n\n");
24 /* Set the return value */
25 set_value(tmp_number((AWKNUM) ret));
26
27 /* Just to make the interpreter happy */
28 return tmp_number((AWKNUM) 0);
29}
30
31/* dlload --- load new builtins in this library */
32
33NODE *
34dlload(tree, dl)
35NODE *tree;
36void *dl;
37{
38 make_builtin("check_arg", do_check_arg, 3);
39 return tmp_number((AWKNUM) 0);
40}
Note: See TracBrowser for help on using the repository browser.