From 9bfdc741fefe31d18abe56b96382baab7a199c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Mon, 4 Aug 2014 00:35:01 +0200 Subject: kike: stuff Implemented a lot of the channel stuff and other stuff as well. --- src/common.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/common.c') 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) { -- cgit v1.2.3