From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 3 21:04:54 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 39FEFAEB; Wed, 3 Sep 2014 21:04:54 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 11C661547; Wed, 3 Sep 2014 21:04:54 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-70-85-31.nwrknj.fios.verizon.net [173.70.85.31]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 04AE7B964; Wed, 3 Sep 2014 17:04:53 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Subject: Re: On changing rand(3) to random(3) in awk(1) Date: Wed, 03 Sep 2014 16:50:35 -0400 Message-ID: <11596842.yV7kvIp5At@ralph.baldwin.cx> User-Agent: KMail/4.10.5 (FreeBSD/10.0-STABLE; KDE/4.10.5; amd64; ; ) In-Reply-To: <97E2800A-1AC1-4595-872B-E4576D4B5FFB@gmail.com> References: <54003C42.1070309@gmail.com> <97E2800A-1AC1-4595-872B-E4576D4B5FFB@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 03 Sep 2014 17:04:53 -0400 (EDT) Cc: Chenguang Li , delphij@freebsd.org, Vitaly Magerya X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2014 21:04:54 -0000 On Friday, August 29, 2014 04:55:57 PM Chenguang Li wrote: > Vitaly Magerya 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