| 161 |
|
{ |
| 162 |
|
n = tree_br[n].cntr_siz; |
| 163 |
|
|
| 164 |
< |
while (n-- > 0) /* LSB first */ |
| 165 |
< |
if (++(*ctrp++)) |
| 166 |
< |
break; |
| 164 |
> |
while (! ++(*ctrp++)) /* LSB first */ |
| 165 |
> |
if (--n <= 0) { |
| 166 |
> |
fputs("Shuffle occupancy overflow!\n", stderr); |
| 167 |
> |
exit(1); /* means we sized something wrong */ |
| 168 |
> |
} |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
|
| 215 |
|
tree_root = tree_alloc(alen); |
| 216 |
|
|
| 217 |
|
while (alen > 0) /* allocate and print random array entries */ |
| 218 |
< |
print_shuf(n, eat_nth_leaf(tree_root, random() % alen--)); |
| 218 |
> |
print_shuf(n, eat_nth_leaf(tree_root, irandom(alen--))); |
| 219 |
|
|
| 220 |
|
free(tree_root); /* all done */ |
| 221 |
|
} |
| 253 |
|
myshuf[i] = i; |
| 254 |
|
/* perform Fisher-Yates shuffle */ |
| 255 |
|
for (i = 0; i < alen-1; i++) { |
| 256 |
< |
int ix = random()%(alen-i) + i; |
| 256 |
> |
int ix = irandom(alen-i) + i; |
| 257 |
|
int ndx = myshuf[i]; |
| 258 |
|
myshuf[i] = myshuf[ix]; |
| 259 |
|
myshuf[ix] = ndx; |
| 287 |
|
n[a] = 0; |
| 288 |
|
if (!a) |
| 289 |
|
goto userr; |
| 290 |
< |
|
| 290 |
> |
#ifdef getc_unlocked |
| 291 |
> |
flockfile(stdout); /* avoid overhead */ |
| 292 |
> |
#endif |
| 293 |
|
if (doshuffle) |
| 294 |
|
shuffle(n); |
| 295 |
|
else |