1
0
Fork 0

[.config] Add trailing / to xdg_config_home. Refs #202

This commit is contained in:
Witold Filipczyk 2022-12-27 11:49:54 +01:00
parent 201e6c055a
commit 846a6a7187
1 changed files with 11 additions and 7 deletions

View File

@ -92,6 +92,8 @@ get_xdg_config_home(void)
return xdg_config_home;
}
char *g_xdg_config_home = getenv("XDG_CONFIG_HOME");
char *home;
char *config_dir = NULL;
if (g_xdg_config_home && *g_xdg_config_home) {
xdg_config_home = test_confdir(g_xdg_config_home,
@ -99,22 +101,22 @@ get_xdg_config_home(void)
N_("Commandline options -config-dir set to %s, "
"but could not create directory %s."));
if (xdg_config_home) {
return xdg_config_home;
goto end;
}
xdg_config_home = test_confdir(g_xdg_config_home, "elinks", NULL);
if (xdg_config_home) {
return xdg_config_home;
goto end;
}
return NULL;
}
char *home = getenv("HOME");
home = getenv("HOME");
if (!home || !*home) {
return NULL;
}
char *config_dir = straconcat(home, STRING_DIR_SEP, ".config", NULL);
config_dir = straconcat(home, STRING_DIR_SEP, ".config", NULL);
if (!config_dir) {
return NULL;
@ -124,13 +126,15 @@ get_xdg_config_home(void)
N_("Commandline options -config-dir set to %s, "
"but could not create directory %s."));
if (xdg_config_home) {
mem_free(config_dir);
return xdg_config_home;
goto end;
}
xdg_config_home = test_confdir(config_dir, "elinks", NULL);
end:
mem_free_if(config_dir);
if (xdg_config_home) {
mem_free(config_dir);
add_to_strn(&xdg_config_home, STRING_DIR_SEP);
return xdg_config_home;
}