Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: RANDOMSMALL <range> [ <seed> ]
- X-seq: zsh-workers 20029
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: Re: RANDOMSMALL <range> [ <seed> ]
- Date: Tue, 08 Jun 2004 22:51:45 +0100
- In-reply-to: "Peter Stephenson"'s message of "Tue, 08 Jun 2004 22:20:09 BST." <20040608212010.5B3F68652@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk
Messages sorted by:
Reverse Date,
Date,
Thread,
Author