[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in param_cnt
From: |
Aharon Robbins |
Subject: |
Re: bug in param_cnt |
Date: |
Wed, 11 Feb 2004 15:09:03 +0200 |
I think you get the actual number of arguments by looping through
the linked lists of lnodes and rnodes and stopping when you're done.
The dynamic extension stuff is something of a "bag on the side" and
IMHO is not well designed or implemented. That feature was contributed,
and I put it in since it's useful, but I hope (one day) to redesign
and reimplement it.
Hope this helps,
Arnold
> Date: Sat, 7 Feb 2004 22:59:12 +0100
> From: Roman Putanowicz <address@hidden>
> To: address@hidden
> Subject: bug in param_cnt
>
> 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, 2004/02/07
- Re: bug in param_cnt,
Aharon Robbins <=