diff options
Diffstat (limited to 'extension')
-rw-r--r-- | extension/ChangeLog | 25 | ||||
-rw-r--r-- | extension/arrayparm.c | 5 | ||||
-rw-r--r-- | extension/filefuncs.c | 37 | ||||
-rw-r--r-- | extension/fork.c | 8 | ||||
-rw-r--r-- | extension/ordchr.c | 7 | ||||
-rw-r--r-- | extension/readfile.c | 6 | ||||
-rwxr-xr-x | extension/steps | 3 | ||||
-rw-r--r-- | extension/testarg.awk | 6 | ||||
-rw-r--r-- | extension/testarg.c | 40 |
9 files changed, 104 insertions, 33 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog new file mode 100644 index 00000000..60805ec4 --- /dev/null +++ b/extension/ChangeLog @@ -0,0 +1,25 @@ +Mon Aug 2 12:18:15 2004 Arnold D. Robbins <arnold@skeeve.com> + + * Release 3.1.4: Release tar file made. + +Mon Jun 21 17:02:37 2004 Arnold D. Robbins <arnold@skeeve.com> + + More from John Haque. + + * testarg.c, testarg.awk: New files. + * arrayparm.c (do_mkarray): Change call of `get_curfunc_parm_count' + to `get_curfunc_arg_count'. + * filefuncs.c (do_chdir, do_stat): Ditto. + * fork.c (do_fork, do_waitpid): Ditto. + * ordchr.c (do_ord, do_chr): Ditto. + * readfile.c (do_readfile): Ditto. + * steps: Updated. + +Mon Jun 14 14:01:16 2004 Arnold D. Robbins <arnold@skeeve.com> + + ChangeLog started. + + Changes from John Haque and ADR to rationalize extension functions. + + * extension/filefuncs.c: Revised for new functionality. See + corresponding entry in main ChangeLog. diff --git a/extension/arrayparm.c b/extension/arrayparm.c index 6c627d65..d2e18d5b 100644 --- a/extension/arrayparm.c +++ b/extension/arrayparm.c @@ -6,10 +6,11 @@ * 10/2001 * * Revised 7/2003 + * Revised 6/2004 */ /* - * Copyright (C) 2001, 2003 the Free Software Foundation, Inc. + * Copyright (C) 2001, 2003, 2004 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -47,7 +48,7 @@ NODE *tree; NODE *var, *sub, *val; NODE **elemval; - if (do_lint && tree->param_cnt > 3) + if (do_lint && get_curfunc_arg_count() > 3) lintwarn("mkarray: called with too many arguments"); var = get_argument(tree, 0); diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 194db28f..ed86875a 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -3,10 +3,11 @@ * to the file system. * * Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998 + * Arnold Robbins and John Haque, update for 3.1.4, applied Mon Jun 14 13:55:30 IDT 2004 */ /* - * Copyright (C) 2001 the Free Software Foundation, Inc. + * Copyright (C) 2001, 2004 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -39,20 +40,15 @@ NODE *tree; NODE *newdir; int ret = -1; - if (do_lint && tree->param_cnt > 1) - lintwarn("chdir: called with too many arguments"); - - newdir = get_argument(tree, 0); - if (newdir != NULL) { - (void) force_string(newdir); - ret = chdir(newdir->stptr); - if (ret < 0) - update_ERRNO(); - - free_temp(newdir); - } else if (do_lint) - lintwarn("chdir: called with no arguments"); + if (do_lint && get_curfunc_arg_count() != 1) + lintwarn("chdir: called with incorrect number of arguments"); + newdir = get_scalar_argument(tree, 0, FALSE); + (void) force_string(newdir); + ret = chdir(newdir->stptr); + if (ret < 0) + update_ERRNO(); + free_temp(newdir); /* Set the return value */ set_value(tmp_number((AWKNUM) ret)); @@ -179,17 +175,12 @@ NODE *tree; char *pmode; /* printable mode */ char *type = "unknown"; - /* check arg count */ - if (tree->param_cnt != 2) - fatal( - "stat: called with incorrect number of arguments (%d), should be 2", - tree->param_cnt); + if (do_lint && get_curfunc_arg_count() > 2) + lintwarn("stat: called with too many arguments"); /* directory is first arg, array to hold results is second */ - file = get_argument(tree, 0); - array = get_argument(tree, 1); - - array = get_array(array); + file = get_scalar_argument(tree, 0, FALSE); + array = get_array_argument(tree, 1, FALSE); /* empty out the array */ assoc_clear(array); diff --git a/extension/fork.c b/extension/fork.c index 6f020318..8ba7d0d6 100644 --- a/extension/fork.c +++ b/extension/fork.c @@ -1,9 +1,11 @@ /* * fork.c - Provide fork and waitpid functions for gawk. + * + * Revised 6/2004 */ /* - * Copyright (C) 2001 the Free Software Foundation, Inc. + * Copyright (C) 2001, 2004 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -34,7 +36,7 @@ NODE *tree; int ret = -1; NODE **aptr; - if (do_lint && tree->param_cnt > 0) + if (do_lint && get_curfunc_arg_count() > 0) lintwarn("fork: called with too many arguments"); ret = fork(); @@ -71,7 +73,7 @@ NODE *tree; pid_t pid; int options = 0; - if (do_lint && tree->param_cnt > 1) + if (do_lint && get_curfunc_arg_count() > 1) lintwarn("waitpid: called with too many arguments"); pidnode = get_argument(tree, 0); diff --git a/extension/ordchr.c b/extension/ordchr.c index 037bfa37..4849ede8 100644 --- a/extension/ordchr.c +++ b/extension/ordchr.c @@ -4,10 +4,11 @@ * Arnold Robbins * arnold@skeeve.com * 8/2001 + * Revised 6/2004 */ /* - * Copyright (C) 2001 the Free Software Foundation, Inc. + * Copyright (C) 2001, 2004 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -38,7 +39,7 @@ NODE *tree; NODE *str; int ret = -1; - if (do_lint && tree->param_cnt > 1) + if (do_lint && get_curfunc_arg_count() > 1) lintwarn("ord: called with too many arguments"); str = get_argument(tree, 0); @@ -70,7 +71,7 @@ NODE *tree; str[0] = str[1] = '\0'; - if (do_lint && tree->param_cnt > 1) + if (do_lint && get_curfunc_arg_count() > 1) lintwarn("chr: called with too many arguments"); num = get_argument(tree, 0); diff --git a/extension/readfile.c b/extension/readfile.c index 65f0efca..d9a01ffd 100644 --- a/extension/readfile.c +++ b/extension/readfile.c @@ -5,10 +5,12 @@ * Tue Apr 23 17:43:30 IDT 2002 * Revised per Peter Tillier * Mon Jun 9 17:05:11 IDT 2003 + * Revised for new dynamic function facilities + * Mon Jun 14 14:53:07 IDT 2004 */ /* - * Copyright (C) 2002, 2003 the Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2004 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -47,7 +49,7 @@ NODE *tree; char *text; int fd; - if (do_lint && tree->param_cnt > 1) + if (do_lint && get_curfunc_arg_count() > 1) lintwarn("readfile: called with too many arguments"); filename = get_argument(tree, 0); diff --git a/extension/steps b/extension/steps index 8bac5d85..7ff5265f 100755 --- a/extension/steps +++ b/extension/steps @@ -2,6 +2,7 @@ # Tue Nov 24 15:04:14 EST 1998 # Sun Aug 26 16:03:58 IDT 2001 # Sun Apr 28 15:59:57 IDT 2002 +# Mon Jun 21 17:03:37 IDT 2004 gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. dl.c gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. filefuncs.c @@ -9,9 +10,11 @@ gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. fork.c gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. ordchr.c gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. arrayparm.c gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. readfile.c +gcc -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. testarg.c ld -o dl.so -shared dl.o ld -o filefuncs.so -shared filefuncs.o ld -o fork.so -shared fork.o ld -o ordchr.so -shared ordchr.o ld -o arrayparm.so -shared arrayparm.o ld -o readfile.so -shared readfile.o +ld -o testarg.so -shared testarg.o diff --git a/extension/testarg.awk b/extension/testarg.awk new file mode 100644 index 00000000..4b9eb517 --- /dev/null +++ b/extension/testarg.awk @@ -0,0 +1,6 @@ +BEGIN { + extension("./testarg.so", "dlload") + check_arg(x, a); + check_arg(y, b, z); + check_arg(p, q, r, s); +} 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); +} |