diff options
| author | Lua Team <team@lua.org> | 2007-03-23 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 2007-03-23 12:00:00 +0000 |
| commit | 7e7bc7c7c7f3301a5f837579b81bcac4a2f9cccc (patch) | |
| tree | 1038a02147bfbda052210f2b53fa1801b63254eb /src/lbaselib.c | |
| parent | 72847ae02f73ea86c1a0d5778a9bc982cdccb821 (diff) | |
| download | lua-github-7e7bc7c7c7f3301a5f837579b81bcac4a2f9cccc.tar.gz | |
Lua 5.1.2-rc15.1.2-rc1
Diffstat (limited to 'src/lbaselib.c')
| -rw-r--r-- | src/lbaselib.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lbaselib.c b/src/lbaselib.c index 2df437b0..147a727e 100644 --- a/src/lbaselib.c +++ b/src/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.191 2006/06/02 15:34:00 roberto Exp $ +** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -114,11 +114,11 @@ static int luaB_setmetatable (lua_State *L) { } -static void getfunc (lua_State *L) { +static void getfunc (lua_State *L, int opt) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { lua_Debug ar; - int level = luaL_optint(L, 1, 1); + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); if (lua_getstack(L, level, &ar) == 0) luaL_argerror(L, 1, "invalid level"); @@ -131,7 +131,7 @@ static void getfunc (lua_State *L) { static int luaB_getfenv (lua_State *L) { - getfunc(L); + getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ else @@ -142,7 +142,7 @@ static int luaB_getfenv (lua_State *L) { static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L); + getfunc(L, 0); lua_pushvalue(L, 2); if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { /* change environment of current thread */ |
