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

View File

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

View File

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