diff options
Diffstat (limited to 'src/strvec.c')
| -rw-r--r-- | src/strvec.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/strvec.c b/src/strvec.c index e668e35..5d140cf 100644 --- a/src/strvec.c +++ b/src/strvec.c @@ -2,6 +2,7 @@ #include "dvec.h" #include "allocator.h" +#include <stddef.h> #include <string.h> int @@ -229,6 +230,23 @@ strvec_remove_str(struct strvec *strvec, const char *str, return 0; } +ssize_t +strvec_find(struct strvec *strvec, size_t start, const char *str) +{ + const char **ent; + size_t i; + + LIBSTRVEC_ABORT_ON_ARGS(!strvec); + + for (i = start; i < strvec->vec.len; i++) { + ent = strvec_at(strvec, i); + if (!str && !*ent) return (ssize_t) i; + if (!strcmp(str, *ent)) return (ssize_t) i; + } + + return -1; +} + char * strvec_join(struct strvec *strvec, const char *sep, const struct allocator *allocator, int *_rc) |
