82 if (reserve == psv->
size) {
84 }
else if (reserve == 0) {
87 }
else if (!psv->
vec) {
90 }
else if (reserve > psv->
size) {
93 memset(psv->
vec + psv->
size, 0, (reserve - psv->
size) *
sizeof(
char *));
98 for (i = psv->
size - 1; i >= reserve; i--) {
112 if (
size == (
size_t) -1) {
121 for (i = 0; i <
size; i++,
vec++) {
142 while ((p = strchr(
str, separator))) {
144 memcpy(new_str,
str, p -
str);
145 new_str[p -
str] =
'\0';
148 psv->
vec[psv->
size - 1] = new_str;
168 for (i = 0, p = psv->
vec; i < psv->
size; i++, p++) {
180 int (*
cmp_func) (
const char *,
const char *))
183 const char *str1, *str2;
185 if (!psv->
vec || 1 == psv->
size) {
189 for (i = 1; i < psv->
size; i++) {
190 if ((str1 = psv->
vec[i])) {
191 for (j = 0; j < i; j++) {
192 if ((str2 = psv->
vec[j])
216 for (i = 0; i < psv->
size;) {
225 if (
str[0] ==
'\0') {
249 for (i = 0, p = dest->
vec, l = src->
vec; i < dest->
size; i++, p++, l++) {
259 const char *
const *))
261 qsort(psv->
vec, psv->
size,
sizeof(
const char *),
262 (int (*) (
const void *,
const void *)) sort_func);
271 memmove(psv->
vec + 1, psv->
vec, (psv->
size - 1) *
sizeof(
char *));
291 }
else if (svindex >= psv->
size) {
295 memmove(psv->
vec + svindex + 1, psv->
vec + svindex,
296 (psv->
size - svindex - 1) *
sizeof(
char *));
325 if (psv->
size == 1) {
332 memmove(psv->
vec + svindex, psv->
vec + svindex + 1,
333 (psv->
size - svindex - 1) *
sizeof(
char *));
334 psv->
vec[psv->
size - 1] = NULL;
352 const struct strvec *stv2)
361 if (0 != strcmp(stv1->
vec[i], stv2->
vec[i])) {
374 return (
const char **) psv->
vec;
382 return svindex < psv->
size;
401 char *buf,
size_t buf_len)
415 *(buf - 1) = separator;
const char * astr_build_or_list(struct astring *astr, const char *const *items, size_t number)
const char * astr_build_and_list(struct astring *astr, const char *const *items, size_t number)
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
#define fc_assert_ret_val(condition, val)
#define fc_calloc(n, esz)
#define fc_realloc(ptr, sz)
void remove_leading_trailing_spaces(char *s)
void strvec_destroy(struct strvec *psv)
void strvec_sort(struct strvec *psv, int(*sort_func)(const char *const *, const char *const *))
void strvec_to_str(const struct strvec *psv, char separator, char *buf, size_t buf_len)
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
bool strvec_index_valid(const struct strvec *psv, size_t svindex)
const char *const * strvec_data(const struct strvec *psv)
void strvec_store(struct strvec *psv, const char *const *vec, size_t size)
static void string_free(char *string)
void strvec_append(struct strvec *psv, const char *string)
void strvec_from_str(struct strvec *psv, char separator, const char *str)
void strvec_reserve(struct strvec *psv, size_t reserve)
const char * strvec_to_or_list(const struct strvec *psv, struct astring *astr)
static char * string_duplicate(const char *string)
const char * strvec_get(const struct strvec *psv, size_t svindex)
void strvec_prepend(struct strvec *psv, const char *string)
void strvec_copy(struct strvec *dest, const struct strvec *src)
struct strvec * strvec_new(void)
void strvec_clear(struct strvec *psv)
size_t strvec_size(const struct strvec *psv)
const char * strvec_to_and_list(const struct strvec *psv, struct astring *astr)
void strvec_remove_duplicate(struct strvec *psv, int(*cmp_func)(const char *, const char *))
bool are_strvecs_equal(const struct strvec *stv1, const struct strvec *stv2)
bool strvec_remove(struct strvec *psv, size_t svindex)
void strvec_remove_empty(struct strvec *psv)
void strvec_insert(struct strvec *psv, size_t svindex, const char *string)
#define strvec_iterate(psv, str)
#define strvec_iterate_end
int fc_snprintf(char *str, size_t n, const char *format,...)