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

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

Re: Debian awk and mawk substr bug (was semicolon bug)


From: Aharon Robbins
Subject: Re: Debian awk and mawk substr bug (was semicolon bug)
Date: Tue, 14 Sep 2004 09:52:29 +0300

Actually, the bug is also in your program.  substr() expects that the numbering
for the first character starts at 1.  You're using 0.  Mawk interprets
that differently than most other awks do.  I bet if you use

        substr($0, 1, length($0) - 6)

it'll work the way you expect it to, everywhere.

Arnold

In article <address@hidden> you write:
>Hello,
>
>Chapman Flack wrote:
>
>>Are you sure it is not a length() or substr() bug, rather than a (less likely)
>>bug specific to semicolons?  Notice that the lines you give as input to awk
>>differ between the two examples below; in the second example there is no
>>semicolon on the first line of input.  The second example behavior is
>>therefore consistent with an interpretation that length() or substr() is
>>simply off by one, nothing to do with semicolons.
>>
>>-Chap
>>  
>>
>
>Yes, sorry.
>
>It appears to be substr() bug in Debian's *mawk* and Debian's *awk*. Not 
>semicolon related and length returns the right value.
>
>
>address@hidden:~/Purdue/CVSData/OpenVM$ /usr/bin/awk '{ print substr($0, 
>0, length($0) - 6) } '
>somestring123456
>somestrin
>
>address@hidden:~/Purdue/CVSData/OpenVM$ /usr/bin/mawk '{ print 
>substr($0, 0, length($0) - 6) } '
>somestring123456
>somestrin
>
>address@hidden:~/Purdue/CVSData/OpenVM$ /usr/local/bin/awk '{ print 
>substr($0, 0, length($0) - 6) } '
>somestring123456
>somestring
>
>Cheers,
>Alex.
>
>------------------------------------------------------------
>Alex Potanin
>PhD Student
>SMCS, VUW
>
>Office: +64 (4) 463 5302
>Mobile: +64 (21) 737 654
>
>http://www.mcs.vuw.ac.nz/~alex/
>------------------------------------------------------------
>
>
>


-- 
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd.     arnold AT skeeve DOT com
P.O. Box 354            Home Phone: +972  8 979-0381    Fax: +1 206 350 8765
Nof Ayalon              Cell Phone: +972 50  729-7545
D.N. Shimshon 99785     ISRAEL




reply via email to

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