| 3719 | } |
| 3720 | |
| 3721 | COMPAT53_API void luaL_requiref(lua_State* L, const char* modname, lua_CFunction openf, int glb) { |
| 3722 | luaL_checkstack(L, 3, "not enough stack slots available"); |
| 3723 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); |
| 3724 | if (lua_getfield(L, -1, modname) == LUA_TNIL) { |
| 3725 | lua_pop(L, 1); |
| 3726 | lua_pushcfunction(L, openf); |
| 3727 | lua_pushstring(L, modname); |
| 3728 | lua_call(L, 1, 1); |
| 3729 | lua_pushvalue(L, -1); |
| 3730 | lua_setfield(L, -3, modname); |
| 3731 | } |
| 3732 | if (glb) { |
| 3733 | lua_pushvalue(L, -1); |
| 3734 | lua_setglobal(L, modname); |
| 3735 | } |
| 3736 | lua_replace(L, -2); |
| 3737 | } |
| 3738 | |
| 3739 | #endif /* Lua 5.1 and 5.2 */ |
| 3740 |
no test coverage detected