]>
Commit | Line | Data |
---|---|---|
dade3e15 AM |
1 | diff -up expect-5.44.1.15/example/mkpasswd.orig expect-5.44.1.15/example/mkpasswd |
2 | --- expect-5.44.1.15/example/mkpasswd.orig 2010-03-08 16:01:05.518378075 +0100 | |
3 | +++ expect-5.44.1.15/example/mkpasswd 2010-03-08 16:01:27.408388162 +0100 | |
4 | @@ -92,7 +92,14 @@ proc insert {pvar char} { | |
5 | } | |
6 | ||
7 | proc rand {m} { | |
8 | - expr {int($m*rand())} | |
9 | + set device /dev/urandom ;# /dev/random can block | |
10 | + set fileId [open $device r] | |
11 | + binary scan [read $fileId 4] i1 number | |
12 | + set clipped [expr $number % $m] | |
13 | +# puts "number is $number" | |
14 | +# puts "clipped is $clipped" | |
15 | + close $fileId | |
16 | + return $clipped | |
17 | } | |
18 | ||
19 | # choose left or right starting hand |