diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-06-30 14:40:27 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-06-30 14:40:27 -0300 |
| commit | a139e2e003e0b62b7d34eeda20dd2354e74885f9 (patch) | |
| tree | 7893fbccec3852dbf35321d2612074c2259570ef /loadlib.c | |
| parent | a71c5f6f531a2503ff80e579e6c3bb95968645ba (diff) | |
| download | lua-a139e2e003e0b62b7d34eeda20dd2354e74885f9.tar.gz lua-a139e2e003e0b62b7d34eeda20dd2354e74885f9.tar.bz2 lua-a139e2e003e0b62b7d34eeda20dd2354e74885f9.zip | |
old (and complex) luaL_findtable now used only in compatibility code
inside lauxlib.c
Diffstat (limited to 'loadlib.c')
| -rw-r--r-- | loadlib.c | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: loadlib.c,v 1.84 2010/06/13 19:36:17 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.85 2010/06/18 17:23:02 roberto Exp roberto $ |
| 3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | ** | 5 | ** |
| @@ -423,7 +423,7 @@ static int loader_Croot (lua_State *L) { | |||
| 423 | 423 | ||
| 424 | static int loader_preload (lua_State *L) { | 424 | static int loader_preload (lua_State *L) { |
| 425 | const char *name = luaL_checkstring(L, 1); | 425 | const char *name = luaL_checkstring(L, 1); |
| 426 | lua_getfield(L, lua_upvalueindex(1), "preload"); | 426 | lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD"); |
| 427 | if (!lua_istable(L, -1)) | 427 | if (!lua_istable(L, -1)) |
| 428 | luaL_error(L, LUA_QL("package.preload") " must be a table"); | 428 | luaL_error(L, LUA_QL("package.preload") " must be a table"); |
| 429 | lua_getfield(L, -1, name); | 429 | lua_getfield(L, -1, name); |
| @@ -633,10 +633,10 @@ LUAMOD_API int luaopen_package (lua_State *L) { | |||
| 633 | LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); | 633 | LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); |
| 634 | lua_setfield(L, -2, "config"); | 634 | lua_setfield(L, -2, "config"); |
| 635 | /* set field `loaded' */ | 635 | /* set field `loaded' */ |
| 636 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); | 636 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED"); |
| 637 | lua_setfield(L, -2, "loaded"); | 637 | lua_setfield(L, -2, "loaded"); |
| 638 | /* set field `preload' */ | 638 | /* set field `preload' */ |
| 639 | lua_newtable(L); | 639 | luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); |
| 640 | lua_setfield(L, -2, "preload"); | 640 | lua_setfield(L, -2, "preload"); |
| 641 | lua_pushglobaltable(L); | 641 | lua_pushglobaltable(L); |
| 642 | lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ | 642 | lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ |
