Take srand()/rand() out of the initialization chain...
authorEric S. Raymond <esr@thyrsus.com>
Wed, 24 May 2017 15:57:53 +0000 (11:57 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 24 May 2017 15:57:53 +0000 (11:57 -0400)
...they're not guatanteed to produce consistent across platforms or
libc versions.

misc.c

diff --git a/misc.c b/misc.c
index e025c78807f585d76a2db794d2c9cb79a970344e..495a339bfcb51563238604789aea72fec991efe2 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -761,8 +761,7 @@ long TSTBIT;
 
 void set_seed(long seedval)
 {
-       srand(seedval);
-       lcgstate.x = (unsigned long) rand() % lcgstate.m;
+       lcgstate.x = (unsigned long) seedval % lcgstate.m;
 }
 
 unsigned long get_next_lcg_value(void)