@@ -215,7 +215,11 @@ static void luaV_call_lua_func_free(void *state);
215215# define luaopen_os dll_luaopen_os
216216# define luaopen_package dll_luaopen_package
217217# define luaopen_debug dll_luaopen_debug
218- # define luaL_openlibs dll_luaL_openlibs
218+ # if LUA_VERSION_NUM >= 505
219+ # define luaL_openselectedlibs dll_luaL_openselectedlibs
220+ # else
221+ # define luaL_openlibs dll_luaL_openlibs
222+ # endif
219223
220224// lauxlib
221225# if LUA_VERSION_NUM <= 501
@@ -331,7 +335,11 @@ int (*dll_luaopen_io) (lua_State *L);
331335int (* dll_luaopen_os ) (lua_State * L );
332336int (* dll_luaopen_package ) (lua_State * L );
333337int (* dll_luaopen_debug ) (lua_State * L );
338+ # if LUA_VERSION_NUM >= 505
339+ void (* dll_luaL_openselectedlibs ) (lua_State * L , int load , int preload );
340+ # else
334341void (* dll_luaL_openlibs ) (lua_State * L );
342+ # endif
335343
336344typedef void * * luaV_function ;
337345typedef struct {
@@ -439,7 +447,11 @@ static const luaV_Reg luaV_dll[] = {
439447 {"luaopen_os" , (luaV_function ) & dll_luaopen_os },
440448 {"luaopen_package" , (luaV_function ) & dll_luaopen_package },
441449 {"luaopen_debug" , (luaV_function ) & dll_luaopen_debug },
450+ # if LUA_VERSION_NUM >= 505
451+ {"luaL_openselectedlibs" , (luaV_function ) & dll_luaL_openselectedlibs },
452+ # else
442453 {"luaL_openlibs" , (luaV_function ) & dll_luaL_openlibs },
454+ # endif
443455 {NULL , NULL }
444456};
445457
@@ -2571,7 +2583,11 @@ luaopen_vim(lua_State *L)
25712583luaV_newstate (void )
25722584{
25732585 lua_State * L = luaL_newstate ();
2586+ # if LUA_VERSION_NUM >= 505
2587+ luaL_openselectedlibs (L , ~0 , 0 ); // core libs
2588+ # else
25742589 luaL_openlibs (L ); // core libs
2590+ # endif
25752591 lua_pushcfunction (L , luaopen_vim ); // vim
25762592 lua_call (L , 0 , 0 );
25772593 return L ;
0 commit comments