fix loop over config files if none was found

if no file was found the string is just "\0" and neads a head
controled while

if no config file was found exit awesome with an error message
(fail early!)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
M. Dietrich 2009-06-01 13:01:31 +02:00 committed by Julien Danjou
parent 7795f623dd
commit 907a5379a3
2 changed files with 4 additions and 3 deletions

View File

@ -513,7 +513,8 @@ main(int argc, char **argv)
spawn_init(); spawn_init();
/* Parse and run configuration file */ /* Parse and run configuration file */
luaA_parserc(&xdg, confpath, true); if (!luaA_parserc(&xdg, confpath, true))
fatal("couldn't find any rc file");
xdgWipeHandle(&xdg); xdgWipeHandle(&xdg);

4
luaa.c
View File

@ -835,7 +835,7 @@ luaA_parserc(xdgHandle* xdg, const char *confpatharg, bool run)
char *tmp = confpath; char *tmp = confpath;
/* confpath is "string1\0string2\0string3\0\0" */ /* confpath is "string1\0string2\0string3\0\0" */
do while(*tmp)
{ {
if(luaA_loadrc(tmp, run)) if(luaA_loadrc(tmp, run))
{ {
@ -845,7 +845,7 @@ luaA_parserc(xdgHandle* xdg, const char *confpatharg, bool run)
else if(!run) else if(!run)
goto bailout; goto bailout;
tmp += a_strlen(tmp) + 1; tmp += a_strlen(tmp) + 1;
} while(*tmp != 0); }
bailout: bailout: