mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-22 11:17:19 +00:00
Convert to random() and automatically fix bug with RAND_MAX is too large
This commit is contained in:
parent
d3c80dc8d2
commit
dd126e1572
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29832
@ -50,7 +50,7 @@ getword()
|
||||
|
||||
inf = Dict;
|
||||
for (;;) {
|
||||
pos = (double)rand() / (RAND_MAX + 1.0) * (double)Dict_size;
|
||||
pos = (double)random() / (RAND_MAX + 1.0) * (double)Dict_size;
|
||||
fseek(inf, pos, 0);
|
||||
if (fgets(Word, BUFSIZ, inf) == NULL)
|
||||
continue;
|
||||
|
@ -35,6 +35,7 @@
|
||||
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
|
||||
# include <stdlib.h>
|
||||
# include "hangman.h"
|
||||
|
||||
/*
|
||||
@ -61,7 +62,7 @@ setup()
|
||||
addstr(*sp);
|
||||
}
|
||||
|
||||
srand(time(NULL) + getpid());
|
||||
srandomdev();
|
||||
if ((Dict = fopen(_PATH_DICT, "r")) == NULL) {
|
||||
perror(_PATH_DICT);
|
||||
endwin();
|
||||
|
Loading…
Reference in New Issue
Block a user