Package: mp3gain Version: 1.5.1-2 Severity: normal Tags: patch when mp3gain is run with -s i (write gain info as id3 tag) then mp3gain upgrades any pre-existing tags to id3 v2.4.
this is fine and works well on existing v2.x tags, but messes up things a bit if only v1 tags are encountered: mp3gain then primes the new tags from v1 info, which is all fixed-length - but mp3gain does not remove the trailing whitespace introduced by that copying (v2.x strings are variable length, null-terminated). the simple attached patch makes mp3gain behave cleanly by removing any trailing whitespace from copied-over v1 tags. regards az
#! /bin/sh /usr/share/dpatch/dpatch-run ## 08_trailingspace.dpatch by <a...@debian.org> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: when copying tags from v1, remove trailing spaces. @DPATCH@ diff -urNad mp3gain-1.5.1~/id3tag.c mp3gain-1.5.1/id3tag.c --- mp3gain-1.5.1~/id3tag.c 2010-01-09 13:20:05.000000000 +1000 +++ mp3gain-1.5.1/id3tag.c 2010-01-09 13:21:27.683931496 +1000 @@ -823,7 +823,7 @@ static int id3_parse_v1_tag(FILE *f, struct ID3v2TagStruct *tag) { unsigned char buf[128]; - char sbuf[32]; + char sbuf[32],*p; struct ID3v2FrameStruct **pframe; @@ -850,6 +850,8 @@ if (buf[3] != '\0') { memcpy(sbuf, buf + 3, 30); sbuf[30] = '\0'; + /* get rid of trailing spaces */ + for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0'); *pframe = id3_make_frame("TIT2", "bs", 0, sbuf); pframe = &((*pframe)->next); } @@ -858,6 +860,9 @@ if (buf[33] != '\0') { memcpy(sbuf, buf + 33, 30); sbuf[30] = '\0'; + /* get rid of trailing spaces */ + for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0'); + DBG(("fixed v1 artist: \"%s\"\n",sbuf)); *pframe = id3_make_frame("TPE1", "bs", 0, sbuf); pframe = &((*pframe)->next); } @@ -866,6 +871,8 @@ if (buf[63] != '\0') { memcpy(sbuf, buf + 63, 30); sbuf[30] = '\0'; + /* get rid of trailing spaces */ + for(p=sbuf+29; *p==' ' && p>=sbuf; *p--='\0'); *pframe = id3_make_frame("TALB", "bs", 0, sbuf); pframe = &((*pframe)->next); }