On Sat, 26 Mar 2016 13:50:47 +0100
Mattias Andrée <maandree_AT_kth.se> wrote:
Hey Mattias,
> +static int
> +random_byte_file(void)
> +{
> + unsigned char r;
> + ssize_t n = read(source, &r, 1);
> + if (n < 0)
> + eprintf("read %s:", sflag);
> + if (!n)
> + eprintf("read %s: end of file reached\n");
> + return r;
> +}
> +
> +static int
> +random_byte_libc(void)
> +{
> + double r;
> + r = rand();
> + r /= (double)RAND_MAX + 1;
> + r *= 256;
> + return (int)r;
> +}
is there a good reason for the existence of shuf(1)? Also, we may want
to think about using more solid interfaces for randomness
(like arc4random()) and remove the "file-source" altogether.
Cheers
Laslo
--
Laslo Hunhold <dev_AT_frign.de>
Received on Tue Dec 27 2016 - 11:32:32 CET