Skip to content

Commit 60a4187

Browse files
committed
Fix Lua 5.5 dynamic build
Cherry-picked from vim/vim#19909
1 parent 6b9133e commit 60a4187

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/if_lua.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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);
331335
int (*dll_luaopen_os) (lua_State *L);
332336
int (*dll_luaopen_package) (lua_State *L);
333337
int (*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
334341
void (*dll_luaL_openlibs) (lua_State *L);
342+
# endif
335343

336344
typedef void **luaV_function;
337345
typedef 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

@@ -2570,7 +2582,11 @@ luaopen_vim(lua_State *L)
25702582
luaV_newstate(void)
25712583
{
25722584
lua_State *L = luaL_newstate();
2585+
# if LUA_VERSION_NUM >= 505
2586+
luaL_openselectedlibs(L, ~0, 0); // core libs
2587+
# else
25732588
luaL_openlibs(L); // core libs
2589+
# endif
25742590
lua_pushcfunction(L, luaopen_vim); // vim
25752591
lua_call(L, 0, 0);
25762592
return L;

0 commit comments

Comments
 (0)