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