aboutsummaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index 5a505b2..389120c 100644
--- a/src/common.c
+++ b/src/common.c
@@ -642,7 +642,7 @@ str_map_iter_next (struct str_map_iter *self)
self->link = self->link->next;
while (!self->link)
{
- if (self->next_index >= map->len)
+ if (self->next_index >= map->alloc)
return NULL;
self->link = map->map[self->next_index++];
}
@@ -1376,6 +1376,33 @@ strip_str_in_place (char *s, const char *stripped_chars)
return s;
}
+static char *
+join_str_vector (const struct str_vector *v, char delimiter)
+{
+ if (!v->len)
+ return xstrdup ("");
+
+ struct str result;
+ str_init (&result);
+ str_append (&result, v->vector[0]);
+ for (size_t i = 1; i < v->len; i++)
+ str_append_printf (&result, "%c%s", delimiter, v->vector[i]);
+ return str_steal (&result);
+}
+
+ATTRIBUTE_PRINTF (1, 2)
+static char *
+xstrdup_printf (const char *format, ...)
+{
+ va_list ap;
+ struct str tmp;
+ str_init (&tmp);
+ va_start (ap, format);
+ str_append_vprintf (&tmp, format, ap);
+ va_end (ap);
+ return str_steal (&tmp);
+}
+
static bool
str_append_env_path (struct str *output, const char *var, bool only_absolute)
{