Bug#63843: marked as forwarded (mawk: random numbers are not always the

from
[Debian Bug Tracking System]

Subject:

Bug#63843: marked as forwarded mawk: random numbers are not always the same (as in C)

From:

Debian Bug Tracking System

Date:

Mon, 01 Mar 2010 20:30:05 +0000

Your message dated Mon, 1 Mar 2010 14:28:46 -0600
with message-id <[email protected]>
has caused the report #63843,
regarding mawk: random numbers are not always the same (as in C)
to be marked as having been forwarded to the upstream software
author(s)
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
63843: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=63843
Debian Bug Tracking System
Contact [email protected] with problems

--- Begin Message ---

Subject:

Re: mawk: random numbers are not always the same as in C

From:

Jonathan Nieder

Date:

Mon, 1 Mar 2010 14:28:46 -0600

tags 63843 + upstream
tags 63843 - patch
severity 63843 normal
thanks
Santiago Vila wrote:
> Today I was surprised to discover that mawk's rand() function
> does not always generate the same random numbers on every run.
>
> mawk(1) explains why: "mawk seeds the random number generator from
> the clock at startup so there is no real need to call srand().
> Srand(expr) is useful for repeating pseudo random sequences."
>
> However, this behaviour is counter-intuitive from the point of view
> of a C programmer, and in fact the other two awk implementations
> in Debian do not need an explicit srand() for the random numbers to be
> the same on every run.
Yes, this violates POSIX (though I wish it didnât, since itâs usually
the most convenient behavior). In fact, the default random sequence
is required to be the same as that produced after srand(1).
The patch at http://bugs.debian.org/63843 is of course unsuitable, but
maybe something similar would work.
Cheers,
Jonathan