Module Name:    src
Committed By:   dholland
Date:           Mon Jul 20 06:43:18 UTC 2009

Modified Files:
        src/games/robots: main.c rnd_pos.c

Log Message:
Use random() instead of rand(), and seed with time instead of pid.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/games/robots/main.c
cvs rdiff -u -r1.8 -r1.9 src/games/robots/rnd_pos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/robots/main.c
diff -u src/games/robots/main.c:1.28 src/games/robots/main.c:1.29
--- src/games/robots/main.c:1.28	Mon Jul 20 06:39:06 2009
+++ src/games/robots/main.c	Mon Jul 20 06:43:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $	*/
+/*	$NetBSD: main.c,v 1.29 2009/07/20 06:43:18 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: main.c,v 1.28 2009/07/20 06:39:06 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.29 2009/07/20 06:43:18 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -50,6 +50,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <time.h>
 #include <unistd.h>
 #include "robots.h"
 
@@ -167,7 +168,7 @@
 		stdscr = newwin(Y_SIZE, X_SIZE, 0, 0);
 	}
 
-	srand(getpid());
+	srandom(time(NULL));
 	if (Real_time)
 		signal(SIGALRM, move_robots);
 	do {

Index: src/games/robots/rnd_pos.c
diff -u src/games/robots/rnd_pos.c:1.8 src/games/robots/rnd_pos.c:1.9
--- src/games/robots/rnd_pos.c:1.8	Mon Jul 20 06:39:06 2009
+++ src/games/robots/rnd_pos.c	Mon Jul 20 06:43:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rnd_pos.c,v 1.8 2009/07/20 06:39:06 dholland Exp $	*/
+/*	$NetBSD: rnd_pos.c,v 1.9 2009/07/20 06:43:18 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rnd_pos.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: rnd_pos.c,v 1.8 2009/07/20 06:39:06 dholland Exp $");
+__RCSID("$NetBSD: rnd_pos.c,v 1.9 2009/07/20 06:43:18 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,5 +67,5 @@
 rnd(int range)
 {
 
-	return rand() % range;
+	return random() % range;
 }

Reply via email to