main/config: replace some uses of xasprintf() with xstrjoin()

This commit is contained in:
Craig Barnes 2024-03-16 20:17:53 +00:00
parent 578765ad83
commit 853be450bb
2 changed files with 8 additions and 8 deletions

View file

@ -355,9 +355,9 @@ open_config(void)
/* First, check XDG_CONFIG_HOME (or .config, if unset) */ /* First, check XDG_CONFIG_HOME (or .config, if unset) */
if (xdg_config_home != NULL && xdg_config_home[0] != '\0') if (xdg_config_home != NULL && xdg_config_home[0] != '\0')
path = xasprintf("%s/foot/foot.ini", xdg_config_home); path = xstrjoin(xdg_config_home, "/foot/foot.ini");
else if (home_dir != NULL) else if (home_dir != NULL)
path = xasprintf("%s/.config/foot/foot.ini", home_dir); path = xstrjoin(home_dir, "/.config/foot/foot.ini");
if (path != NULL) { if (path != NULL) {
LOG_DBG("checking for %s", path); LOG_DBG("checking for %s", path);
@ -382,7 +382,7 @@ open_config(void)
conf_dir = strtok(NULL, ":")) conf_dir = strtok(NULL, ":"))
{ {
free(path); free(path);
path = xasprintf("%s/foot/foot.ini", conf_dir); path = xstrjoin(conf_dir, "/foot/foot.ini");
LOG_DBG("checking for %s", path); LOG_DBG("checking for %s", path);
int fd = open(path, O_RDONLY | O_CLOEXEC); int fd = open(path, O_RDONLY | O_CLOEXEC);
@ -2861,7 +2861,7 @@ get_server_socket_path(void)
const char *wayland_display = getenv("WAYLAND_DISPLAY"); const char *wayland_display = getenv("WAYLAND_DISPLAY");
if (wayland_display == NULL) { if (wayland_display == NULL) {
return xasprintf("%s/foot.sock", xdg_runtime); return xstrjoin(xdg_runtime, "/foot.sock");
} }
return xasprintf("%s/foot-%s.sock", xdg_runtime, wayland_display); return xasprintf("%s/foot-%s.sock", xdg_runtime, wayland_display);

8
main.c
View file

@ -261,7 +261,7 @@ main(int argc, char *const *argv)
break; break;
case 't': case 't':
tll_push_back(overrides, xasprintf("term=%s", optarg)); tll_push_back(overrides, xstrjoin("term=", optarg));
break; break;
case 'L': case 'L':
@ -269,11 +269,11 @@ main(int argc, char *const *argv)
break; break;
case 'T': case 'T':
tll_push_back(overrides, xasprintf("title=%s", optarg)); tll_push_back(overrides, xstrjoin("title=", optarg));
break; break;
case 'a': case 'a':
tll_push_back(overrides, xasprintf("app-id=%s", optarg)); tll_push_back(overrides, xstrjoin("app-id=", optarg));
break; break;
case 'D': { case 'D': {
@ -287,7 +287,7 @@ main(int argc, char *const *argv)
} }
case 'f': { case 'f': {
char *font_override = xasprintf("font=%s", optarg); char *font_override = xstrjoin("font=", optarg);
tll_push_back(overrides, font_override); tll_push_back(overrides, font_override);
break; break;
} }