[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GAWK 3.1.1 bug, DJGPP port
From: |
Serge Bohdjalian |
Subject: |
Re: GAWK 3.1.1 bug, DJGPP port |
Date: |
Tue, 07 Jan 2003 17:26:10 -0500 |
Hi Stephan,
Thanks for your response. In my ignorance, I didn't realize that "e" (or
"E") could be used for base-10 exponent notation. This partly explained the
strange behaviour I observed. (I would have thought that a "+" or "-"
needed to follow the "e".)
At 2003.01.07 01:49 PM +0100, you wrote:
Hello,
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
Note that with 3 different versions of GAWK for Windows I get ...
C:\TEST>"C:\TEST\gawk310_SourceForge.exe" -f "TEST.AWK" "TEST.TXT"
0 1
1
1
C:\TEST>"C:\TEST\gawk311_Cygwin.exe" -f "TEST.AWK" "TEST.TXT"
0 1
0
0
C:\TEST>"C:\TEST\gawk311_DJGPP.exe" -f "TEST.AWK" "TEST.TXT"
0 0
0
0
(I assume my version of DJGPP GAWK doesn't have the patch you provided.)
I don't see why the last 2 expressions, as you state, should equal 1
(TRUE). From what I understand, if "0" is compared to a numeric constant,
"0" should be interpreted as a number. Presumably, the same principle
should apply to "0e0". I don't understand why "0e0" is treated differently
from "0". The GAWK documentation says...
...
In the next example:
$ echo 1e2 3 | awk '{ print ($1 < $2) ? "true" : "false" }'
-| false
...the result is "false" because both "$1" and "$2"
are user input. They are numeric strings -- therefore both have
the "strnum" attribute, dictating a numeric comparison.
...
When I run the following script...
BEGIN {
$0 = "0";
if ($0) print $0 " = TRUE"; else print $0 " = FALSE";
$0 = "0e0";
if ($0) print $0 " = TRUE"; else print $0 " = FALSE";
}
...I get the following output with my 3 versions of GAWK for Windows...
C:\TEST>"C:\TEST\gawk310_SourceForge.exe" -f "TEST.AWK" "TEST.TXT"
0 = FALSE
0e0 = TRUE
C:\TEST>"C:\TEST\gawk311_Cygwin.exe" -f "TEST.AWK" "TEST.TXT"
0 = FALSE
0e0 = TRUE
C:\TEST>"C:\TEST\gawk311_DJGPP.exe" -f "TEST.AWK" "TEST.TXT"
0 = FALSE
0e0 = FALSE
...
Before I knew that "0e0" could be interpreted as a number, I would have
thought that the first 2 outputs (from SourceForge and Cygwin) were
correct. Now I'm not so sure.
-Serge