[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug in param_cnt
From: |
Roman Putanowicz |
Subject: |
bug in param_cnt |
Date: |
Sat, 7 Feb 2004 22:59:12 +0100 |
Hi,
I am using gawk gawk-3.1.3.
In the manual section describing dynamic extension the following
code fragment:
/* check arg count */
if (tree->param_cnt != 2)
fatal(
"stat: called with %d arguments, should be 2",
tree->param_cnt);
suggests that tree->param_cnt holds the actual number of
parameters the function was called with.
Unfortunately from my experiments it turns out that
tree->param_cnt holds not the actual number of parameters
but the number which was given to the make_builtin.
Here is the code I played with:
/*------------------------------------------
#include "awk.h"
static NODE *
foo(NODE *tree)
{
printf("nargs : %d\n", tree->param_cnt);
return tmp_number((AWKNUM) 0);
}
NODE *
dlload(NODE *tree, void *dl)
{
make_builtin("foo", foo, 23);
return tmp_number((AWKNUM)0);
}
//-------------------------------------------
Compiled into dynamic extension in all circumstances
gives 'nargs : 23'.
I would appreciate any hints as how to fix that or how
to get the actual number of arguments.
Regards
Roman Putanowicz
- bug in param_cnt,
Roman Putanowicz <=