bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Tentative CSV extension - please advise


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Tentative CSV extension - please advise
Date: Tue, 15 Mar 2016 08:38:20 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Mar 15, 2016 at 02:18:21AM -0600, address@hidden wrote:
> > > 1.- The extension should provide CSV field values as $1-$NF
> >
> > That sounds right.
> >
> > > 2.- The current extension api only allows to provide a string value for 
> > > $0,
> > > but not individual field values. $0 is split into fields by the gawk core
> > > according to the current FS.
> >
> > I took a look at the awk_input_buf_t API, and you are right. And it has to 
> > be
> > this way, since the file could also be read using getline into a variable, 
> > in
> > which case the notion of $1-$NF does not apply.
> 
> The right way to do this is to extend the extension mechanism with a function
> pointer that sets the fields.  Or more likely to add a fields array pointer
> to the awk_input_buf_t and a flag indicating that the values should be used.

That will work well in most cases, but do we want to try to support getline
into a variable where the code may later call split on that variable? If so, we
would need to find a way to extend the split() function as well. Maybe it's too
difficult to do that...

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]