luaa: return parsing error right away

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-03-02 14:16:08 +01:00
parent bcfdc290db
commit e81fd419c3
1 changed files with 25 additions and 18 deletions

13
luaa.c
View File

@ -977,8 +977,6 @@ luaA_init(void)
static bool static bool
luaA_loadrc(const char *confpath, bool run) 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)
@ -997,7 +995,7 @@ luaA_loadrc(const char *confpath, bool run)
} }
else else
fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1));
}
return false; return false;
} }
@ -1015,11 +1013,16 @@ luaA_parserc(const char *confpatharg, bool run)
bool ret = false; bool ret = false;
/* try to load, return if it's ok */ /* try to load, return if it's ok */
if(confpatharg)
{
if(luaA_loadrc(confpatharg, run)) if(luaA_loadrc(confpatharg, run))
{ {
ret = true; ret = true;
goto bailout; goto bailout;
} }
else if(!run)
goto bailout;
}
if((confdir = getenv("XDG_CONFIG_HOME"))) if((confdir = getenv("XDG_CONFIG_HOME")))
a_asprintf(&confpath, "%s" AWESOME_CONFIG_FILE, confdir); a_asprintf(&confpath, "%s" AWESOME_CONFIG_FILE, confdir);
@ -1032,6 +1035,8 @@ luaA_parserc(const char *confpatharg, bool run)
ret = true; ret = true;
goto bailout; goto bailout;
} }
else if(!run)
goto bailout;
p_delete(&confpath); p_delete(&confpath);
@ -1053,6 +1058,8 @@ luaA_parserc(const char *confpatharg, bool run)
ret = true; ret = true;
goto bailout; goto bailout;
} }
else if(!run)
goto bailout;
p_delete(&confpath); p_delete(&confpath);
} }