strv: rename strv_endswith to endswith_strv and dedup ENDSWITH_SET

This commit is contained in:
Mike Yuan
2024-01-04 16:51:57 +08:00
parent eba8b54130
commit 2e6f012bf0
4 changed files with 22 additions and 31 deletions
+10 -10
View File
@@ -716,6 +716,16 @@ char* startswith_strv(const char *s, char * const *l) {
return NULL;
}
char* endswith_strv(const char *s, char * const *l) {
STRV_FOREACH(i, l) {
char *found = endswith(s, *i);
if (found)
return found;
}
return NULL;
}
char** strv_reverse(char **l) {
size_t n;
@@ -915,13 +925,3 @@ int _string_strv_ordered_hashmap_put(OrderedHashmap **h, const char *key, const
}
DEFINE_HASH_OPS_FULL(string_strv_hash_ops, char, string_hash_func, string_compare_func, free, char*, strv_free);
char* strv_endswith(const char *s, char **l) {
STRV_FOREACH(i, l) {
char *e = endswith(s, *i);
if (e)
return (char*) e;
}
return NULL;
}