On changing rand(3) to random(3) in awk(1)

John Baldwin jhb at freebsd.org
Wed Sep 3 21:04:54 UTC 2014


On Friday, August 29, 2014 04:55:57 PM Chenguang Li wrote:
> Vitaly Magerya <vmagerya at gmail.com> wrote:
> > On 2014-08-29 10:12, Chenguang Li wrote:
> >> ... ...
> >> 
> >> Yes, I've noticed there's a fairness problem, 0 comes out more often.
> >> Since
> >> the original code is buggy too, do we need to be compatible with it?
> > 
> > I see no reason why we would.
> > 
> > Interestingly enough, GNU awk has this bug as well (and I am entirely
> > too lazy to report it).
> 
> Yes, I came across that line a few days ago. OSX's awk also has this bug,
> judging from their code[1]:
> 
>     u = (Awkfloat) (random() % RAND_MAX) / RAND_MAX;
> 
> >> Thanks for pointing that out, I've modified the gist as your suggestion.
> > 
> > Looks good to me. You might want to open a bug report with that patch,
> > as it's not clear if any committer is reading this thread.

Can you please open a bug report with the latest patch?

Xin Li (delphij@) imported the most recent awk version.  Ideally this patch 
would go upstream and not just be a local patch.  Perhaps Xin can help with 
that?

-- 
John Baldwin


More information about the freebsd-hackers mailing list