Date: Fri, 20 May 2005 19:40:06 GMT From: Vivek Khera <vivek@khera.org> To: freebsd-amd64@FreeBSD.org Subject: Re: amd64/81279: /usr/games/random returns every line Message-ID: <200505201940.j4KJe6LD096212@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR amd64/81279; it has been noted by GNATS. From: Vivek Khera <vivek@khera.org> To: bug-followup@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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505201940.j4KJe6LD096212>