Skip to content

Commit 22db4a3

Browse files
ychinchrisbra
authored andcommitted
patch 9.2.0294: if_lua: lua interface does not work with lua 5.5
Problem: if_lua: lua interface does not work with lua 5.5 (Lyderic Landry) Solution: Use the new lua API `luaL_openselectedlibs()` (Yee Cheng Chin) Lua 5.5 removed the API function `openlibs` with `openselectedlibs`, with `luaL_openlibs` replaced by a macro that just calls the new `luaL_openselectedlibs` in the headers (see lua/lua@d738c8d18). This broke Vim's dynamic Lua build as we try to redefine `luaL_openlibs` ourselves and also this function can no longer be loaded from the lib. Update the code to use the new API call instead to fix the issue. fixes: #19814 closes: #19842 closes: #19909 Signed-off-by: Yee Cheng Chin <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent bd8b6c6 commit 22db4a3

2 files changed

Lines changed: 19 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;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
294,
737739
/**/
738740
293,
739741
/**/

0 commit comments

Comments
 (0)