Move some code from luaa.c to awesome.c

It makes more sense to append the xdg config dirs to our list of
searchpath in awesome.c than in luaa.c. Plus, it simplifies some of the
following work.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-01-25 13:50:52 +01:00
parent 508614dfd2
commit 89202529ea
2 changed files with 13 additions and 13 deletions

View file

@ -545,6 +545,19 @@ main(int argc, char **argv)
/* Get XDG basedir data */
xdgInitHandle(&xdg);
/* add XDG_CONFIG_DIR as include path */
const char * const *xdgconfigdirs = xdgSearchableConfigDirectories(&xdg);
for(; *xdgconfigdirs; xdgconfigdirs++)
{
/* Append /awesome to *xdgconfigdirs */
const char *suffix = "/awesome";
size_t len = a_strlen(*xdgconfigdirs) + a_strlen(suffix) + 1;
char *entry = p_new(char, len);
a_strcat(entry, len, *xdgconfigdirs);
a_strcat(entry, len, suffix);
string_array_append(&searchpath, entry);
}
/* init lua */
luaA_init(&xdg, &searchpath);
string_array_wipe(&searchpath);

13
luaa.c
View file

@ -777,19 +777,6 @@ luaA_init(xdgHandle* xdg, string_array_t *searchpath)
/* Export keys */
key_class_setup(L);
/* add XDG_CONFIG_DIR as include path */
const char * const *xdgconfigdirs = xdgSearchableConfigDirectories(xdg);
for(; *xdgconfigdirs; xdgconfigdirs++)
{
/* Append /awesome to *xdgconfigdirs */
const char *suffix = "/awesome";
size_t len = a_strlen(*xdgconfigdirs) + a_strlen(suffix) + 1;
char *entry = p_new(char, len);
a_strcat(entry, len, *xdgconfigdirs);
a_strcat(entry, len, suffix);
string_array_append(searchpath, entry);
}
/* add Lua search paths */
lua_getglobal(L, "package");
if (LUA_TTABLE != lua_type(L, 1))