Subject: Re: bug in gawk/gsub() (not present in nawk)
To: Jose Nazario <jose@monkey.org>
From: Stepan Kasal <kasal@math.cas.cz>
List: netbsd-bugs
Date: 06/05/2003 09:37:27
Hello,
On Thu, Jun 05, 2003 at 12:14:19AM -0400, Jose Nazario wrote:
> $ awk --version
> GNU Awk 3.0.3
> Copyright (C) 1989, 1991-1997 Free Software Foundation.
that is a really old version.
But I've found out gawk-3.1.1 contains this bug too (and thus probably
all releases between).
The latest release, 3.1.2, works correctly. (It contain new regex.c.)
> gsub(/[\ \"-\/\\:;\[\]\@\?\.\,\$]/, "", $2)
> print $2
>
> in gawk, as found in netbsd-macppc/1.5.2, this will drop the first letter
> of every word. the resulting string will be "hissitleyitle", while in nawk
> as built on openbsd-3.3 this will get it correct.
I have found out that in gawk-3.0.3 and gawk-3.1.1, it's sufficient to
replace \/ by / so that the range "-/ is recognized correctly:
gsub(/[\ \"-/\\:;\[\]\@\?\.\,\$]/, "", $2)
But there is no need to use so many backslashes, I'd use:
gsub(/[ "-/\\:;\[\]@?.,$]/, "", $2)
HTH,
Stepan Kasal