luaa: use buffer rather than asprintf()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
6ff72afd90
commit
0b61a38c7a
17
luaa.c
17
luaa.c
|
@ -41,6 +41,7 @@
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "common/xcursor.h"
|
#include "common/xcursor.h"
|
||||||
|
#include "common/buffer.h"
|
||||||
|
|
||||||
#ifdef WITH_DBUS
|
#ifdef WITH_DBUS
|
||||||
extern const struct luaL_reg awesome_dbus_lib[];
|
extern const struct luaL_reg awesome_dbus_lib[];
|
||||||
|
@ -739,14 +740,20 @@ luaA_init(xdgHandle* xdg)
|
||||||
|
|
||||||
/* add XDG_CONFIG_DIR as include path */
|
/* add XDG_CONFIG_DIR as include path */
|
||||||
const char * const *xdgconfigdirs = xdgSearchableConfigDirectories(xdg);
|
const char * const *xdgconfigdirs = xdgSearchableConfigDirectories(xdg);
|
||||||
|
buffer_t buf;
|
||||||
|
buffer_init(&buf);
|
||||||
for(; *xdgconfigdirs; xdgconfigdirs++)
|
for(; *xdgconfigdirs; xdgconfigdirs++)
|
||||||
{
|
{
|
||||||
char *buf;
|
size_t len = a_strlen(*xdgconfigdirs);
|
||||||
a_asprintf(&buf, "package.path = package.path .. \";%s/awesome/?.lua;%s/awesome/?/init.lua\"",
|
buffer_addsl(&buf, "package.path = package.path .. \";");
|
||||||
*xdgconfigdirs, *xdgconfigdirs);
|
buffer_add(&buf, *xdgconfigdirs, len);
|
||||||
luaA_dostring(L, buf);
|
buffer_addsl(&buf, "/awesome/?.lua;");
|
||||||
p_delete(&buf);
|
buffer_add(&buf, *xdgconfigdirs, len);
|
||||||
|
buffer_addsl(&buf, "/awesome/?/init.lua\"");
|
||||||
|
luaA_dostring(L, buf.s);
|
||||||
|
buf.len = 0;
|
||||||
}
|
}
|
||||||
|
buffer_wipe(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue