From f0ca5e75056930da20127c17fb65fd34360db796 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 17 Sep 2011 17:21:34 +0200 Subject: [PATCH] Set the conffile value before executing the code Signed-off-by: Julien Danjou --- luaa.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/luaa.c b/luaa.c index 56c65d1cb..d8d0229ee 100644 --- a/luaa.c +++ b/luaa.c @@ -853,13 +853,17 @@ luaA_loadrc(const char *confpath, bool run) { if(run) { + /* Set the conffile right now so it can be used inside the + * configuration file. */ + globalconf.conffile = a_strdup(confpath); if(lua_pcall(globalconf.L, 0, LUA_MULTRET, 0)) - fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); - else { - globalconf.conffile = a_strdup(confpath); - return true; + fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); + /* An error happened, so reset this. */ + globalconf.conffile = NULL; } + else + return true; } else {