From e81fd419c3f7f8a283de793d38db19e0f2fb700e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 2 Mar 2009 14:16:08 +0100 Subject: [PATCH] luaa: return parsing error right away Signed-off-by: Julien Danjou --- luaa.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/luaa.c b/luaa.c index 6a83ec062..269d9e60a 100644 --- a/luaa.c +++ b/luaa.c @@ -977,27 +977,25 @@ luaA_init(void) static bool luaA_loadrc(const char *confpath, bool run) { - if(confpath) + if(!luaL_loadfile(globalconf.L, confpath)) { - if(!luaL_loadfile(globalconf.L, confpath)) + if(run) { - if(run) - { - 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; - } - } + if(lua_pcall(globalconf.L, 0, LUA_MULTRET, 0)) + fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); else - lua_pop(globalconf.L, 1); - return true; + { + globalconf.conffile = a_strdup(confpath); + return true; + } } else - fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); + lua_pop(globalconf.L, 1); + return true; } + else + fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); + return false; } @@ -1015,10 +1013,15 @@ luaA_parserc(const char *confpatharg, bool run) bool ret = false; /* try to load, return if it's ok */ - if(luaA_loadrc(confpatharg, run)) + if(confpatharg) { - ret = true; - goto bailout; + if(luaA_loadrc(confpatharg, run)) + { + ret = true; + goto bailout; + } + else if(!run) + goto bailout; } if((confdir = getenv("XDG_CONFIG_HOME"))) @@ -1032,6 +1035,8 @@ luaA_parserc(const char *confpatharg, bool run) ret = true; goto bailout; } + else if(!run) + goto bailout; p_delete(&confpath); @@ -1053,6 +1058,8 @@ luaA_parserc(const char *confpatharg, bool run) ret = true; goto bailout; } + else if(!run) + goto bailout; p_delete(&confpath); }