bug-gawk
[Top][All Lists]
Advanced

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

Re: numeric instead of string comparison with array indices that look li


From: arnold
Subject: Re: numeric instead of string comparison with array indices that look like numbers
Date: Fri, 19 Apr 2024 07:13:14 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hello.

It's not related. I will send out a fix in a minute.

Arnold

alexandre.ferrieux@orange.com wrote:

> Hi Ed,
>
> Is this related to 
> https://lists.nongnu.org/archive/html/bug-gawk/2024-02/msg00024.html ?
> (In both cases the problem is implicit integer/string conversions in array 
> indices.)
>
> -Alex
>
> On 19/04/2024 13:05, Ed Morton wrote:
> > --------------------------------------------------------------------------------------------------------------
> >  
> >
> > CAUTION : This email originated outside the company. Do not click on any 
> > links 
> > or open attachments unless you are expecting them from the sender.
> >
> > ATTENTION : Cet e-mail provient de l'extérieur de l'entreprise. Ne cliquez 
> > pas 
> > sur les liens ou n'ouvrez pas les pièces jointes à moins de connaitre 
> > l'expéditeur.
> > --------------------------------------------------------------------------------------------------------------
> >  
> >
> >
> > Configuration Information [Automatically generated, do not change]:
> > Machine: x86_64
> > OS: cygwin
> > Compiler: gcc
> > Compilation CFLAGS: -ggdb -O2 -pipe -Wall -Werror=format-security 
> > -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 
> > -fdebug-prefix-map=/cygdrive/d/a/scallywag/gawk/gawk-5.3.0-1.x86_64/build=/usr/src/debug/gawk-5.3.0-1
> >  
> > -fdebug-prefix-map=/cygdrive/d/a/scallywag/gawk/gawk-5.3.0-1.x86_64/src/gawk-5.3.0=/usr/src/debug/gawk-5.3.0-1
> >  
> > -DNDEBUG
> > uname output: CYGWIN_NT-10.0-22631 TournaMart_2023 3.5.3-1.x86_64 
> > 2024-04-03 
> > 17:25 UTC x86_64 Cygwin
> > Machine Type: x86_64-pc-cygwin
> >
> > Gawk Version: 5.3.0
> >
> > Attestation 1:
> >         I have read 
> > https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
> >         Yes
> >
> > Attestation 2:
> >         I have not modified the sources before building gawk.
> >         True
> >
> > Description:
> >         gawk is [presumably] doing numeric instead of string comparisons 
> > when
> >         using an array index (always a string) on one side of the comparison
> >         and a number on the other. This behavior can be modified just by
> >         calling `typeof()` on the array index before the comparison.
> >
> > Repeat-By:
> >         In the following, `"10"` is always a string and we're always 
> > comparing
> >         `"10" < 2` but note there's no output from the second script that's
> >         using a variable populated from the array index and we can cause it
> >         to produce the expected output just by adding a call to `typeof()`
> >         in the third script:
> >
> >         1) $ awk 'BEGIN{ i="10"; if(i < 2) print i }'
> >            10
> >            $
> >
> >         2) $ awk 'BEGIN{ a["10"]; for (i in a) { if(i < 2) print i } }'
> >            $
> >
> >         3) $ awk 'BEGIN{ a["10"]; for (i in a) { print typeof(i); if(i < 2) 
> > print i } }'
> >            string
> >            10
> >            $
>
> ____________________________________________________________________________________________________________
> Ce message et ses pieces jointes peuvent contenir des informations 
> confidentielles ou privilegiees et ne doivent donc
> pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu 
> ce message par erreur, veuillez le signaler
> a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
> electroniques etant susceptibles d'alteration,
> Orange decline toute responsabilite si ce message a ete altere, deforme ou 
> falsifie. Merci.
>
> This message and its attachments may contain confidential or privileged 
> information that may be protected by law;
> they should not be distributed, used or copied without authorisation.
> If you have received this email in error, please notify the sender and delete 
> this message and its attachments.
> As emails may be altered, Orange is not liable for messages that have been 
> modified, changed or falsified.
> Thank you.



reply via email to

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