Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"It's what you learn after you know it all that counts." -- John Wooden


devel / comp.lang.awk / Odd bug

SubjectAuthor
* Odd bugMary Karr
`* Re: Odd bugKenny McCormack
 `* Re: Odd bugKaz Kylheku
  `* Re: Odd bugKenny McCormack
   `- Re: Odd bugJanis Papanagnou

1
Odd bug

<c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1470&group=comp.lang.awk#1470

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:ac8:7d14:0:b0:3f3:641b:85f with SMTP id g20-20020ac87d14000000b003f3641b085fmr2392282qtb.10.1685372793005;
Mon, 29 May 2023 08:06:33 -0700 (PDT)
X-Received: by 2002:a05:620a:45a6:b0:75b:c11:f42f with SMTP id
bp38-20020a05620a45a600b0075b0c11f42fmr1538114qkb.10.1685372792824; Mon, 29
May 2023 08:06:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 29 May 2023 08:06:32 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=68.134.9.107; posting-account=hw9--AoAAAAhttY8AR627LOuI4hcIhSa
NNTP-Posting-Host: 68.134.9.107
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com>
Subject: Odd bug
From: karrmary922@gmail.com (Mary Karr)
Injection-Date: Mon, 29 May 2023 15:06:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1266
 by: Mary Karr - Mon, 29 May 2023 15:06 UTC

This code prints "yes" in 4.1

awk 'BEGIN{token = "firstname"; if(token ~ (/^lastname|^firstname/)) {print "yes"} }'

...and in 5.1 prints nothing

The code is user error, there should be no parens around the //.

It's confusing why the versions have different results. Did 4.1 auto-detect the problem?

Re: Odd bug

<u52jkg$9pup$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1471&group=comp.lang.awk#1471

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: Re: Odd bug
Date: Mon, 29 May 2023 16:24:48 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <u52jkg$9pup$1@news.xmission.com>
References: <c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com>
Injection-Date: Mon, 29 May 2023 16:24:48 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="321497"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 29 May 2023 16:24 UTC

In article <c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com>,
Mary Karr <karrmary922@gmail.com> wrote:
>This code prints "yes" in 4.1
>
> awk 'BEGIN{token = "firstname"; if(token ~ (/^lastname|^firstname/)) {print "yes"} }'
>
>..and in 5.1 prints nothing

Confirmed. In 4.1.4, it prints "yes"; in 5.0.1 it prints nothing.

>The code is user error, there should be no parens around the //.
>
>It's confusing why the versions have different results. Did 4.1
>auto-detect the problem?

Actually, it looks like it is a bug fixed in 5.x.
The previous (4.x) behavior is actually incorrect.

Here's my explanation (which you may or may not already know). Basically,
AWK (specifically, GAWK) tries very hard to come up with a legal
interpretation of whatever you throw at it. Kind of like when a human
says something nonsensical to you; you try very hard to come up with an
interpretation of what they said that makes sense. Only if that is not
possible do you tell them that they are speaking gibberish.

What is happening is that when you put a bare regular expression in parens,
it then gets evaluated as either 0 or 1, depending on whether or not the
reg exp matches (i.e., is contained in) $0. The following demonstrates how
to change your program so that a current version of GAWK will print "yes":

$ /usr/bin/gawk 'BEGIN{$0="lastname";token = "first1ame"; if(token ~ (/^lastname|^firstname/)) {print "yes"} }'
yes
$

--
Mike Huckabee has yet to consciously uncouple from Josh Duggar.

Re: Odd bug

<20230529111746.484@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1472&group=comp.lang.awk#1472

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.awk
Subject: Re: Odd bug
Date: Mon, 29 May 2023 18:33:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <20230529111746.484@kylheku.com>
References: <c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com>
<u52jkg$9pup$1@news.xmission.com>
Injection-Date: Mon, 29 May 2023 18:33:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c9a7b14fa665d867d13efc298dfa8530";
logging-data="1667478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++N7LL6rg32VRGW16obauGeOWauU6+JsE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:+48kkDliugRtLWDeRFhXqtOdsFU=
 by: Kaz Kylheku - Mon, 29 May 2023 18:33 UTC

