[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Incorrect setting of some '$' fields when FS = "" and LINT = 1
From: |
Nick Hobson |
Subject: |
Incorrect setting of some '$' fields when FS = "" and LINT = 1 |
Date: |
Thu, 1 Oct 2009 19:41:01 -0700 (PDT) |
Hi,
I think I've found a gawk bug. I have demonstrated it in gawk 3.1.7 under Arch
Linux and in gawk 3.1.6 under Xubuntu 8.10.
The program is:
#! /usr/bin/gawk -f
BEGIN {LINT = 1; FS = ""}
{
for (i = 1; i <= NF; i++) {
a[$i]++
print FNR, i, $i
}
}
The input data file is:
abc xyz
When run as gawk-bug test-input > test-output, the expected output is:
1 1 a
1 2 b
1 3 c
1 4
1 5 x
1 6 y
1 7 z
The actual output is:
1 1 a
1 2 \0
1 3 \0
1 4
1 5 \0
1 6 y
1 7 \0
(where '\0' is a binary zero.)
So the problem is that $2, $3, $5 and $7 are incorrectly being set to binary
zero.
Curiously, the bug goes away if:
(a) LINT = 1 is removed (or changed to LINT = 0),
(b) a[$i]++ is removed, or
(c) FS = "" is removed -- in which case the actual output is as expected:
1 1 abc
1 2 xyz
Attached: gawk-bug, test-input, test-output
Regards,
Nick Hobson
gawk-bug
Description: Binary data
test-input
Description: Binary data
test-output
Description: Binary data
- Incorrect setting of some '$' fields when FS = "" and LINT = 1,
Nick Hobson <=