| 1170 | |
| 1171 | |
| 1172 | static int loadlib (lua_State *L) { |
| 1173 | static const luaL_Reg libs[] = { |
| 1174 | {LUA_GNAME, luaopen_base}, |
| 1175 | {"coroutine", luaopen_coroutine}, |
| 1176 | {"debug", luaopen_debug}, |
| 1177 | {"io", luaopen_io}, |
| 1178 | {"os", luaopen_os}, |
| 1179 | {"math", luaopen_math}, |
| 1180 | {"string", luaopen_string}, |
| 1181 | {"table", luaopen_table}, |
| 1182 | {"T", luaB_opentests}, |
| 1183 | {NULL, NULL} |
| 1184 | }; |
| 1185 | lua_State *L1 = getstate(L); |
| 1186 | int i; |
| 1187 | luaL_requiref(L1, "package", luaopen_package, 0); |
| 1188 | lua_assert(lua_type(L1, -1) == LUA_TTABLE); |
| 1189 | /* 'requiref' should not reload module already loaded... */ |
| 1190 | luaL_requiref(L1, "package", NULL, 1); /* seg. fault if it reloads */ |
| 1191 | /* ...but should return the same module */ |
| 1192 | lua_assert(lua_compare(L1, -1, -2, LUA_OPEQ)); |
| 1193 | luaL_getsubtable(L1, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); |
| 1194 | for (i = 0; libs[i].name; i++) { |
| 1195 | lua_pushcfunction(L1, libs[i].func); |
| 1196 | lua_setfield(L1, -2, libs[i].name); |
| 1197 | } |
| 1198 | return 0; |
| 1199 | } |
| 1200 | |
| 1201 | static int closestate (lua_State *L) { |
| 1202 | lua_State *L1 = getstate(L); |
nothing calls this directly
no test coverage detected