util: rework strappenda(), and rename it strjoina()

After all it is now much more like strjoin() than strappend(). At the
same time, add support for NULL sentinels, even if they are normally not
necessary.
This commit is contained in:
Lennart Poettering
2015-02-03 02:05:59 +01:00
parent 44de0efc6e
commit 63c372cb9d
75 changed files with 248 additions and 237 deletions
+1 -1
View File
@@ -1359,7 +1359,7 @@ int bus_add_match_internal_kernel(
#define internal_match(bus, m) \
((bus)->hello_flags & KDBUS_HELLO_MONITOR \
? (isempty(m) ? "eavesdrop='true'" : strappenda((m), ",eavesdrop='true'")) \
? (isempty(m) ? "eavesdrop='true'" : strjoina((m), ",eavesdrop='true'")) \
: (m))
static int bus_add_match_internal_dbus1(
+1 -1
View File
@@ -354,7 +354,7 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
color = ansi_highlight();
off = ansi_highlight_off();
suffix = strappenda(off, "\n");
suffix = strjoina(off, "\n");
}
if (c->mask & SD_BUS_CREDS_PID)
+2 -2
View File
@@ -256,8 +256,8 @@ static void print_subtree(const char *prefix, const char *path, char **l) {
l++;
}
vertical = strappenda(prefix, draw_special_char(DRAW_TREE_VERTICAL));
space = strappenda(prefix, draw_special_char(DRAW_TREE_SPACE));
vertical = strjoina(prefix, draw_special_char(DRAW_TREE_VERTICAL));
space = strjoina(prefix, draw_special_char(DRAW_TREE_SPACE));
for (;;) {
bool has_more = false;
+1 -1
View File
@@ -1286,7 +1286,7 @@ int bus_set_address_system_remote(sd_bus *b, const char *host) {
if (!e)
return -ENOMEM;
c = strappenda(",argv4=--machine=", m);
c = strjoina(",argv4=--machine=", m);
}
}
+2 -2
View File
@@ -791,7 +791,7 @@ _public_ int sd_machine_get_class(const char *machine, char **class) {
assert_return(machine_name_is_valid(machine), -EINVAL);
assert_return(class, -EINVAL);
p = strappenda("/run/systemd/machines/", machine);
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(p, NEWLINE, "CLASS", &c, NULL);
if (r < 0)
return r;
@@ -814,7 +814,7 @@ _public_ int sd_machine_get_ifindices(const char *machine, int **ifindices) {
assert_return(machine_name_is_valid(machine), -EINVAL);
assert_return(ifindices, -EINVAL);
p = strappenda("/run/systemd/machines/", machine);
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(p, NEWLINE, "NETIF", &netif, NULL);
if (r < 0)
return r;