aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-02-13 14:07:37 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-02-13 14:07:37 -0200
commit2866fb2dd0412b8ff1b605722c547f2548716ad3 (patch)
tree5f3fa95d0cf8edf6f8c6dbb3b7670837b6a72698
parent4b6f436d67bd19adcea57f7a2db651b22310bf57 (diff)
downloadlua-2866fb2dd0412b8ff1b605722c547f2548716ad3.tar.gz
lua-2866fb2dd0412b8ff1b605722c547f2548716ad3.tar.bz2
lua-2866fb2dd0412b8ff1b605722c547f2548716ad3.zip
reset _REQUIREDNAME after loading module
-rw-r--r--lbaselib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index bbb5cb88..80f4db44 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.117 2003/02/10 10:21:31 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.118 2003/02/12 09:11:01 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -449,8 +449,6 @@ static int luaB_require (lua_State *L) {
449 int status = LUA_ERRFILE; /* not found (yet) */ 449 int status = LUA_ERRFILE; /* not found (yet) */
450 luaL_checkstring(L, 1); 450 luaL_checkstring(L, 1);
451 lua_settop(L, 1); 451 lua_settop(L, 1);
452 lua_pushvalue(L, 1);
453 lua_setglobal(L, "_REQUIREDNAME");
454 lua_getglobal(L, REQTAB); 452 lua_getglobal(L, REQTAB);
455 if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table"); 453 if (!lua_istable(L, 2)) return luaL_error(L, "`" REQTAB "' is not a table");
456 path = getpath(L); 454 path = getpath(L);
@@ -468,7 +466,11 @@ static int luaB_require (lua_State *L) {
468 } 466 }
469 switch (status) { 467 switch (status) {
470 case 0: { 468 case 0: {
469 lua_pushvalue(L, 1);
470 lua_setglobal(L, "_REQUIREDNAME");
471 lua_call(L, 0, 0); /* run loaded module */ 471 lua_call(L, 0, 0); /* run loaded module */
472 lua_pushnil(L);
473 lua_setglobal(L, "_REQUIREDNAME"); /* reset */
472 lua_pushvalue(L, 1); 474 lua_pushvalue(L, 1);
473 lua_pushboolean(L, 1); 475 lua_pushboolean(L, 1);
474 lua_rawset(L, 2); /* mark it as loaded */ 476 lua_rawset(L, 2); /* mark it as loaded */