diff options
author | dholland <dholland@NetBSD.org> | 2008-02-20 04:48:10 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2008-02-20 04:48:10 +0000 |
commit | 413a596f439ac842277d61847a166f6c8ea6f497 (patch) | |
tree | a9854443f3fb048cc97d37b27fcf2565d03a7cc5 /monop | |
parent | add44e03d1bf488b8342d844a181698d900b3ee1 (diff) | |
download | bsdgames-darwin-413a596f439ac842277d61847a166f6c8ea6f497.tar.gz bsdgames-darwin-413a596f439ac842277d61847a166f6c8ea6f497.tar.zst bsdgames-darwin-413a596f439ac842277d61847a166f6c8ea6f497.zip |
Use random() rather than rand(). Suggested by diffing against OpenBSD.
Diffstat (limited to 'monop')
-rw-r--r-- | monop/monop.c | 7 | ||||
-rw-r--r-- | monop/roll.c | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/monop/monop.c b/monop/monop.c index 08509622..4741b878 100644 --- a/monop/monop.c +++ b/monop/monop.c @@ -1,4 +1,4 @@ -/* $NetBSD: monop.c,v 1.17 2008/02/19 09:45:02 dholland Exp $ */ +/* $NetBSD: monop.c,v 1.18 2008/02/20 04:48:10 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,13 +39,14 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: monop.c,v 1.17 2008/02/19 09:45:02 dholland Exp $"); +__RCSID("$NetBSD: monop.c,v 1.18 2008/02/20 04:48:10 dholland Exp $"); #endif #endif /* not lint */ #include <stdio.h> #include <signal.h> #include <stdlib.h> +#include <time.h> #include <unistd.h> #include "monop.def" @@ -67,7 +68,7 @@ main(ac, av) /* Revoke setgid privileges */ setgid(getgid()); - srand(getpid()); + srandom(time(NULL)); heapstart = sbrk(0); if (ac > 1) { if (!rest_f(av[1])) diff --git a/monop/roll.c b/monop/roll.c index 07395fa9..b3e5a9d7 100644 --- a/monop/roll.c +++ b/monop/roll.c @@ -1,4 +1,4 @@ -/* $NetBSD: roll.c,v 1.9 2003/08/07 09:37:29 agc Exp $ */ +/* $NetBSD: roll.c,v 1.10 2008/02/20 04:48:10 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: roll.c,v 1.9 2003/08/07 09:37:29 agc Exp $"); +__RCSID("$NetBSD: roll.c,v 1.10 2008/02/20 04:48:10 dholland Exp $"); #endif #endif /* not lint */ @@ -74,7 +74,7 @@ roll(ndie, nsides) num_sides = nsides; tot = 0; while (ndie--) - tot += (r = rand()) * (num_sides / RAND_MAX) + 1; + tot += (r = random()) * (num_sides / RAND_MAX) + 1; return tot; } #endif |