From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: Re: RANDOMSMALL <range> [ <seed> ]
Date: Tue, 08 Jun 2004 22:51:45 +0100 [thread overview]
Message-ID: <20040608215146.BF35E8652@pwstephenson.fsnet.co.uk> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Tue, 08 Jun 2004 22:20:09 BST." <20040608212010.5B3F68652@pwstephenson.fsnet.co.uk>
Peter Stephenson wrote:
> Look at the math function rand48 in the zsh/mathfunc package.
Ooops, this turns out to be badly broken when used with a seed
parameter. After the second time you always get the same number.
Not actually all that random.
Index: Src/Modules/mathfunc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/mathfunc.c,v
retrieving revision 1.4
diff -u -r1.4 mathfunc.c
--- Src/Modules/mathfunc.c 2 Jun 2004 22:15:00 -0000 1.4
+++ Src/Modules/mathfunc.c 8 Jun 2004 21:42:14 -0000
@@ -500,7 +500,7 @@
* to each unsigned short.
*/
for (i = 0; i < 3 && !do_init; i++) {
- unsigned short *seedptr = seedbuf + i;
+ unsigned short *seedptr = seedbufptr + i;
*seedptr = 0;
for (j = 0; j < 4; j++) {
if (*seedstr >= '0' && *seedstr <= '9')
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
next prev parent reply other threads:[~2004-06-08 21:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-01 18:01 zsh malloc bug Dave Yost
2004-06-02 9:32 ` Peter Stephenson
2004-06-02 18:21 ` Dave Yost
2004-06-08 13:20 ` Peter Stephenson
2004-06-08 18:09 ` RANDOMSMALL <range> [ <seed> ] Dave Yost
2004-06-08 21:20 ` Peter Stephenson
2004-06-08 21:51 ` Peter Stephenson [this message]
2004-06-08 21:55 ` Larry Bakst
2004-06-16 19:13 ` zsh malloc bug Dave Yost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040608215146.BF35E8652@pwstephenson.fsnet.co.uk \
--to=pws@pwstephenson.fsnet.co.uk \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).