bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: GAWK 3.1.1 bug, DJGPP port


From: Stepan Kasal
Subject: Re: GAWK 3.1.1 bug, DJGPP port
Date: Tue, 7 Jan 2003 13:49:06 +0100
User-agent: Mutt/1.2.5.1i

Hello,
        thank you very much for the bug report.  I took me some time to
discover the causes.

On Mon, Dec 30, 2002 at 10:33:10AM -0500, Serge Bohdjalian wrote:
> BEGIN {
>     $0 = "00E0";
>     print $0 ", " ($0 && 1) ", " ($0 != "");
>     $1 = "00E0";
>     print $1 ", " ($1 && 1) ", " ($1 != "");
> }

yields in most GAWK 3.1.1 ports, eg. Cygwin:
> 00E0, 1, 1
> 00E0, 1, 1

which is the correct result.  (See my recent post to comp.lang.awk, id
<address@hidden> for detailed discussion.)

But this is in fact double bug:
1) gawk doesn't recognize that 00E0 is a valid representation of number 0;
2) gawk tries to interpret $0 as number, even though it was assigned
a string constant.

Observe:
        BEGIN {
                # first bug:
                $0 = "0 0e0"
                print $1 && 1, $2 && 2
                
                # second bug:
                $0 = "00"
                print $0 && 1
        
                # and even worse:
                $0 = a = "00"
                print a && 1
        }
gives
        0 1
        0
        0
while correct results are
        0 0
        1
        1

The DJGPP version has the first one fixed, exposing the second one:
> 00E0, 0, 1
> 00E0, 1, 1

The reason is probably that DJGPP environment has old strtod(), probably
C89, not C99 and thus doesn't use gawk's strtod wrapper.

Patches attached.

Regards,
        Stepan Kasal

Attachment: gawk-3.1.1-0e0.patch
Description: Text document

Attachment: gawk-3.1.1-maybe_num.patch
Description: Text document


reply via email to

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