Lines 165-171
Link Here
|
165 |
* 0 (which has a 1 / denom chance of being true), we select the |
165 |
* 0 (which has a 1 / denom chance of being true), we select the |
166 |
* line. |
166 |
* line. |
167 |
*/ |
167 |
*/ |
168 |
selected = (arc4random_uniform(denom) == 0); |
168 |
selected = ((int)(denom * arc4random_uniform(UINT32_MAX) / (UINT32_MAX-1)) == 0); |
169 |
while ((ch = getchar()) != EOF) { |
169 |
while ((ch = getchar()) != EOF) { |
170 |
if (selected) |
170 |
if (selected) |
171 |
(void)putchar(ch); |
171 |
(void)putchar(ch); |
Lines 175-181
Link Here
|
175 |
err(2, "stdout"); |
175 |
err(2, "stdout"); |
176 |
|
176 |
|
177 |
/* Now see if the next line is to be printed. */ |
177 |
/* Now see if the next line is to be printed. */ |
178 |
selected = (arc4random_uniform(denom) == 0); |
178 |
selected = ((int)(denom * arc4random_uniform(UINT32_MAX) / (UINT32_MAX-1)) == 0); |
179 |
} |
179 |
} |
180 |
} |
180 |
} |
181 |
if (ferror(stdin)) |
181 |
if (ferror(stdin)) |