Correctly handle fallback config directories

This commit is contained in:
Simon Long 2024-01-06 09:15:33 +00:00
parent 23d2b82b74
commit 1385ce20ad
2 changed files with 6 additions and 2 deletions

View file

@ -144,7 +144,11 @@ config_dir_n(int n)
.len = sizeof(buf),
.dirs = config_dirs
};
return find_dir(&ctx, n);
if (n == 0) {
return find_dir(&ctx, getenv("XDG_CONFIG_HOME") ? 0 : 1);
} else {
return find_dir(&ctx, getenv("XDG_CONFIG_DIRS") ? 2 : 3);
}
}
char *

View file

@ -1474,7 +1474,7 @@ rcxml_read(const char *filename)
* the first time. The specified 'filename' is only respected the first
* time.
*/
for (int i = 3; i >= 0; i--) {
for (int i = 1; i >= 0; i--) {
line = NULL;
len = 0;
if (filename) {