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