summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-11-04 07:07:06 (GMT)
committerJeff King <peff@peff.net>2012-11-08 16:34:08 (GMT)
commit6bb2a1377b4b7a044f69d0107c38479180694fac (patch)
tree3bf597a5322507120597b9ec67bcc2ee394a1530 /string-list.c
parent9c50374497d5a3259907e32455f228cfbda85ddf (diff)
downloadgit-6bb2a1377b4b7a044f69d0107c38479180694fac.zip
git-6bb2a1377b4b7a044f69d0107c38479180694fac.tar.gz
git-6bb2a1377b4b7a044f69d0107c38479180694fac.tar.bz2
string_list: add a function string_list_remove_empty_items()
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Acked-by: Johan Herland <johan@herland.net> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/string-list.c b/string-list.c
index c54b816..397e6cf 100644
--- a/string-list.c
+++ b/string-list.c
@@ -136,6 +136,15 @@ void filter_string_list(struct string_list *list, int free_util,
list->nr = dst;
}
+static int item_is_not_empty(struct string_list_item *item, void *unused)
+{
+ return *item->string != '\0';
+}
+
+void string_list_remove_empty_items(struct string_list *list, int free_util) {
+ filter_string_list(list, free_util, item_is_not_empty, NULL);
+}
+
char *string_list_longest_prefix(const struct string_list *prefixes,
const char *string)
{