On 2023-05-29, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> What is happening is that when you put a bare regular expression in parens,
> it then gets evaluated as either 0 or 1, depending on whether or not the
> reg exp matches (i.e., is contained in) $0. The following demonstrates how
> to change your program so that a current version of GAWK will print "yes":

Awk is "weird" that way. Ostensibly, it is based on C, but brings
in various quirks, includiing whitespace sensitivities in the middle
of expressions.

In C, parentheses are sanely behaved. Given:

int x = 42;

These are valid:

(x)++;

(x) = (x) + 1;

Parentheses influence associativity and precedence. Other than that,
(x) is exactly the same as x to the point that if x is an lvalue,
so is x, and we can "increment through" and "assign through"
the parentheses.

Not so in Awk, or not all the time.

For instance, try this

BEGIN { (x) = 42; }

Nope! No "assigning through parentheses".

You cannot randomly sprinkle parentheses around expression terms in Awk.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Odd bug

<u538g5$a48d$1@news.xmission.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1473&group=comp.lang.awk#1473

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk
Subject: Re: Odd bug
Date: Mon, 29 May 2023 22:20:53 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <u538g5$a48d$1@news.xmission.com>
References: <c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com> <u52jkg$9pup$1@news.xmission.com> <20230529111746.484@kylheku.com>
Injection-Date: Mon, 29 May 2023 22:20:53 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="332045"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 29 May 2023 22:20 UTC

In article <20230529111746.484@kylheku.com>,
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>On 2023-05-29, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> What is happening is that when you put a bare regular expression in parens,
>> it then gets evaluated as either 0 or 1, depending on whether or not the
>> reg exp matches (i.e., is contained in) $0. The following demonstrates how
>> to change your program so that a current version of GAWK will print "yes":
>
>Awk is "weird" that way. Ostensibly, it is based on C, but brings
>in various quirks, includiing whitespace sensitivities in the middle
>of expressions.

Note, BTW, that if you change the slashes to quotes - i.e., put:

token ~ ("^lastname|^firstname"))

the problem goes away (though other problems may appear).

--
The key difference between faith and science is that in science, evidence that
doesn't fit the theory tends to weaken the theory (that is, make it less likely to
be believed), whereas in faith, contrary evidence just makes faith stronger (on
the assumption that Satan is testing you - trying to make you abandon your faith).

Re: Odd bug

<u53erm$1mvdu$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1474&group=comp.lang.awk#1474

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: Odd bug
Date: Tue, 30 May 2023 02:09:26 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u53erm$1mvdu$1@dont-email.me>
References: <c4685425-7035-4a1d-8948-8c1a8bbe2b9cn@googlegroups.com>
<u52jkg$9pup$1@news.xmission.com> <20230529111746.484@kylheku.com>
<u538g5$a48d$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 30 May 2023 00:09:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0616311dc03c0f1a427803497012b625";
logging-data="1801662"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C8xGAjVgZt3VHy3t8aLI9"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:xYTgEZpVF2A89cDV3ITS4vcVDHk=
In-Reply-To: <u538g5$a48d$1@news.xmission.com>
 by: Janis Papanagnou - Tue, 30 May 2023 00:09 UTC

On 30.05.2023 00:20, Kenny McCormack wrote:
> In article <20230529111746.484@kylheku.com>,
> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>> On 2023-05-29, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>>> What is happening is that when you put a bare regular expression in parens,
>>> it then gets evaluated as either 0 or 1, depending on whether or not the
>>> reg exp matches (i.e., is contained in) $0. The following demonstrates how
>>> to change your program so that a current version of GAWK will print "yes":
>>
>> Awk is "weird" that way. Ostensibly, it is based on C, but brings
>> in various quirks, includiing whitespace sensitivities in the middle
>> of expressions.
>
> Note, BTW, that if you change the slashes to quotes - i.e., put:
>
> token ~ ("^lastname|^firstname"))
>
> the problem goes away (though other problems may appear).

Other problems than those inherent to dynamic regexps? - Looks fine to me.

Janis

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor