[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gensub() indirectly called with more than 2 parameters: produce a st
From: |
Denis Shirokov |
Subject: |
Re: gensub() indirectly called with more than 2 parameters: produce a strange error |
Date: |
Wed, 22 Jan 2025 17:33:45 +0200 |
Great question!
ср, 22 янв. 2025 г. в 16:29, Andrew J. Schorr <
aschorr@telemetry-investments.com>:
> Hi,
>
> Is that the issue, or is it that the indirect gensub call
> is requiring 2 args instead of 3 or 4?
>
> In builtin.c:call_sub, the code says:
>
> if (flags == 0 || flags == GSUB) {
> /* sub or gsub */
> if (nargs != 2)
> fatal(_("%s: can be called indirectly only with
> two arguments"), name);
> ...
> } else {
> /* gensub */
> if (nargs < 3 || nargs > 4)
> fatal(_("indirect call to gensub requires three or
> four arguments"));
>
> So why is this insisting on only 2 args?
>
> Regards,
> Andy
>
> On Wed, Jan 22, 2025 at 01:16:21AM -0700, arnold@skeeve.com wrote:
> > "Arguments" is a synonym for "parameters". I will see if it makes
> > sense to try to use only one term everywhere.
> >
> > Thanks,
> >
> > Arnold
> >
> > Denis Shirokov <cosmogen@gmail.com> wrote:
> >
> > > Hi GAWK Team!
> > >
> > > the built-in gensub() generate strange error in case if called
> infirectly
> > > with more than two parameters
> > >
> > > to reproduce this issue run attached (example.gwk) script using:
> > >
> > > gawk -f ./example.gwk
> > >
> > > example:
> > >
> > > BEGIN{
> > > f = "awk::gensub"
> > > a = b = c = d = ""
> > > @f( a, b, c, d )
> > > }
> > >
> > > outputs:
> > >
> > > gawk: ./example.gwk:7: fatal: awk::gensub: can be called
> indirectly
> > > only with two arguments
> > >
> > > two arguments? =(
> > >
> > > Regards
> > > Denis
>
>