22 lines
901 B
Plaintext
22 lines
901 B
Plaintext
$OpenBSD: patch-src_lmathlib_c,v 1.1 2007/03/15 22:03:37 pedro Exp $
|
|
--- src/lmathlib.c.orig Sun Mar 4 11:10:17 2007
|
|
+++ src/lmathlib.c Sun Mar 4 11:11:40 2007
|
|
@@ -181,7 +181,7 @@ static int math_max (lua_State *L) {
|
|
static int math_random (lua_State *L) {
|
|
/* the `%' avoids the (rare) case of r==1, and is needed also because on
|
|
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
|
|
- lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
|
|
+ lua_Number r = (lua_Number)(arc4random()%RAND_MAX) / (lua_Number)RAND_MAX;
|
|
switch (lua_gettop(L)) { /* check number of arguments */
|
|
case 0: { /* no arguments */
|
|
lua_pushnumber(L, r); /* Number between 0 and 1 */
|
|
@@ -207,7 +207,7 @@ static int math_random (lua_State *L) {
|
|
|
|
|
|
static int math_randomseed (lua_State *L) {
|
|
- srand(luaL_checkint(L, 1));
|
|
+ arc4random_stir();
|
|
return 0;
|
|
}
|
|
|