LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File expect-5.32.2-random.patch of Package expect (Project home:non7top:epel5)

--- expect5.32/example/mkpasswd.random	Mon Jul 23 10:42:04 2001
+++ expect5.32/example/mkpasswd	Mon Jul 23 11:50:56 2001
@@ -92,7 +92,14 @@
 }
 
 proc rand {m} {
-    expr {int($m*rand())}
+    set device /dev/urandom		;# /dev/random can block
+    set fileId [open $device r]
+    binary scan [read $fileId 4] i1 number
+    set clipped [expr $number % $m]
+#    puts "number is $number"
+#    puts "clipped is $clipped"
+    close $fileId
+    return $clipped
 }
 
 # choose left or right starting hand