Module Name:    src
Committed By:   dholland
Date:           Mon Jul 20 05:33:35 UTC 2009

Modified Files:
        src/games/random: random.c

Log Message:
ANSIfy. Also, we now have RANDOM_MAX; use it. Object diffs checked...


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/games/random/random.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/random/random.c
diff -u src/games/random/random.c:1.12 src/games/random/random.c:1.13
--- src/games/random/random.c:1.12	Sun Jul 20 01:03:22 2008
+++ src/games/random/random.c	Mon Jul 20 05:33:35 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.c,v 1.12 2008/07/20 01:03:22 lukem Exp $	*/
+/*	$NetBSD: random.c,v 1.13 2009/07/20 05:33:35 dholland Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)random.c	8.6 (Berkeley) 6/1/94";
 #else
-__RCSID("$NetBSD: random.c,v 1.12 2008/07/20 01:03:22 lukem Exp $");
+__RCSID("$NetBSD: random.c,v 1.13 2009/07/20 05:33:35 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -57,15 +57,10 @@
 #include <unistd.h>
 #include <limits.h>
 
-#define MAXRANDOM	2147483647
-
-int  main(int, char **);
 void usage(void) __dead;
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
 	struct timeval tp;
 	double denom;
@@ -113,7 +108,7 @@
 
 	/* Compute a random exit status between 0 and denom - 1. */
 	if (random_exit)
-		return ((denom * random()) / MAXRANDOM);
+		return ((denom * random()) / RANDOM_MAX);
 
 	/*
 	 * Act as a filter, randomly choosing lines of the standard input
@@ -128,7 +123,7 @@
 	 * 0 (which has a 1 / denom chance of being true), we select the
 	 * line.
 	 */
-	selected = (int)(denom * random() / MAXRANDOM) == 0;
+	selected = (int)(denom * random() / RANDOM_MAX) == 0;
 	while ((ch = getchar()) != EOF) {
 		if (selected)
 			(void)putchar(ch);
@@ -138,7 +133,7 @@
 				err(2, "stdout");
 
 			/* Now see if the next line is to be printed. */
-			selected = (int)(denom * random() / MAXRANDOM) == 0;
+			selected = (int)(denom * random() / RANDOM_MAX) == 0;
 		}
 	}
 	if (ferror(stdin))
@@ -149,7 +144,7 @@
 }
 
 void
-usage()
+usage(void)
 {
 
 	(void)fprintf(stderr, "usage: random [-er] [denominator]\n");

Reply via email to