From a8abeef91f0669e726e0b9ab398d56cc38efa3c6 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Sat, 22 Nov 2008 16:44:33 +0200 Subject: [PATCH] Use rpmConfigDir() instead of hardwired value in Lua initialization - userconfig is actually unused --- luaext/userconfig.c | 2 +- rpmio/rpmlua.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/luaext/userconfig.c b/luaext/userconfig.c index 014e325..458768a 100644 --- a/luaext/userconfig.c +++ b/luaext/userconfig.c @@ -51,7 +51,7 @@ static void mysaveline (lua_State *L, const char *s) { static int luapath(lua_State *L) { lua_pushstring(L, "LUA_PATH"); - lua_pushstring(L, RPMCONFIGDIR "/lua/?.lua;?.lua"); + lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua;?.lua"); lua_rawset(L, LUA_GLOBALSINDEX); return 0; } diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c index 3345c56..1a40b27 100644 --- a/rpmio/rpmlua.c +++ b/rpmio/rpmlua.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "rpmio/rpmhook.h" #define _RPMLUA_INTERNAL @@ -39,6 +40,7 @@ rpmlua rpmluaNew() rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua)); struct stat st; const luaL_reg *lib; + char *initlua = rpmGenPath(rpmConfigDir(), "init.lua", NULL); static const luaL_reg extlibs[] = { {"posix", luaopen_posix}, @@ -58,14 +60,15 @@ rpmlua rpmluaNew() lua_settop(L, 0); } lua_pushliteral(L, "LUA_PATH"); - lua_pushstring(L, RPMCONFIGDIR "/lua/?.lua"); + lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua"); lua_rawset(L, LUA_GLOBALSINDEX); lua_pushliteral(L, "print"); lua_pushcfunction(L, rpm_print); lua_rawset(L, LUA_GLOBALSINDEX); rpmluaSetData(lua, "lua", lua); - if (stat(RPMCONFIGDIR "/init.lua", &st) != -1) - (void)rpmluaRunScriptFile(lua, RPMCONFIGDIR "/init.lua"); + if (stat(initlua, &st) != -1) + (void)rpmluaRunScriptFile(lua, initlua); + free(initlua); return lua; } -- 2.7.4