luaa: use buffer rather than asprintf()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-26 20:22:10 +02:00
parent 6ff72afd90
commit 0b61a38c7a
1 changed files with 12 additions and 5 deletions

17
luaa.c
View File

@ -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