shithub: cuefs

Download patch

ref: 2d0983f7322153b0c6ed729479976e31de8e4541
parent: c402d678bf078f5aed978229c400a9f1362824b1
author: Tevo <estevan.cps@gmail.com>
date: Sat Feb 13 22:21:23 EST 2021

Handle SONGWRITER properly (!)

--- a/cue.c	Sat Feb 13 22:10:49 2021
+++ b/cue.c	Sat Feb 13 22:21:23 2021
@@ -60,10 +60,8 @@
 		}
 		free(e->title);
 		free(e->isrc);
-		/*
-		 * TODO maybe we should keep track of every performer in
-		 * the Cuesheet, even if they're "song only" performers?
-		 */
+		if(e->songwriter != s->songwriter)
+			free(e->songwriter);
 		if(e->performer != s->performer)
 			free(e->performer);
 
@@ -81,6 +79,7 @@
 
 	free(s->title);
 	free(s->performer);
+	free(s->songwriter);
 	free(s->mcn);
 
 	free(s);
@@ -134,6 +133,23 @@
 }
 
 void
+setsongwriter(Cuesheet *c, char *composer)
+{
+	composer = strdup(composer);
+	if(c->curentry == nil)
+	{
+		free(c->songwriter);
+		c->songwriter = composer;
+	}
+	else
+	{
+		if(c->curentry->songwriter != c->songwriter)
+			free(c->curentry->songwriter);
+		c->curentry->songwriter = composer;
+	}
+}
+
+void
 settitle(Cuesheet *c, char *title)
 {
 	title = strdup(title);
@@ -215,6 +231,7 @@
 	new->sheet = c;
 	new->file = c->curfile;
 	new->performer = c->performer;
+	new->songwriter = c->songwriter;
 	new->index = i;
 
 	if(c->entries == nil)
--- a/cue.y	Sat Feb 13 22:10:49 2021
+++ b/cue.y	Sat Feb 13 22:21:23 2021
@@ -44,6 +44,7 @@
 	| ISRC ISRCCODE			{ setisrc(cursheet, $2); }
 	| PREGAP timestamp			{ setpregap(cursheet, $2); }
 	| POSTGAP timestamp		{ setpostgap(cursheet, $2); }
+	| SONGWRITER STRING		{ setsongwriter(cursheet, $2); }
 	;
 
 flags:						{ $$ = 0; }
--- a/cuefs.h	Sat Feb 13 22:10:49 2021
+++ b/cuefs.h	Sat Feb 13 22:21:23 2021
@@ -75,14 +75,14 @@
 	Start *starts;
 	AFile *file;
 	int index, flags;
-	char *title, *performer, *isrc;
+	char *title, *performer, *songwriter, *isrc;
 	Timestamp pregap, postgap;
 	Entry *next;
 };
 
 struct Cuesheet
 {
-	char *title, *performer, *mcn;
+	char *title, *performer, *songwriter, *mcn;
 	AFile *files, *curfile;
 	Entry *entries, *curentry;
 };
@@ -102,6 +102,7 @@
 void setflags(Cuesheet*, int);
 void setmcn(Cuesheet*, char*);
 void setperformer(Cuesheet*, char*);
+void setsongwriter(Cuesheet*, char*);
 void settitle(Cuesheet*, char*);
 void addfile(Cuesheet*, char*, int);
 void addnewtrack(Cuesheet*, int);
--- a/fs.c	Sat Feb 13 22:10:49 2021
+++ b/fs.c	Sat Feb 13 22:21:23 2021
@@ -392,6 +392,8 @@
 	ret = tagflag(&c, ret, esmprint("TRACKNUMBER=%d", e->index));
 	if(e->performer != nil)
 		ret = tagflag(&c, ret, esmprint("ARTIST=%s", e->performer));
+	if(e->songwriter != nil)
+		ret = tagflag(&c, ret, esmprint("COMPOSER=%s", e->songwriter));
 	if(e->isrc != nil)
 		ret = tagflag(&c, ret, esmprint("ISRC=%s", e->isrc));
 	if(e->sheet->performer != nil)