diff --git a/src/common/impl/lua.c b/src/common/impl/lua.c index 1f4050a00..e1384c5e3 100644 --- a/src/common/impl/lua.c +++ b/src/common/impl/lua.c @@ -9,9 +9,7 @@ static yyjson_mut_val* lua2yyjson(lua_State* L, int idx, yyjson_mut_doc* doc, in if (__builtin_expect(depth > 15, false)) { yyjson_mut_doc_free(doc); lua_pushlstring( - L, "yyjson: recursion depth exceeded; possible circular reference", - strlen("yyjson: recursion depth exceeded; possible circular reference") - ); + L, "yyjson: recursion depth exceeded; possible circular reference", strlen("yyjson: recursion depth exceeded; possible circular reference")); lua_error(L); // noreturn __builtin_unreachable(); } @@ -180,6 +178,8 @@ const char* ffLuaLoadState() { FF_LIBRARY_LOAD_SYMBOL_MESSAGE(liblua, luaopen_string) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(liblua, luaopen_table) #endif + + #if !FF_DISABLE_DLOPEN FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(liblua, luaData, luaL_checkany) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(liblua, luaData, luaL_loadbufferx) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(liblua, luaData, luaL_tolstring) @@ -208,6 +208,7 @@ const char* ffLuaLoadState() { FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(liblua, luaData, lua_tolstring) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(liblua, luaData, lua_tonumberx) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(liblua, luaData, lua_type) + #endif lua_State* L = ffluaL_newstate(); if (L == NULL) { diff --git a/src/common/lua.h b/src/common/lua.h index 0c5917cd4..06343c40e 100644 --- a/src/common/lua.h +++ b/src/common/lua.h @@ -3,16 +3,19 @@ #include "fastfetch.h" #if FF_HAVE_LUA - // Hack. LUA_API is defined as extern which prevents us from implementing the functions ourselves. - #include - #undef LUA_API - #undef LUALIB_API - #undef LUAMOD_API - #define LUA_API static inline - #define LUALIB_API LUA_API - #define LUAMOD_API LUA_API + #if !FF_DISABLE_DLOPEN + // Hack. LUA_API is defined as extern which prevents us from implementing the functions ourselves. + #include + #undef LUA_API + #undef LUALIB_API + #undef LUAMOD_API + #define LUA_API static inline + #define LUALIB_API LUA_API + #define LUAMOD_API LUA_API + + #pragma GCC diagnostic ignored "-Wunused-function" + #endif - #pragma GCC diagnostic ignored "-Wunused-function" #include #include #include @@ -24,6 +27,7 @@ #include "common/library.h" extern struct FFLuaData { + #if !FF_DISABLE_DLOPEN FF_LIBRARY_SYMBOL(luaL_checkany) FF_LIBRARY_SYMBOL(luaL_loadbufferx) FF_LIBRARY_SYMBOL(luaL_tolstring) @@ -52,13 +56,13 @@ extern struct FFLuaData { FF_LIBRARY_SYMBOL(lua_tolstring) FF_LIBRARY_SYMBOL(lua_tonumberx) FF_LIBRARY_SYMBOL(lua_type) + #endif lua_State* L; bool inited; } luaData; -const char* ffLuaLoadState(); - + #if !FF_DISABLE_DLOPEN FF_A_ALWAYS_INLINE void(lua_settop)(lua_State* L, int idx) { return luaData.fflua_settop(L, idx); } @@ -148,11 +152,11 @@ FF_A_ALWAYS_INLINE int(lua_rawgeti)(lua_State* L, int idx, lua_Integer n) { } FF_A_ALWAYS_INLINE - #if LUA_VERSION_NUM > 503 + #if LUA_VERSION_NUM > 503 lua_Unsigned - #else + #else size_t - #endif + #endif (lua_rawlen)(lua_State* L, int idx) { return luaData.fflua_rawlen(L, idx); } @@ -176,5 +180,8 @@ FF_A_ALWAYS_INLINE lua_Number(lua_tonumberx)(lua_State* L, int idx, int* isnum) FF_A_ALWAYS_INLINE int(lua_type)(lua_State* L, int idx) { return luaData.fflua_type(L, idx); } + #endif + +const char* ffLuaLoadState(void); #endif