[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible bug in getfunc() in lbaselib.c (5.1.1)?
- From: Rici Lake <lua@...>
- Date: Fri, 9 Feb 2007 11:11:08 -0500
On 9-Feb-07, at 11:07 AM, Doug Rogers wrote:
Eric Raible wrote:
Seems to me that a simpler (and more correct) patch would be to
change lbaselib.c:121
from:
int level = luaL_optint(L, 1, 1);
to:
int level = luaL_checkint(L, 1);
That was my first thought, but then the error message is misleading
(that it expected a number).
Doug
Yeah, I'd normally write something like:
switch (lua_type(L, 1)) {
case LUA_TFUNCTION: {
// handle the function case
}
case LUA_TNUMBER: {
int level = lua_tointeger(L, 1);
// ...
}
default: luaL_typerror(L, 1, "number or function");
}