string_list_add_refs_from_colon_sep(): use string_list_split()

It makes for simpler code than strbuf_split().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:
Michael Haggerty 2012-11-04 08:07:10 +01:00 committed by Jeff King
parent 031954d443
commit 6fa23773d2

21
notes.c
View File

@ -943,23 +943,18 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
void string_list_add_refs_from_colon_sep(struct string_list *list, void string_list_add_refs_from_colon_sep(struct string_list *list,
const char *globs) const char *globs)
{ {
struct strbuf globbuf = STRBUF_INIT; struct string_list split = STRING_LIST_INIT_NODUP;
struct strbuf **split; char *globs_copy = xstrdup(globs);
int i; int i;
strbuf_addstr(&globbuf, globs); string_list_split_in_place(&split, globs_copy, ':', -1);
split = strbuf_split(&globbuf, ':'); string_list_remove_empty_items(&split, 0);
for (i = 0; split[i]; i++) { for (i = 0; i < split.nr; i++)
if (split[i]->len && split[i]->buf[split[i]->len-1] == ':') string_list_add_refs_by_glob(list, split.items[i].string);
strbuf_setlen(split[i], split[i]->len-1);
if (!split[i]->len)
continue;
string_list_add_refs_by_glob(list, split[i]->buf);
}
strbuf_list_free(split); string_list_clear(&split, 0);
strbuf_release(&globbuf); free(globs_copy);
} }
static int notes_display_config(const char *k, const char *v, void *cb) static int notes_display_config(const char *k, const char *v, void *cb)