xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3()

This avoids the need for an unused third argument for most xstrjoin()
calls and replaces the cases where it's needed with a more flexible
function. Code generation is the same in both cases, when there are 2
string params and a compile-time known delimiter.

This commit also converts 4 uses of xasprintf() to use xstrjoin*().

See also: https://godbolt.org/z/xsjrhv9b6
This commit is contained in:
Craig Barnes 2024-08-03 08:12:13 +01:00
parent 62b0b65d47
commit f87c9bb9f7
7 changed files with 44 additions and 31 deletions

View file

@ -994,7 +994,7 @@ reload_fonts(struct terminal *term, bool resize_grid)
snprintf(size, sizeof(size), ":size=%.2f",
term->font_sizes[i][j].pt_size * scale);
names[i][j] = xstrjoin(font->pattern, size, 0);
names[i][j] = xstrjoin(font->pattern, size);
}
}
@ -1021,9 +1021,9 @@ reload_fonts(struct terminal *term, bool resize_grid)
char *attrs[4] = {
[0] = dpi, /* Takes ownership */
[1] = xstrjoin(dpi, !custom_bold ? ":weight=bold" : "", 0),
[2] = xstrjoin(dpi, !custom_italic ? ":slant=italic" : "", 0),
[3] = xstrjoin(dpi, !custom_bold_italic ? ":weight=bold:slant=italic" : "", 0),
[1] = xstrjoin(dpi, !custom_bold ? ":weight=bold" : ""),
[2] = xstrjoin(dpi, !custom_italic ? ":slant=italic" : ""),
[3] = xstrjoin(dpi, !custom_bold_italic ? ":weight=bold:slant=italic" : ""),
};
struct fcft_font *fonts[4];