From Lua 5.2: Add lua_copy().

Contributed by François Perrad.
This commit is contained in:
Mike Pall
2017-04-07 12:24:26 +02:00
parent c67a098292
commit ef23b70eb6
3 changed files with 21 additions and 11 deletions

View File

@@ -572,8 +572,7 @@ LUALIB_API int luaopen_package(lua_State *L)
lj_lib_pushcf(L, lj_cf_package_unloadlib, 1);
lua_setfield(L, -2, "__gc");
luaL_register(L, LUA_LOADLIBNAME, package_lib);
lua_pushvalue(L, -1);
lua_replace(L, LUA_ENVIRONINDEX);
lua_copy(L, -1, LUA_ENVIRONINDEX);
lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0);
for (i = 0; package_loaders[i] != NULL; i++) {
lj_lib_pushcf(L, package_loaders[i], 1);