summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2019-10-10 13:45:42 +0300
committerPanu Matilainen <pmatilai@redhat.com>2019-11-18 12:46:29 +0200
commit3e69a82488a6726c4c3ef259060e6d27a2101665 (patch)
treed5402c64952cbaa3329c231cb4aefd9dc3775b6b
parent70666bb619d6af91c3b5b6e230b0e81b1188743f (diff)
downloadrpm-3e69a82488a6726c4c3ef259060e6d27a2101665.tar.gz
Avoid using types from Lua includes in rpmlua.h again
rpmlua.h was originally written in a way that allows it to be included regardless of whether Lua is actually enabled in rpm or not, or where Lua headers are, specifically to isolate the rest of rpm from these details. That was changed in commit 62bd62286aa888c60145daf315a938dd87eadc89 when <lauxlib.h> started getting included in rpmlua.h, which leaks to places like librpmbuild which do not directly use Lua. The way Lua typedef's the luaL_Reg struct to itself defies my C fu for for handling this in some nicer typesafe way, fix this all by just using a void pointer instead, this is just an internal API where buyer can be expected to beware. Fixes #888 (cherry picked from commit facee2c70a0987567abd1287b41bbc673b5e17e3)
-rw-r--r--lib/rpmliblua.c1
-rw-r--r--rpmio/rpmlua.c3
-rw-r--r--rpmio/rpmlua.h8
3 files changed, 4 insertions, 8 deletions
diff --git a/lib/rpmliblua.c b/lib/rpmliblua.c
index 4f91b4364..93f7c9d52 100644
--- a/lib/rpmliblua.c
+++ b/lib/rpmliblua.c
@@ -1,6 +1,7 @@
#include "system.h"
#include <lua.h>
+#include <lauxlib.h>
#include <rpm/rpmlib.h>
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index ad1428fd5..c698ff098 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -179,8 +179,9 @@ rpmlua rpmluaFree(rpmlua lua)
return NULL;
}
-void rpmluaRegister(rpmlua lua, const luaL_Reg *funcs, const char *lib)
+void rpmluaRegister(rpmlua lua, const void *regfuncs, const char *lib)
{
+ const luaL_Reg *funcs = regfuncs;
lua_getfield(lua->L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
lua_getfield(lua->L, -1, lib);
luaL_setfuncs(lua->L, funcs, 0);
diff --git a/rpmio/rpmlua.h b/rpmio/rpmlua.h
index 87418c621..05fe69753 100644
--- a/rpmio/rpmlua.h
+++ b/rpmio/rpmlua.h
@@ -1,10 +1,6 @@
#ifndef RPMLUA_H
#define RPMLUA_H
-#ifdef WITH_LUA
-#include <lauxlib.h>
-#endif
-
typedef enum rpmluavType_e {
RPMLUAV_NIL = 0,
RPMLUAV_STRING = 1,
@@ -23,9 +19,7 @@ rpmlua rpmluaNew(void);
rpmlua rpmluaFree(rpmlua lua);
rpmlua rpmluaGetGlobalState(void);
-#ifdef WITH_LUA
-void rpmluaRegister(rpmlua lua, const luaL_Reg *funcs, const char *lib);
-#endif
+void rpmluaRegister(rpmlua lua, const void *regfuncs, const char *lib);
int rpmluaCheckScript(rpmlua lua, const char *script,
const char *name);