Re: Breaking a table of record rows into an array

Liste des GroupesRevenir à cl awk 
Sujet : Re: Breaking a table of record rows into an array
De : mortonspam (at) *nospam* gmail.com (Ed Morton)
Groupes : comp.lang.awk
Date : 14. Mar 2024, 13:32:45
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <usuqpe$1joik$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 3/14/2024 7:09 AM, Ed Morton wrote:
On 3/14/2024 5:50 AM, Ed Morton wrote:
On 3/14/2024 1:19 AM, Aharon Robbins wrote:
In article <87y1am5cfo.fsf@nosuchdomain.example.com>,
Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
Do you see something in POSIX that defines the behavior of assigning to
NF?
>
In the section "Variables and Special Values"
>
| References to nonexistent fields (that is, fields after $NF), shall
| evaluate to the uninitialized value. Such references shall not create
| new fields. However, assigning to a nonexistent field (for example,
| $(NF+2)=5) shall increase the value of NF; create any intervening fields
| with the uninitialized value; and cause the value of $0 to be
| recomputed, with the fields being separated by the value of OFS. Each
| field variable shall have a string value or an uninitialized value when
| created.
>
It doesn't say what happens when you do NF -= 2; nonetheless, all
traditional awks throw away fields when you do something like that.
>
It doesn't say what happens when you do NF += 2 either. All I'm saying is that changing the value of NF is undefined behavior per POSIX.
>
I'm not sure which awks would be considered "traditional" vs otherwise but AFAIK POSIX is descriptive, i.e. describes how X behaves rather than dictates the behavior of X, so if the appropriate set of awk variants all behave the same way for any behavior such as this that's currently undefined by POSIX (changing the value of NF, the value of $0 in the end section, and field splitting with a null FS being the 3 most commonly used cases IMO) then maybe the folks who write that spec could/should update it to describe that behavior but I don't know which awks all behave the same way for those cases, nor if that's enough of them for POSIX to make a definition.
>
     Ed.
 I couldn't find any existing tickets so I just created tickets with the Austin Group to request that definitions for the 3 cases I listed above be added to the POSIX spec:
 1) Changing the value of NF = https://www.austingroupbugs.net/view.php?id=1820
2) The value of $0, $1, etc. in an END section = https://www.austingroupbugs.net/view.php?id=1821
3) Splitting using a null field separator = https://www.austingroupbugs.net/view.php?id=1822
I just added a final ticket from me for the other undefined behavior I fairly often see people relying on (e.g. when creating multi-line records by reading 1 line at a time to handle quoted fields that include newlines without gawk --csv):
4) Changing the value of NR or FNR = https://www.austingroupbugs.net/view.php?id=1823

Obviously I've no idea if they'll be implemented or not but AFAIK it doesn't hurt to ask. I said "in most modern awks..." in each of them, if anyone knows which specific awks behave in the ways I described (or which don't) then feel free to comment on the issues if you can, I just don't have access to multiple awk variants at this time.
 Regards,
      Ed.

Date Sujet#  Auteur
11 Mar 24 * Re: Breaking a table of record rows into an array19Mr. Man-wai Chang
11 Mar 24 +- Re: Breaking a table of record rows into an array1Keith Thompson
12 Mar 24 +- Re: Breaking a table of record rows into an array1Janis Papanagnou
13 Mar 24 `* Re: Breaking a table of record rows into an array16Ed Morton
13 Mar 24  `* Re: Breaking a table of record rows into an array15Aharon Robbins
13 Mar 24   +* Re: Breaking a table of record rows into an array13Keith Thompson
13 Mar 24   i+* Re: Breaking a table of record rows into an array7Kaz Kylheku
13 Mar 24   ii`* Re: Breaking a table of record rows into an array6Keith Thompson
13 Mar 24   ii +* Re: Breaking a table of record rows into an array4Kaz Kylheku
14 Mar 24   ii i+* Re: Breaking a table of record rows into an array2Ed Morton
14 Mar 24   ii ii`- Re: Breaking a table of record rows into an array1Kaz Kylheku
14 Mar 24   ii i`- Re: Breaking a table of record rows into an array1Keith Thompson
14 Mar 24   ii `- Re: Breaking a table of record rows into an array1Kaz Kylheku
14 Mar 24   i`* Re: Breaking a table of record rows into an array5Aharon Robbins
14 Mar 24   i +- Re: Breaking a table of record rows into an array1Keith Thompson
14 Mar 24   i `* Re: Breaking a table of record rows into an array3Ed Morton
14 Mar 24   i  `* Re: Breaking a table of record rows into an array2Ed Morton
14 Mar 24   i   `- Re: Breaking a table of record rows into an array1Ed Morton
14 Mar 24   `- Re: Breaking a table of record rows into an array1Ed Morton

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal