Rename strv_add*() to strv_append*()

Consistency.
This commit is contained in:
Přemysl Eric Janouch 2017-01-23 23:07:24 +01:00
parent 6642bdf9cd
commit 0e08055d6d
Signed by: p
GPG Key ID: B715679E3A361BE6
3 changed files with 24 additions and 24 deletions

View File

@ -132,7 +132,7 @@ irc_parse_message (struct irc_message *msg, const char *line)
if (*line == ':')
{
strv_add (&msg->params, ++line);
strv_append (&msg->params, ++line);
break;
}
@ -140,7 +140,7 @@ irc_parse_message (struct irc_message *msg, const char *line)
if (!param_len)
break;
strv_add_owned (&msg->params, xstrndup (line, param_len));
strv_append_owned (&msg->params, xstrndup (line, param_len));
line += param_len;
}
}
@ -1572,7 +1572,7 @@ mpd_client_parse_line (struct mpd_client *self, const char *line)
struct mpd_response response;
memset (&response, 0, sizeof response);
if (!strcmp (line, "list_OK"))
strv_add_owned (&self->data, NULL);
strv_append_owned (&self->data, NULL);
else if (mpd_client_parse_response (line, &response))
{
mpd_client_dispatch (self, &response);
@ -1580,7 +1580,7 @@ mpd_client_parse_line (struct mpd_client *self, const char *line)
free (response.message_text);
}
else
strv_add (&self->data, line);
strv_append (&self->data, line);
return true;
}
@ -1741,7 +1741,7 @@ mpd_client_send_command (struct mpd_client *self, const char *command, ...)
va_list ap;
va_start (ap, command);
for (; command; command = va_arg (ap, const char *))
strv_add (&v, command);
strv_append (&v, command);
va_end (ap);
mpd_client_send_commandv (self, v.vector);
@ -1839,10 +1839,10 @@ mpd_client_idle (struct mpd_client *self, unsigned subsystems)
struct strv v;
strv_init (&v);
strv_add (&v, "idle");
strv_append (&v, "idle");
for (size_t i = 0; i < N_ELEMENTS (mpd_subsystem_names); i++)
if (subsystems & (1 << i))
strv_add (&v, mpd_subsystem_names[i]);
strv_append (&v, mpd_subsystem_names[i]);
mpd_client_send_commandv (self, v.vector);
strv_free (&v);

View File

@ -411,7 +411,7 @@ strv_reset (struct strv *self)
}
static void
strv_add_owned (struct strv *self, char *s)
strv_append_owned (struct strv *self, char *s)
{
self->vector[self->len] = s;
if (++self->len >= self->alloc)
@ -421,34 +421,34 @@ strv_add_owned (struct strv *self, char *s)
}
static void
strv_add (struct strv *self, const char *s)
strv_append (struct strv *self, const char *s)
{
strv_add_owned (self, xstrdup (s));
strv_append_owned (self, xstrdup (s));
}
static void
strv_add_args (struct strv *self, const char *s, ...)
strv_append_args (struct strv *self, const char *s, ...)
ATTRIBUTE_SENTINEL;
static void
strv_add_args (struct strv *self, const char *s, ...)
strv_append_args (struct strv *self, const char *s, ...)
{
va_list ap;
va_start (ap, s);
while (s)
{
strv_add (self, s);
strv_append (self, s);
s = va_arg (ap, const char *);
}
va_end (ap);
}
static void
strv_add_vector (struct strv *self, char **vector)
strv_append_vector (struct strv *self, char **vector)
{
while (*vector)
strv_add (self, *vector++);
strv_append (self, *vector++);
}
static char *
@ -2921,11 +2921,11 @@ cstr_split (const char *s, const char *delimiters, bool ignore_empty,
while ((end = strpbrk (begin, delimiters)))
{
if (!ignore_empty || begin != end)
strv_add_owned (out, xstrndup (begin, end - begin));
strv_append_owned (out, xstrndup (begin, end - begin));
begin = ++end;
}
if (!ignore_empty || *begin)
strv_add (out, begin);
strv_append (out, begin);
}
static char *
@ -3213,7 +3213,7 @@ get_xdg_config_dirs (struct strv *out)
struct str config_home;
str_init (&config_home);
get_xdg_home_dir (&config_home, "XDG_CONFIG_HOME", ".config");
strv_add (out, config_home.str);
strv_append (out, config_home.str);
str_free (&config_home);
const char *xdg_config_dirs;
@ -3240,7 +3240,7 @@ get_xdg_data_dirs (struct strv *out)
struct str data_home;
str_init (&data_home);
get_xdg_home_dir (&data_home, "XDG_DATA_HOME", ".local/share");
strv_add (out, data_home.str);
strv_append (out, data_home.str);
str_free (&data_home);
const char *xdg_data_dirs;

View File

@ -162,7 +162,7 @@ test_strv (void)
struct strv v;
strv_init (&v);
strv_add_owned (&v, xstrdup ("xkcd"));
strv_append_owned (&v, xstrdup ("xkcd"));
strv_reset (&v);
const char *a[] =
@ -171,17 +171,17 @@ test_strv (void)
// Add the first two items via another vector
struct strv w;
strv_init (&w);
strv_add_args (&w, a[0], a[1], NULL);
strv_add_vector (&v, w.vector);
strv_append_args (&w, a[0], a[1], NULL);
strv_append_vector (&v, w.vector);
strv_free (&w);
// Add an item and delete it right after
strv_add (&v, "test");
strv_append (&v, "test");
strv_remove (&v, v.len - 1);
// Add the rest of the list properly
for (int i = 2; i < (int) N_ELEMENTS (a); i++)
strv_add (&v, a[i]);
strv_append (&v, a[i]);
// Check the contents
soft_assert (v.len == N_ELEMENTS (a));