From: Chris Hanson Date: Mon, 1 Oct 2018 06:24:50 +0000 (-0700) Subject: Change random to use a binary input file for initializing. X-Git-Tag: mit-scheme-pucked-9.2.19~2^2~24 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=c80e3b44e0906e878c5bf7275e49b3a654776590;p=mit-scheme.git Change random to use a binary input file for initializing. --- diff --git a/src/runtime/random.scm b/src/runtime/random.scm index db176d253..9461bd1a8 100644 --- a/src/runtime/random.scm +++ b/src/runtime/random.scm @@ -206,18 +206,18 @@ USA. (if (or (eq? #t state) (int:integer? state)) ;; Use good random source if available (if (file-readable? "/dev/urandom") - (call-with-input-file "/dev/urandom" + (call-with-binary-input-file "/dev/urandom" (lambda (port) (initial-random-state (lambda (b) (let outer () (let inner ((m #x100) - (n (char->integer (read-char port)))) + (n (read-u8 port))) (cond ((< m b) (inner (* m #x100) (+ (* n #x100) - (char->integer (read-char port))))) + (read-u8 port)))) ((< n b) n) (else (outer))))))))) (simple-random-state))