Subject: bin/25543: AWK's gensub(re,repl,N,src) mis-handles N.
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <rkr@olib.org>
List: netbsd-bugs
Date: 05/12/2004 10:38:14
>Number: 25543
>Category: bin
>Synopsis: AWK's gensub(re,repl,N,src) mis-handles N.
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed May 12 10:39:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Richard Rauch
>Release: Pre-2.0 -current.
>Organization:
n/a
>Environment:
NetBSD odysseus 1.6ZK NetBSD 1.6ZK (odysseus) #1: Wed Mar 17 05:27:46 CST 2004 root@atlas:/usr/netbsd/current/src/sys/arch/i386/compile/obj.i386/odysseus i386
>Description:
I'm not sure if this has been fixed, but there's no outstanding bug-
report, and with 2.0 looming close I decided to fire off a bug report
before attempting to update my system.
echo "helloello" | awk '{print gensub ("ello","i",1,$0);}'
...prints "hiello" in GNU's gawk, but
prints "helloi" in NetBSD's nawk.
I believe that gensub() is a GNUism, so gawk's handling is
presumably correct by definition.
>How-To-Repeat:
echo "helloello" | awk '{print gensub ("ello","i",1,$0);}'
>Fix:
My copy of userland sources should be quite recent, though my last
compile-and-install of userland was some time back. If the above bug
still manifests, then I think you can fix it with this patch to
.../src/dist/nawk/run.c (+ for new, - for old), around line 1950:
if (sptr[0] == 'g' || sptr[0] == 'G')
whichm = -1;
else
- whichm = (int) getfval(h);
+ whichm = (int) getfval(h) + 1;
tempfree(h);
if (pmatch(pfa, t)) {
...(untested)
>Release-Note:
>Audit-Trail:
>Unformatted: