| 3194 | } |
| 3195 | |
| 3196 | COMPAT53_API void luaL_requiref(lua_State *L, const char *modname, |
| 3197 | lua_CFunction openf, int glb) { |
| 3198 | luaL_checkstack(L, 3, "not enough stack slots available"); |
| 3199 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); |
| 3200 | if (lua_getfield(L, -1, modname) == LUA_TNIL) { |
| 3201 | lua_pop(L, 1); |
| 3202 | lua_pushcfunction(L, openf); |
| 3203 | lua_pushstring(L, modname); |
| 3204 | lua_call(L, 1, 1); |
| 3205 | lua_pushvalue(L, -1); |
| 3206 | lua_setfield(L, -3, modname); |
| 3207 | } |
| 3208 | if (glb) { |
| 3209 | lua_pushvalue(L, -1); |
| 3210 | lua_setglobal(L, modname); |
| 3211 | } |
| 3212 | lua_replace(L, -2); |
| 3213 | } |
| 3214 | |
| 3215 | #endif /* Lua 5.1 and 5.2 */ |
| 3216 |
no test coverage detected