| 760 | |
| 761 | |
| 762 | LUAMOD_API int luaopen_package (lua_State *L) { |
| 763 | createclibstable(L); |
| 764 | luaL_newlib(L, pk_funcs); /* create 'package' table */ |
| 765 | createsearcherstable(L); |
| 766 | /* set field 'path' */ |
| 767 | setpath(L, "path", LUA_PATHVARVERSION, LUA_PATH_VAR, LUA_PATH_DEFAULT); |
| 768 | /* set field 'cpath' */ |
| 769 | setpath(L, "cpath", LUA_CPATHVARVERSION, LUA_CPATH_VAR, LUA_CPATH_DEFAULT); |
| 770 | /* store config information */ |
| 771 | lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" |
| 772 | LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); |
| 773 | lua_setfield(L, -2, "config"); |
| 774 | /* set field 'loaded' */ |
| 775 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); |
| 776 | lua_setfield(L, -2, "loaded"); |
| 777 | /* set field 'preload' */ |
| 778 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); |
| 779 | lua_setfield(L, -2, "preload"); |
| 780 | lua_pushglobaltable(L); |
| 781 | lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ |
| 782 | luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ |
| 783 | lua_pop(L, 1); /* pop global table */ |
| 784 | return 1; /* return 'package' table */ |
| 785 | } |
| 786 |
nothing calls this directly
no test coverage detected