summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5cba05)
raw | patch | inline | side by side (parent: d5cba05)
author | Max Kellermann <max@duempel.org> | |
Sat, 10 Oct 2009 14:36:10 +0000 (16:36 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 10 Oct 2009 14:36:10 +0000 (16:36 +0200) |
Concatenate them with ", " in between.
NEWS | patch | blob | history | |
src/strfsong.c | patch | blob | history |
index fc7be11ebd536221206e4e1544ba1fde30bdabb8..4ce914c5decf67f3758fdd3307840b7f5a80a2fa 100644 (file)
--- a/NEWS
+++ b/NEWS
* list_window: fix narrow cursor drawing
* screen_play: repaint after the "select-playing" command
* screen_text: start searching at window origin, not bottom
+* strfsong: support multiple values for a tag
ncmpc 0.15 - 2009-09-24
diff --git a/src/strfsong.c b/src/strfsong.c
index a146583516553754d14d4c9da03f6362de858db3..39e0c52a0fa9a37541904dd273e5d9445f76ebc7 100644 (file)
--- a/src/strfsong.c
+++ b/src/strfsong.c
return p;
}
+#ifndef NCMPC_MINI
+
+static char *
+concat_tag_values(const char *a, const char *b)
+{
+ return g_strconcat(a, ", ", b, NULL);
+}
+
+static char *
+song_more_tag_values(const struct mpd_song *song, enum mpd_tag_type tag,
+ const char *first)
+{
+ const char *p = mpd_song_get_tag(song, tag, 1);
+ char *buffer, *prev;
+
+ if (p == NULL)
+ return NULL;
+
+ buffer = concat_tag_values(first, p);
+ for (unsigned i = 2; (p = mpd_song_get_tag(song, tag, i)) != NULL;
+ ++i) {
+ prev = buffer;
+ buffer = concat_tag_values(buffer, p);
+ g_free(prev);
+ }
+
+ return buffer;
+}
+
+#endif /* !NCMPC_MINI */
+
static char *
song_tag_locale(const struct mpd_song *song, enum mpd_tag_type tag)
{
const char *value = mpd_song_get_tag(song, tag, 0);
+ char *result;
+#ifndef NCMPC_MINI
+ char *all;
+#endif /* !NCMPC_MINI */
+
if (value == NULL)
return NULL;
- return utf8_to_locale(value);
+#ifndef NCMPC_MINI
+ all = song_more_tag_values(song, tag, value);
+ if (all != NULL)
+ value = all;
+#endif /* !NCMPC_MINI */
+
+ result = utf8_to_locale(value);
+
+#ifndef NCMPC_MINI
+ g_free(all);
+#endif /* !NCMPC_MINI */
+
+ return result;
}
static gsize