New function 'luaL_openselectedlibs'

Makes it easier to start Lua with only some standard libraries.
This commit is contained in:
Roberto Ierusalimschy
2022-12-07 15:12:52 -03:00
parent 0270c204c2
commit d738c8d18b
7 changed files with 85 additions and 83 deletions

6
lua.c
View File

@@ -609,6 +609,10 @@ static void doREPL (lua_State *L) {
/* }================================================================== */
#if !defined(luai_openlibs)
#define luai_openlibs(L) luaL_openlibs(L)
#endif
/*
** Main body of stand-alone interpreter (to be called in protected mode).
@@ -631,7 +635,7 @@ static int pmain (lua_State *L) {
lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
luaL_openlibs(L); /* open standard libraries */
luai_openlibs(L); /* open standard libraries */
createargtable(L, argv, argc, script); /* create table 'arg' */
lua_gc(L, LUA_GCRESTART); /* start GC... */
lua_gc(L, LUA_GCGEN, 0, 0); /* ...in generational mode */