diff options
| -rw-r--r-- | lbaselib.c | 8 |
1 files changed, 5 insertions, 3 deletions
| @@ -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 */ |
