aboutsummaryrefslogtreecommitdiffstats
path: root/extension/testarg.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 14:40:49 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 14:40:49 +0300
commit85c0d5edb781c9f31b79e48452b1ca68643f41de (patch)
tree14efbc59b30cdd626a208d6391f3ed226387054e /extension/testarg.c
parent6cc7d587a710606d3fe52222707739c7cc1b8651 (diff)
downloadegawk-85c0d5edb781c9f31b79e48452b1ca68643f41de.tar.gz
egawk-85c0d5edb781c9f31b79e48452b1ca68643f41de.tar.bz2
egawk-85c0d5edb781c9f31b79e48452b1ca68643f41de.zip
Move to gawk-3.1.4.
Diffstat (limited to 'extension/testarg.c')
-rw-r--r--extension/testarg.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/extension/testarg.c b/extension/testarg.c
new file mode 100644
index 00000000..747dd515
--- /dev/null
+++ b/extension/testarg.c
@@ -0,0 +1,40 @@
+#include "awk.h"
+
+static NODE *
+do_check_arg(tree)
+NODE *tree;
+{
+ 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);
+
+ arg1 = get_scalar_argument(tree, 0, FALSE);
+ arg2 = get_array_argument(tree, 1, FALSE);
+ arg3 = get_scalar_argument(tree, 2, TRUE); /* optional */
+ if (argc > 3) { /* try to use an extra arg */
+ NODE *arg4;
+ arg4 = get_array_argument(tree, 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);
+}
+
+/* dlload --- load new builtins in this library */
+
+NODE *
+dlload(tree, dl)
+NODE *tree;
+void *dl;
+{
+ make_builtin("check_arg", do_check_arg, 3);
+ return tmp_number((AWKNUM) 0);
+}