Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 127163 - gawk-3.1.5 bug with FIELDWIDTHS
Summary: gawk-3.1.5 bug with FIELDWIDTHS
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-22 02:34 UTC by Ramon Garcia
Modified: 2006-04-11 17:12 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed fix (field.c.diff,532 bytes, patch)
2006-03-22 02:34 UTC, Ramon Garcia
Details | Diff
gawk-3.1.5-fieldwidths.patch (gawk-3.1.5-fieldwidths.patch,822 bytes, patch)
2006-04-10 22:06 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ramon Garcia 2006-03-22 02:34:04 UTC
I have recently emerged gawk-3.1.5. This caused to break my scripts because of a bug in handling of FIELDWIDTHS (a feature of GNU awk to parse text files with fields of fixed width). Apparently there is a bug in the routine that parses FIELDWIDTHS. I am attaching a patch.

This has been reported to the maintainer of GNU awk with no answer at the moment.
Comment 1 Ramon Garcia 2006-03-22 02:34:50 UTC
Created attachment 82853 [details, diff]
Proposed fix
Comment 2 Ramon Garcia 2006-03-22 02:42:11 UTC
Here is a simple test case of the bug

AWK script:

#!/usr/bin/awk -f
BEGIN {
   FIELDWIDTHS = "15 15 15 ";
}
{
   x = $1;
   y = $2;
   z = $3;
   print "x y z", x, y, z
}


Awk input file (ensure that each column is 15 characters wide):

   0.4867373206   1.3206333033  -0.2333178127
   0.5668176165   1.3711756314  -0.2193558040
   0.4325251781   1.3399488722  -0.1568307497


Expected output

x y z    0.4867373206    1.3206333033   -0.2333178127
x y z    0.5668176165    1.3711756314   -0.2193558040
x y z    0.4325251781    1.3399488722   -0.1568307497


Obtained output:

x y z    0.4867373206    1.3206333033
x y z    0.5668176165    1.3711756314
x y z    0.4325251781    1.3399488722
Comment 3 Ramon Garcia 2006-03-22 12:28:26 UTC
In the previous script there is a bug. There should be no space after the last number.

Instead of:

FIELDWIDTHS = "15 15 15 ";

it should be:

FIELDWIDTHS = "15 15 15";
Comment 4 SpanKY gentoo-dev 2006-04-10 22:06:08 UTC
Created attachment 84420 [details, diff]
gawk-3.1.5-fieldwidths.patch

try this patch from Fedora instead
Comment 5 SpanKY gentoo-dev 2006-04-11 17:12:37 UTC
should be fixed with gawk-3.1.5-r1