Hi Max,

OK, I see. I've changed the patch to cover your suggestion.

Best regards,
Andreas


2015-08-12 12:15 GMT+02:00 Max Kellermann <m...@duempel.org>:
> On 2015/08/12 09:20, Andreas Mair <amair....@gmail.com> wrote:
>> Hi Max,
>>
>> I've built a small patch that will "clean" the track and disc numbers.
>> Maybe you want to apply that attached patch.
>
> I'm not happy with that.  If the "TRACK" tag is non-numeric garbage,
> MPD will assume track number "0", which is not correct.  It would be
> better not to expose a "TRACK" tag at all than one with an incorrect
> value.
diff --git a/src/tag/TagHandler.cxx b/src/tag/TagHandler.cxx
index 9bbaae3..4a8c5eb 100644
--- a/src/tag/TagHandler.cxx
+++ b/src/tag/TagHandler.cxx
@@ -17,6 +17,9 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <stdio.h>
+#include <stdlib.h>
+
 #include "config.h"
 #include "TagHandler.hxx"
 #include "TagBuilder.hxx"
@@ -35,7 +38,18 @@ add_tag_tag(TagType type, const char *value, void *ctx)
 {
 	TagBuilder &tag = *(TagBuilder *)ctx;
 
-	tag.AddItem(type, value);
+	if (type == TAG_TRACK || type == TAG_DISC) {
+		char *end;
+		int n = strtol(value, &end, 10);
+		if (value != end) {
+			char s[21];
+			if (snprintf(s, 21, "%d", n) >= 0) {
+				tag.AddItem(type, s);
+			}
+		}
+	} else  {
+		tag.AddItem(type, value);
+	}
 }
 
 const struct tag_handler add_tag_handler = {
_______________________________________________
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to