Change random to use a binary input file for initializing.
authorChris Hanson <org/chris-hanson/cph>
Mon, 1 Oct 2018 06:24:50 +0000 (23:24 -0700)
committerChris Hanson <org/chris-hanson/cph>
Mon, 1 Oct 2018 06:24:50 +0000 (23:24 -0700)
src/runtime/random.scm

index db176d253d38c6af1c3a1871b4e71a94616bd583..9461bd1a81023d9e2a713f50585890fb51a6dc40 100644 (file)
@@ -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))