| Deutsch English Français Italiano |
|
<vtjlif$1tmav$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.awk
Subject: Re: Nitpicking the code (Was: Experiences with match()
subexpressions?)
Date: Mon, 14 Apr 2025 20:53:01 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <vtjlif$1tmav$1@dont-email.me>
References: <vt7qlq$2ge70$1@dont-email.me> <vt7qs4$2gior$1@dont-email.me>
<vt9q0n$70fm$1@dont-email.me> <vtgtkr$3br8e$1@dont-email.me>
<vtjjlf$1ni8g$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Apr 2025 20:53:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5f5bc6df05680b5fde3314ed5014a43e";
logging-data="2021727"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4eLHQyDS71j/IqpvaSIz8"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Tw1JIsjgf83M8yN0W5Oq2fhIn7c=
In-Reply-To: <vtjjlf$1ni8g$1@news.xmission.com>
Bytes: 2681
On 14.04.2025 20:20, Kenny McCormack wrote:
> In article <vtgtkr$3br8e$1@dont-email.me>,
> Ed Morton <mortonspam@gmail.com> wrote:
> ...
>> data = "R=\"R=r1,R=r2\",R=r2,R=r3,E=e"
>> nf = patsplit(data, arr, /[RE]=([^,]*|"([^"]|"")*")/)
>> delete arr
>> for ( i in arr ) {
>> sub(/[^=]+=/, "", arr[i])
>> }
>
> This can't be right, since if the sequence:
> delete arr
> for (i in arr) ...
> can't possibly do anything. I.e., the for statement will be a no-op, since
> the array is empty at that point.
>
>> or any awk:
>>
>> data = "R=\"R=r1,R=r2\",R=r2,R=r3,E=e"
>> nf = 0
>> delete arr
>> while ( match(data, /[RE]=([^,]*|"([^"]|"")*")/, a) ) {
>> arr[++nf] = substr(data, RSTART+2, RLENGTH-2)
>> data = substr(data, RSTART+RLENGTH)
>> }
>
> I believe "delete arr" (without an index, hence removing the entire array)
> is an "extension". I can't quite quote chapter and verse, but I note that
> "man mawk" explicitly mentions that mawk supports this syntax, thereby
> implying that it isn't "standard". Of course, gawk supports it as well.
>
> So, if by "any awk", you mean "strictly standard", then, well, you can see
> where I am going with this.
I seem to recall that a standard way to clear an array could be using
split("", arr)
for example. To my taste it looks a bit clumsy, not as nice as using
'delete', but well, whatever one prefers.
Janis