summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-08-04 00:35:01 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-08-04 01:24:10 +0200
commit9bfdc741fefe31d18abe56b96382baab7a199c85 (patch)
treedef0120c6cf517a1c3a892aea777b0aa802121a5 /src/common.c
parent3291fd5c7ad82852ed1db1350755f85cc412ab39 (diff)
downloadxK-9bfdc741fefe31d18abe56b96382baab7a199c85.tar.gz
xK-9bfdc741fefe31d18abe56b96382baab7a199c85.tar.xz
xK-9bfdc741fefe31d18abe56b96382baab7a199c85.zip
kike: stuff
Implemented a lot of the channel stuff and other stuff as well.
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)
{