diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-02-24 20:03:14 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-02-24 20:03:14 +0000 |
commit | 9c2e7fd3626b87157cf06411dec43c00b49e962a (patch) | |
tree | 840a5e79cdcda01db7fae8a3fd4ef0e2163d679a | |
parent | 910d6e507a01395800e17a148cc49198c70e35b0 (diff) |
Use macro for better readability of adjust_mp3entry().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29390 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/metadata.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index 4e4ffb6ad2..1680fd760b 100644 --- a/apps/metadata.c +++ b/apps/metadata.c @@ -379,40 +379,33 @@ void strip_tags(int handle_id) #endif /* CONFIG_CODEC == SWCODEC */ #endif /* ! __PCTOOL__ */ +#define MOVE_ENTRY(x) if (x) x += offset; + void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig) { long offset; if (orig > dest) - offset = - ((size_t)orig - (size_t)dest); + offset = -((size_t)orig - (size_t)dest); else - offset = (size_t)dest - (size_t)orig; - - if (entry->title) - entry->title += offset; - if (entry->artist) - entry->artist += offset; - if (entry->album) - entry->album += offset; - if (entry->genre_string > (char*)orig - && entry->genre_string < (char*)orig + sizeof(struct mp3entry)) + offset = ((size_t)dest - (size_t)orig); + + MOVE_ENTRY(entry->title) + MOVE_ENTRY(entry->artist) + MOVE_ENTRY(entry->album) + + if (entry->genre_string > (char*)orig && + entry->genre_string < (char*)orig + sizeof(struct mp3entry)) /* Don't adjust that if it points to an entry of the "genres" array */ entry->genre_string += offset; - if (entry->track_string) - entry->track_string += offset; - if (entry->disc_string) - entry->disc_string += offset; - if (entry->year_string) - entry->year_string += offset; - if (entry->composer) - entry->composer += offset; - if (entry->comment) - entry->comment += offset; - if (entry->albumartist) - entry->albumartist += offset; - if (entry->grouping) - entry->grouping += offset; - if (entry->mb_track_id) - entry->mb_track_id += offset; + + MOVE_ENTRY(entry->track_string) + MOVE_ENTRY(entry->disc_string) + MOVE_ENTRY(entry->year_string) + MOVE_ENTRY(entry->composer) + MOVE_ENTRY(entry->comment) + MOVE_ENTRY(entry->albumartist) + MOVE_ENTRY(entry->grouping) + MOVE_ENTRY(entry->mb_track_id) } void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig) |