stat_ctx->lua_stat_tokens_ref = -1;
/* Interact with lua_stat */
+ int lua_stat_top = lua_gettop(L);
if (luaL_dostring(L, "return require \"lua_stat\"") != 0) {
msg_err_config("cannot require lua_stat: %s",
lua_tostring(L, -1));
}
else {
-#if LUA_VERSION_NUM >= 504
- lua_settop(L, -2);
-#endif
+ /* Lua 5.4's require returns 2 values (module + path), keep only first */
+ lua_settop(L, lua_stat_top + 1);
if (lua_type(L, -1) != LUA_TTABLE) {
msg_err_config("lua stat must return "
"table and not %s",
}
}
+ int selector_top = lua_gettop(L);
if (luaL_dostring(L, "return require \"lua_selectors\"") != 0) {
msg_warn_config("cannot require lua_selectors: %s",
lua_tostring(L, -1));
}
else {
+ /* Lua 5.4's require returns 2 values (module + path), keep only first */
+ lua_settop(L, selector_top + 1);
if (lua_type(L, -1) != LUA_TTABLE) {
msg_warn_config("lua selectors must return "
"table and not %s",
}
}
+ int selector_top = lua_gettop(L);
if (luaL_dostring(L, "return require \"lua_selectors\"") != 0) {
msg_warn_config("cannot require lua_selectors: %s",
lua_tostring(L, -1));
}
else {
+ /* Lua 5.4's require returns 2 values (module + path), keep only first */
+ lua_settop(L, selector_top + 1);
if (lua_type(L, -1) != LUA_TTABLE) {
msg_warn_config("lua selectors must return "
"table and not %s",
fuzzy_module_ctx->cleanup_rules_ref = -1;
/* Interact with lua_fuzzy */
+ int lua_fuzzy_top = lua_gettop(L);
if (luaL_dostring(L, "return require \"lua_fuzzy\"") != 0) {
msg_err_config("cannot require lua_fuzzy: %s",
lua_tostring(L, -1));
fuzzy_module_ctx->enabled = FALSE;
}
else {
-#if LUA_VERSION_NUM >= 504
- lua_settop(L, -2);
-#endif
+ /* Lua 5.4's require returns 2 values (module + path), keep only first */
+ lua_settop(L, lua_fuzzy_top + 1);
if (lua_type(L, -1) != LUA_TTABLE) {
msg_err_config("lua fuzzy must return "
"table and not %s",
script_name);
}
+ int top = lua_gettop(L);
+
if (luaL_dostring(L, str) != 0) {
msg_err("cannot execute lua script %s: %s",
str, lua_tostring(L, -1));
return FALSE;
}
else {
+ /* Lua 5.4's require returns 2 values (module + path), keep only first */
+ lua_settop(L, top + 1);
+
if (lua_type(L, -1) == LUA_TTABLE) {
lua_pushstring(L, "handler");
lua_gettable(L, -2);