From c80e3b44e0906e878c5bf7275e49b3a654776590 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 30 Sep 2018 23:24:50 -0700 Subject: [PATCH] Change random to use a binary input file for initializing. --- src/runtime/random.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)) -- 2.25.1