NetBSD Problem Report #48667
From www@NetBSD.org Wed Mar 19 17:25:18 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 47939A5800
for <gnats-bugs@gnats.NetBSD.org>; Wed, 19 Mar 2014 17:25:18 +0000 (UTC)
Message-Id: <20140319172517.18A8BA5808@mollari.NetBSD.org>
Date: Wed, 19 Mar 2014 17:25:17 +0000 (UTC)
From: kuehro@gmx.de
Reply-To: kuehro@gmx.de
To: gnats-bugs@NetBSD.org
Subject: awk: man page for gsub shows wrong order of arguments
X-Send-Pr-Version: www-1.0
>Number: 48667
>Category: bin
>Synopsis: awk: man page for gsub shows wrong order of arguments
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 19 17:30:00 +0000 2014
>Closed-Date: Sun Mar 23 01:31:47 +0000 2014
>Last-Modified: Sun Mar 23 01:31:47 +0000 2014
>Originator: Kai-Uwe Eckhardt
>Release: 6.99.36 amd64
>Organization:
>Environment:
>Description:
man 1 awk shows gsub(r, t, [s]) instead of gsub(r, s, [t]) as defined
in POSIX and implemented in awk.
>How-To-Repeat:
>Fix:
--- awk.1.orig 2014-03-19 18:06:18.000000000 +0100
+++ awk.1 2014-03-19 18:09:23.000000000 +0100
@@ -419,7 +419,7 @@
are
.Em not
supported at this moment.
-.It Fn gsub r t "[s]"
+.It Fn gsub r s "[t]"
same as
.Fn sub
except that all occurrences of the regular expression
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 21 Mar 2014 18:13:52 +0000
State-Changed-Why:
gsub(r, t, [s])
same as sub() except that all occurrences of the regular
expression are replaced; sub() and gsub() return the number of
replacements.
sub(r, t, [s])
substitutes t for the first occurrence of the regular expression
r in the string s. If s is not given, $0 is used.
% echo hi | awk '{ sub(".", "x", $0); print $0; }'
xi
Seems to me like it's doing what the man page says. Can you clarify?
From: "Kai-Uwe Eckhardt" <kuehro@gmx.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Aw: Re: bin/48667 (awk: man page for gsub shows wrong order of
arguments)
Date: Fri, 21 Mar 2014 19:25:52 +0100
>
> % echo hi | awk '{ sub(".", "x", $0); print $0; }'
> xi
>
> Seems to me like it's doing what the man page says. Can you clarify?
In the man page s means substition string and t the target string, in which
teh substitution should take place. So it would be sub(".", $0, "x")
according to the man page:
gensub(r, s, h, [t])
Search the target string t for matches of the regular expression
r. If h is a string beginning with g or G, then replace all
matches of r with s. Otherwise, h is a number indicating which
match of r to replace. If no t is supplied, $0 is used instead.
Unlike sub() and gsub(), the modified string is returned as the
result of the function, and the original target is not changed.
Note that the \n sequences within replacement string s supported
by GNU awk are not supported at this moment.
gsub(r, t, [s])
same as sub() except that all occurrences of the regular expres-
sion are replaced; sub() and gsub() return the number of replace-
ments.
Kai-Uwe
From: "Kai-Uwe Eckhardt" <kuehro@gmx.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Aw: Re: bin/48667 (awk: man page for gsub shows wrong order of
arguments)
Date: Fri, 21 Mar 2014 19:37:43 +0100
> sub(r, t, [s])
> substitutes t for the first occurrence of the regular expression
> r in the string s. If s is not given, $0 is used.
>
> % echo hi | awk '{ sub(".", "x", $0); print $0; }'
> xi
>
> Seems to me like it's doing what the man page says. Can you clarify?
Yes, you are right. I was using the definition in gensub instead of sub.
Sorry for the confusion.
Kai-Uwe
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: Re: bin/48667 (awk: man page for gsub shows wrong order of
arguments)
Date: Sun, 23 Mar 2014 01:29:05 +0000
On Fri, Mar 21, 2014 at 06:40:01PM +0000, Kai-Uwe Eckhardt wrote:
> > Seems to me like it's doing what the man page says. Can you clarify?
>
> Yes, you are right. I was using the definition in gensub instead of sub.
> Sorry for the confusion.
Ah... well, you're right too, in that it's unnecessarily confusing for
them to not be consistent.
--
David A. Holland
dholland@netbsd.org
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48667 CVS commit: src/external/historical/nawk/bin
Date: Sun, 23 Mar 2014 01:29:12 +0000
Module Name: src
Committed By: dholland
Date: Sun Mar 23 01:29:12 UTC 2014
Modified Files:
src/external/historical/nawk/bin: awk.1
Log Message:
Change the argument names in the prototypes and discussion for
sub/gsub to match those in gensub. Noted by Kai-Uwe Eckhardt in
PR 48667.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/historical/nawk/bin/awk.1
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 23 Mar 2014 01:31:47 +0000
State-Changed-Why:
fixed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.