From c87a29a61b2b374263d9fd2816b2e19f66643178 Mon Sep 17 00:00:00 2001 From: Gustav Behm Date: Wed, 24 Jul 2024 18:30:36 +0200 Subject: [PATCH] Add XDG config directories to the Lua searchpath --- .version | 2 +- src/cli.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.version b/.version index de9e145..8fe9561 100644 --- a/.version +++ b/.version @@ -1,3 +1,3 @@ VERSION_MAJOR=0 VERSION_MINOR=1 -VERSION_PATCH=1 +VERSION_PATCH=2 diff --git a/src/cli.c b/src/cli.c index 51ed3a3..09a2fdc 100644 --- a/src/cli.c +++ b/src/cli.c @@ -143,6 +143,18 @@ static int add_xdg_to_search_paths(lua_State* L) failwith("buffer overflow"); } + for(const char** p = xdg_dirs(xdg, XDG_CONFIG); *p != NULL; p++) { + l += snprintf(&path[l], sizeof(path) - l, ";%s/?.lua;%s/?/init.lua", *p, *p); + if(l >= sizeof(path)) { + failwith("pathfer overflow"); + } + + cl += snprintf(&cpath[cl], sizeof(cpath) - cl, ";%s/?.so", *p); + if(cl >= sizeof(cpath)) { + failwith("pathfer overflow"); + } + } + for(const char** p = xdg_dirs(xdg, XDG_DATA); *p != NULL; p++) { l += snprintf(&path[l], sizeof(path) - l, ";%s/?.lua;%s/?/init.lua", *p, *p); if(l >= sizeof(path)) {