lua: Allow regular int to be passed as a 64 bit integer.

This commit is contained in:
Richard W.M. Jones
2012-11-20 13:39:38 +00:00
parent 3454cfb73c
commit 74105fdab1

View File

@@ -645,10 +645,19 @@ get_int64 (lua_State *L, int index)
int64_t r;
const char *s;
s = luaL_checkstring (L, index);
if (sscanf (s, \"%%\" SCNi64, &r) != 1)
return luaL_error (L, \"int64 parameter expected\");
return r;
switch (lua_type (L, index)) {
case LUA_TSTRING:
s = luaL_checkstring (L, index);
if (sscanf (s, \"%%\" SCNi64, &r) != 1)
return luaL_error (L, \"int64 parameter expected\");
return r;
case LUA_TNUMBER:
return luaL_checkint (L, index);
default:
return luaL_error (L, \"expecting 64 bit integer\");
}
}
static void