Discussion:
standards/44876: awk: incorrect return value of function srand()
(too old to reply)
c***@tut.by
2011-04-18 12:40:11 UTC
Permalink
Number: 44876
Category: standards
Synopsis: awk: incorrect return value of function srand()
Confidential: no
Severity: non-critical
Priority: low
Responsible: standards-manager
State: open
Class: sw-bug
Submitter-Id: net
Arrival-Date: Mon Apr 18 12:40:00 +0000 2011
Originator: Aleksey Cheusov
Release: Linux 2.6.18-194.32.1.el5xen
<organization of PR author (multiple lines)>
According to POSIX/SUS
(http://pubs.opengroup.org/onlinepubs/009695399/utilities/awk.html)

srand([expr])
Set the seed value for rand to expr or use the time of day if expr
is omitted. The previous seed value shall be returned.

awk from NetBSD returns new seed, gawk and mawk work correctly.

0 cheusov>awk 'BEGIN {print srand(1), srand(2), srand(3)}'
1 2 3
0 cheusov>mawk 'BEGIN {print srand(1), srand(2), srand(3)}'
1303130273 1 2
0 cheusov>gawk 'BEGIN {print srand(1), srand(2), srand(3)}'
1 1 2
0 cheusov>
Unknown
Christos Zoulas
2011-04-18 15:25:11 UTC
Permalink
The following reply was made to PR standards/44876; it has been noted by GNATS.

From: "Christos Zoulas" <***@netbsd.org>
To: gnats-***@gnats.NetBSD.org
Cc:
Subject: PR/44876 CVS commit: src/external/historical/nawk/dist
Date: Mon, 18 Apr 2011 11:23:29 -0400

Module Name: src
Committed By: christos
Date: Mon Apr 18 15:23:28 UTC 2011

Modified Files:
src/external/historical/nawk/dist: main.c run.c

Log Message:
PR/44876: Aleksey Cheusov: awk: incorrect return value of function srand()
Make it return the value of the previous random seed as the standard mandates.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/historical/nawk/dist/main.c
cvs rdiff -u -r1.2 -r1.3 src/external/historical/nawk/dist/run.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Aleksey Cheusov
2011-04-18 19:25:15 UTC
Permalink
The following reply was made to PR standards/44876; it has been noted by GNATS.

From: Aleksey Cheusov <***@tut.by>
To: gnats-***@NetBSD.org
Cc:
Subject: Re: PR/44876 CVS commit: src/external/historical/nawk/dist
Date: Mon, 18 Apr 2011 22:21:02 +0300
Post by Christos Zoulas
cvs rdiff -u -r1.4 -r1.5 src/external/historical/nawk/dist/main.c
cvs rdiff -u -r1.2 -r1.3 src/external/historical/nawk/dist/run.c
It looks good. Thanks!

--
Best regards, Aleksey Cheusov.
c***@NetBSD.org
2011-04-18 20:56:39 UTC
Permalink
Synopsis: awk: incorrect return value of function srand()

State-Changed-From-To: open->closed
State-Changed-By: ***@NetBSD.org
State-Changed-When: Mon, 18 Apr 2011 16:56:33 -0400
State-Changed-Why:
submitter verified it has been fixed.

Loading...