Sujet : Re: Breaking a table of record rows into an array
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.awkDate : 13. Mar 2024, 17:22:35
Autres entêtes
Organisation : None to speak of
Message-ID : <87y1am5cfo.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
arnold@freefriends.org (Aharon Robbins) writes:
In article <usqkgn$he7u$2@dont-email.me>,
Ed Morton <mortonspam@gmail.com> wrote:
the effect of setting `NF` is
undefined behavior per POSIX and so will do different things in
different awk variants and even in 1 awk variant can behave differently
depending on whether you're setting it to a higher or lower than
original value
>
This is not true. The effect of setting NF was well defined
by the original awk book and also in POSIX.
>
Decreasing NF throws away fields. Increasing NF adds the
intervening fields with the null string as their values
and rebuilds the record.
I don't see that in the POSIX specification.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html"""
NF
The number of fields in the current record. Inside a BEGIN action,
the use of NF is undefined unless a getline function without a var
argument is executed previously. Inside an END action, NF shall
retain the value it had for the last record read, unless a
subsequent, redirected, getline function without a var argument is
performed prior to entering the END action.
"""
I don't see an explicit statement that assigning to NF has undefined
behavior. The last sentence seems to imply, if taken literally, that
assigning to NF doesn't change its value, at least within an END
section. Perhaps it's merely an oversight, or perhaps I've missed
something.
Do you see something in POSIX that defines the behavior of assigning to
NF?
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comWorking, but not speaking, for Medtronicvoid Void(void) { Void(); } /* The recursive call of the void */