Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > be2c43ee7ff197283cdfffaf0ef62823 > files > 9

expect-5.43.0-22.mga3.src.rpm

diff -up expect-5.43/example/mkpasswd.random expect-5.43/example/mkpasswd
--- expect-5.43/example/mkpasswd.random	2004-12-07 00:38:21.000000000 +0100
+++ expect-5.43/example/mkpasswd	2008-09-25 12:27:19.000000000 +0200
@@ -92,7 +92,14 @@ proc insert {pvar char} {
 }
 
 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