amd64/81279: /usr/games/random returns every line
Vivek Khera
vivek at khera.org
Fri May 20 12:40:06 PDT 2005
The following reply was made to PR amd64/81279; it has been noted by GNATS.
From: Vivek Khera <vivek at khera.org>
To: bug-followup at FreeBSD.org
Cc:
Subject: Re: amd64/81279: /usr/games/random returns every line
Date: Fri, 20 May 2005 15:36:55 -0400
--Apple-Mail-6-871661888
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
Here's a patch for /usr/src/games/random/random.c which seems to
solve the problem, based on Adriaan's message.
--Apple-Mail-6-871661888
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="random.c.patch"
Content-Disposition: attachment;
filename=random.c.patch
--- #random.c~ Fri May 20 15:26:50 2005
+++ random.c Fri May 20 15:26:50 2005
@@ -159,7 +159,7 @@
/* Compute a random exit status between 0 and denom - 1. */
if (random_exit)
- return (int)((denom * random()) / LONG_MAX);
+ return (int)((denom * random()) / INT_MAX);
/*
* Select whether to print the first line. (Prime the pump.)
@@ -167,7 +167,7 @@
* 0 (which has a 1 / denom chance of being true), we select the
* line.
*/
- selected = (int)(denom * random() / LONG_MAX) == 0;
+ selected = (int)(denom * random() / INT_MAX) == 0;
while ((ch = getchar()) != EOF) {
if (selected)
(void)putchar(ch);
@@ -177,7 +177,7 @@
err(2, "stdout");
/* Now see if the next line is to be printed. */
- selected = (int)(denom * random() / LONG_MAX) == 0;
+ selected = (int)(denom * random() / INT_MAX) == 0;
}
}
if (ferror(stdin))
--Apple-Mail-6-871661888--
More information about the freebsd-amd64
mailing list