diff options
author | Max Kellermann <max@duempel.org> | 2009-12-16 20:49:03 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-16 20:49:03 +0100 |
commit | b89281411f237c6644e666cb439bde68ea901a52 (patch) | |
tree | c68dc44bbc44ca82cca1237db5f0063ff42e5cee /src | |
parent | 67c41033c189f1efccdc4e40a7916c2ad46e40a6 (diff) | |
download | mpd-b89281411f237c6644e666cb439bde68ea901a52.tar.gz mpd-b89281411f237c6644e666cb439bde68ea901a52.tar.xz mpd-b89281411f237c6644e666cb439bde68ea901a52.zip |
cue_tag: added function cue_tag()
Merge code from cue_tag_file() and cue_tag_string().
Diffstat (limited to '')
-rw-r--r-- | src/cue/cue_tag.c | 42 | ||||
-rw-r--r-- | src/cue/cue_tag.h | 4 |
2 files changed, 29 insertions, 17 deletions
diff --git a/src/cue/cue_tag.c b/src/cue/cue_tag.c index 70f7fc767..94797bd46 100644 --- a/src/cue/cue_tag.c +++ b/src/cue/cue_tag.c @@ -172,20 +172,15 @@ cue_tag_merge(struct tag *a, struct tag *b) } struct tag * -cue_tag_file(FILE *fp, unsigned tnum) +cue_tag(struct Cd *cd, unsigned tnum) { - struct Cd *cd; struct tag *cd_tag, *track_tag; - assert(fp != NULL); + assert(cd != NULL); if (tnum > 256) return NULL; - cd = cue_parse_file(fp); - if (cd == NULL) - return NULL; - /* tag from CDtext info */ cd_tag = cue_tag_cd(cd_get_cdtext(cd), cd_get_rem(cd)); @@ -193,16 +188,35 @@ cue_tag_file(FILE *fp, unsigned tnum) track_tag = cue_tag_track(track_get_cdtext(cd_get_track(cd, tnum)), track_get_rem(cd_get_track(cd, tnum))); + return cue_tag_merge(cd_tag, track_tag); +} + +struct tag * +cue_tag_file(FILE *fp, unsigned tnum) +{ + struct Cd *cd; + struct tag *tag; + + assert(fp != NULL); + + if (tnum > 256) + return NULL; + + cd = cue_parse_file(fp); + if (cd == NULL) + return NULL; + + tag = cue_tag(cd, tnum); cd_delete(cd); - return cue_tag_merge(cd_tag, track_tag); + return tag; } struct tag * cue_tag_string(const char *str, unsigned tnum) { struct Cd *cd; - struct tag *cd_tag, *track_tag; + struct tag *tag; assert(str != NULL); @@ -213,14 +227,8 @@ cue_tag_string(const char *str, unsigned tnum) if (cd == NULL) return NULL; - /* tag from CDtext info */ - cd_tag = cue_tag_cd(cd_get_cdtext(cd), cd_get_rem(cd)); - - /* tag from TRACKtext info */ - track_tag = cue_tag_track(track_get_cdtext(cd_get_track(cd, tnum)), - track_get_rem(cd_get_track(cd, tnum))); - + tag = cue_tag(cd, tnum); cd_delete(cd); - return cue_tag_merge(cd_tag, track_tag); + return tag; } diff --git a/src/cue/cue_tag.h b/src/cue/cue_tag.h index e5dc24fb9..1ddaa59c8 100644 --- a/src/cue/cue_tag.h +++ b/src/cue/cue_tag.h @@ -8,6 +8,10 @@ #include <stdio.h> struct tag; +struct Cd; + +struct tag * +cue_tag(struct Cd *cd, unsigned tnum); struct tag * cue_tag_file(FILE *file, unsigned tnum); |