Skip to content

Commit

Permalink
Add XDG config directories to the Lua searchpath
Browse files Browse the repository at this point in the history
  • Loading branch information
rootmos committed Jul 24, 2024
1 parent 60e34af commit c87a29a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION_MAJOR=0
VERSION_MINOR=1
VERSION_PATCH=1
VERSION_PATCH=2
12 changes: 12 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit c87a29a

Please sign in to comment.