From 18fab522f949164e7d7167932baa0722a0c741c1 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 30 Jul 2008 18:20:19 +0200 Subject: [PATCH] lua: expand package.path more Signed-off-by: Julien Danjou --- lua.c | 10 +++++++++- lua.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lua.c b/lua.c index 46201e8b..06495193 100644 --- a/lua.c +++ b/lua.c @@ -562,7 +562,7 @@ luaA_parserc(const char *confpatharg) { int screen; const char *confdir, *xdg_config_dirs; - char *confpath = NULL, **xdg_files, **buf; + char *confpath = NULL, **xdg_files, **buf, path[1024]; ssize_t len; if(confpatharg) @@ -580,6 +580,9 @@ luaA_parserc(const char *confpatharg) len += sizeof(AWESOME_CONFIG_FILE); confpath = p_new(char, len); a_strcpy(confpath, len, confdir); + /* update package.path */ + snprintf(path, sizeof(path) - 1, "package.path = package.path .. \";%s/awesome/?.lua\"", confdir); + luaA_dostring(globalconf.L, path); } else { @@ -588,6 +591,9 @@ luaA_parserc(const char *confpatharg) confpath = p_new(char, len); a_strcpy(confpath, len, confdir); a_strcat(confpath, len, XDG_CONFIG_HOME_DEFAULT); + /* update package.path */ + snprintf(path, sizeof(path) - 1, "package.path = package.path .. \";%s" XDG_CONFIG_HOME_DEFAULT "/awesome/?.lua\"", confdir); + luaA_dostring(globalconf.L, path); } a_strcat(confpath, len, AWESOME_CONFIG_FILE); @@ -613,6 +619,8 @@ luaA_parserc(const char *confpatharg) confpath = p_new(char, len); a_strcpy(confpath, len, *buf); a_strcat(confpath, len, AWESOME_CONFIG_FILE); + snprintf(path, sizeof(path) - 1, "package.path = package.path .. \";%s/awesome/?.lua\"", *buf); + luaA_dostring(globalconf.L, path); if(luaL_dofile(globalconf.L, confpath)) fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); else diff --git a/lua.h b/lua.h index dd5c9069..bf4cbd38 100644 --- a/lua.h +++ b/lua.h @@ -71,7 +71,7 @@ typedef int luaA_function; #define luaA_dostring(L, cmd) \ do { \ - if(cmd) \ + if(a_strlen(cmd)) \ if(luaL_dostring(L, cmd)) \ warn("error executing Lua code: %s", \ lua_tostring(L, -1)); \