aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-19 17:59:36 +0200
committerMax Kellermann <max@duempel.org>2010-06-30 21:15:39 +0200
commit7cca55549b247f14e40d4d5f21aceb88d0261b12 (patch)
treecbd06a0ec8f010b4e1a935388299525013eeea31
parentc7e89ea3a38b8c022a754d779e6ae1100a2b19af (diff)
downloadmpd-7cca55549b247f14e40d4d5f21aceb88d0261b12.tar.gz
mpd-7cca55549b247f14e40d4d5f21aceb88d0261b12.tar.xz
mpd-7cca55549b247f14e40d4d5f21aceb88d0261b12.zip
tag_ape: moved code to tag_ape_import_item()
Improve code readability.
Diffstat (limited to '')
-rw-r--r--src/tag_ape.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/tag_ape.c b/src/tag_ape.c
index 2ffc9b80b..5dc13d9c5 100644
--- a/src/tag_ape.c
+++ b/src/tag_ape.c
@@ -45,6 +45,26 @@ static const int tagItems[7] = {
TAG_ITEM_DATE,
};
+static struct tag *
+tag_ape_import_item(struct tag *tag, unsigned long flags,
+ const char *key, const char *value, size_t value_length)
+{
+ /* we only care about utf-8 text tags */
+ if ((flags & (0x3 << 1)) != 0)
+ return tag;
+
+ for (unsigned i = 0; i < 7; i++) {
+ if (g_ascii_strcasecmp(key, apeItems[i]) == 0) {
+ if (tag == NULL)
+ tag = tag_new();
+ tag_add_item_n(tag, tagItems[i],
+ value, value_length);
+ }
+ }
+
+ return tag;
+}
+
struct tag *
tag_ape_load(const char *file)
{
@@ -56,7 +76,6 @@ tag_ape_load(const char *file)
size_t tagLen;
size_t size;
unsigned long flags;
- int i;
char *key;
struct {
@@ -127,17 +146,8 @@ tag_ape_load(const char *file)
if (tagLen < size)
goto fail;
- /* we only care about utf-8 text tags */
- if (!(flags & (0x3 << 1))) {
- for (i = 0; i < 7; i++) {
- if (g_ascii_strcasecmp(key, apeItems[i]) == 0) {
- if (!ret)
- ret = tag_new();
- tag_add_item_n(ret, tagItems[i],
- p, size);
- }
- }
- }
+ ret = tag_ape_import_item(ret, flags, key, p, size);
+
p += size;
tagLen -= size;
}