From bf56ae79dde6775287d3df2f9624971ef37977c9 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 28c0cfed2..474a3b648 100644 --- a/luaa.c +++ b/luaa.c @@ -639,13 +639,17 @@ luaA_loadrc(const char *confpath, bool run) { if(run) { + /* Set the conffile right now so it can be used inside the + * configuration file. */ + conffile = a_strdup(confpath); if(lua_pcall(globalconf.L, 0, LUA_MULTRET, 0)) - fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); - else { - conffile = a_strdup(confpath); - return true; + fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); + /* An error happened, so reset this. */ + conffile = NULL; } + else + return true; } else {