diff options
author | Max Kellermann <max@duempel.org> | 2009-01-24 15:56:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-24 15:56:34 +0100 |
commit | e6cb939a82d8559c338ce4cc824c55f4d58499e1 (patch) | |
tree | e5f794457752a791bfea3eb7aac301d9eba179d6 | |
parent | 6a2118d04c7b73450edfffb6fdc40de1a05bfe94 (diff) | |
download | mpd-e6cb939a82d8559c338ce4cc824c55f4d58499e1.tar.gz mpd-e6cb939a82d8559c338ce4cc824c55f4d58499e1.tar.xz mpd-e6cb939a82d8559c338ce4cc824c55f4d58499e1.zip |
locate: added locate_item_list_casefold()
Merged casefolding code from two locations into this one library
function.
Diffstat (limited to '')
-rw-r--r-- | src/dbUtils.c | 8 | ||||
-rw-r--r-- | src/locate.c | 12 | ||||
-rw-r--r-- | src/locate.h | 7 | ||||
-rw-r--r-- | src/queue_print.c | 6 |
4 files changed, 22 insertions, 11 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c index 00df5b606..b33ec58df 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -84,14 +84,10 @@ searchForSongsIn(struct client *client, const char *name, const struct locate_item_list *criteria) { int ret; - struct locate_item_list *new_list; + struct locate_item_list *new_list + = locate_item_list_casefold(criteria); struct search_data data; - new_list = locate_item_list_new(criteria->length); - for (unsigned i = 0; i < criteria->length; i++) - new_list->items[i].needle = - g_utf8_casefold(criteria->items[i].needle, -1); - data.client = client; data.criteria = new_list; diff --git a/src/locate.c b/src/locate.c index 9f6eff686..d334e797a 100644 --- a/src/locate.c +++ b/src/locate.c @@ -117,6 +117,18 @@ locate_item_list_parse(char *argv[], int argc) return list; } +struct locate_item_list * +locate_item_list_casefold(const struct locate_item_list *list) +{ + struct locate_item_list *new_list = locate_item_list_new(list->length); + + for (unsigned i = 0; i < list->length; i++) + new_list->items[i].needle = + g_utf8_casefold(list->items[i].needle, -1); + + return new_list; +} + void locate_item_free(struct locate_item *item) { diff --git a/src/locate.h b/src/locate.h index 0f1bd1a64..c2d4c0ec4 100644 --- a/src/locate.h +++ b/src/locate.h @@ -63,6 +63,13 @@ locate_item_list_new(unsigned length); struct locate_item_list * locate_item_list_parse(char *argv[], int argc); +/** + * Duplicate the struct locate_item_list object and convert all + * needles with g_utf8_casefold(). + */ +struct locate_item_list * +locate_item_list_casefold(const struct locate_item_list *list); + void locate_item_list_free(struct locate_item_list *list); diff --git a/src/queue_print.c b/src/queue_print.c index 54cdc15ae..5479360a2 100644 --- a/src/queue_print.c +++ b/src/queue_print.c @@ -85,11 +85,7 @@ queue_search(struct client *client, const struct queue *queue, { unsigned i; struct locate_item_list *new_list = - locate_item_list_new(criteria->length); - - for (i = 0; i < criteria->length; i++) - new_list->items[i].needle = - g_utf8_casefold(criteria->items[i].needle, -1); + locate_item_list_casefold(criteria); for (i = 0; i < queue_length(queue); i++) { const struct song *song = queue_get(queue, i); |