Fix luaL_requiref glb handling for Lua<=5.1

This commit is contained in:
Alex Orlenko 2022-05-30 21:45:25 +01:00
parent a05a58b258
commit a100ebb3d7
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
2 changed files with 5 additions and 3 deletions

View File

@ -568,11 +568,10 @@ pub unsafe fn luaL_requiref(
lua_getfield(L, -1, modname);
}
}
if cfg!(feature = "lua51") && glb != 0 {
if glb != 0 {
lua_pushvalue(L, -1);
lua_setglobal(L, modname);
}
if cfg!(feature = "luajit") && glb == 0 {
} else {
lua_pushnil(L);
lua_setglobal(L, modname);
}

View File

@ -513,6 +513,9 @@ pub unsafe fn luaL_requiref(
if glb != 0 {
lua_pushvalue(L, -1);
lua_setglobal(L, modname);
} else {
lua_pushnil(L);
lua_setglobal(L, modname);
}
lua_replace(L, -2);
}