lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 2866fb2dd0412b8ff1b605722c547f2548716ad3
parent 4b6f436d67bd19adcea57f7a2db651b22310bf57
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Thu, 13 Feb 2003 14:07:15 -0200

reset _REQUIREDNAME after loading module

Diffstat:
Mlbaselib.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lbaselib.c b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.117 2003/02/10 10:21:31 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.118 2003/02/12 09:11:01 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -449,8 +449,6 @@ static int luaB_require (lua_State *L) { int status = LUA_ERRFILE; /* not found (yet) */ luaL_checkstring(L, 1); lua_settop(L, 1); - lua_pushvalue(L, 1); - lua_setglobal(L, "_REQUIREDNAME"); lua_getglobal(L, REQTAB); if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table"); path = getpath(L); @@ -468,7 +466,11 @@ static int luaB_require (lua_State *L) { } switch (status) { case 0: { + lua_pushvalue(L, 1); + lua_setglobal(L, "_REQUIREDNAME"); lua_call(L, 0, 0); /* run loaded module */ + lua_pushnil(L); + lua_setglobal(L, "_REQUIREDNAME"); /* reset */ lua_pushvalue(L, 1); lua_pushboolean(L, 1); lua_rawset(L, 2); /* mark it as loaded */