]> gitweb.factorcode.org Git - factor.git/commitdiff
random.windows: Saw in the pastebin that some Windows installs still don't
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 27 Jul 2013 20:28:20 +0000 (13:28 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 27 Jul 2013 20:28:20 +0000 (13:28 -0700)
start with this code. Just set the system and secure RNGs to f, and
calling them will throw an error. The Mersenne Twister is still the
default anyway.

basis/random/windows/windows.factor

index 0bf08b78783eb1f7b0393f21f5c195c3002b3ccd..29f46dd51d04dcad6a4196177c535f9eb487ea3f 100755 (executable)
@@ -46,8 +46,12 @@ M: windows-crypto-context random-bytes* ( n windows-crypto-context -- bytes )
     handle>> swap [ ] [ <byte-array> ] bi
     [ CryptGenRandom win32-error=0/f ] keep ;
 
-: try-crypto-providers ( seq -- windows-crypto-context )
-    [ first2 <windows-crypto-context> ] attempt-all ;
+! Some Windows installations still don't work, so just set
+! system and secure rngs to f
+: try-crypto-providers ( seq -- windows-crypto-context/f )
+    [
+        [ first2 <windows-crypto-context> ] attempt-all
+    ] [ 2drop f ] recover ;
 
 [
     {