shithub: cuefs

Download patch

ref: 693f78971543823312587d81f1d5dab1fe21e84a
parent: b2fa9c0cbf6951af0a0b06a48e9ee2f8fbcb6bb5
author: Tevo <estevan.cps@gmail.com>
date: Sat Feb 13 21:59:21 EST 2021

Handle ISRC properly

--- a/cue.c
+++ b/cue.c
@@ -59,6 +59,7 @@
 			free(st);
 		}
 		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?
@@ -163,11 +164,19 @@
 }
 
 void
+setisrc(Cuesheet *c, char *isrc)
+{
+	if(c->curentry == nil)
+		parserfatal("flag outside of track");
+	c->curentry->isrc = isrc;
+}
+
+void
 addfile(Cuesheet *c, char *name, int format)
 {
 	AFile *new;
 
-	new = emalloc(sizeof(*new));
+	new = emallocz(sizeof(*new), 1);
 	new->name	= strdup(name);
 	new->type	= format;
 	new->actual	= actualformat(new);
--- a/cue.l
+++ b/cue.l
@@ -4,6 +4,8 @@
 
 %}
 
+%a 4096
+
 %s MCNNO
 %%
 \".*\"			{
@@ -24,6 +26,13 @@
 					yylval.str = strdup(yytext); 
 					BEGIN(INITIAL);
 					return MCN; 
+				}
+
+
+[A-Z][A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9][0-9][0-9][0-9]	{	/* FIXME this is ridiculous, but [A-Z]{5}[0-9]{7} just refuses to work */
+					yylval.str = strdup(yytext);
+					BEGIN(INITIAL);
+					return ISRCCODE;
 				}
 
 [0-9]+			{
--- a/cue.y
+++ b/cue.y
@@ -18,7 +18,7 @@
 }
 
 %token <i>   INTEGER
-%token <str> STRING MCN
+%token <str> STRING MCN ISRCCODE
 
 %type <i>    filetype
 %type <time> timestamp
@@ -26,7 +26,7 @@
 
 %token CATALOG CDTEXTFILE FLAGS DCP CHAN4 PREEMPH SCMS INDEX
 %token ISRC PERFORMER POSTGAP PREGAP SONGWRITER TITLE TRACK
-%token FILE FWAVE FMP3 FAIFF FBINARY FMOTOROLA AUDIO MCN
+%token FILE FWAVE FMP3 FAIFF FBINARY FMOTOROLA AUDIO MCN ISRCCODE
 
 %%
 cuesheet:
@@ -41,6 +41,7 @@
 	| INDEX INTEGER timestamp	{ settimestamp(cursheet, $2, $3); }
 	| CATALOG MCN				{ setmcn(cursheet, $2); }
 	| FLAGS flags				{ setflags(cursheet, $2); }
+	| ISRC ISRCCODE			{ setisrc(cursheet, $2); }
 	;
 
 flags:						{ $$ = 0; }
--- a/cuefs.h
+++ b/cuefs.h
@@ -1,6 +1,6 @@
 
 extern char *fname;
-extern int infd;
+extern int infd, outfd;
 
 /* lex/yacc */
 int yylex(void);
@@ -75,7 +75,7 @@
 	Start *starts;
 	AFile *file;
 	int index, flags;
-	char *title, *performer;
+	char *title, *performer, *isrc;
 	Entry *next;
 };
 
@@ -95,6 +95,7 @@
 Cuesheet* newsheet(void);
 void freesheet(Cuesheet*);
 
+void setisrc(Cuesheet*, char*);
 void setflags(Cuesheet*, int);
 void setmcn(Cuesheet*, char*);
 void setperformer(Cuesheet*, char*);
--- a/main.c
+++ b/main.c
@@ -53,6 +53,8 @@
 		usage();
 	} ARGEND;
 
+	outfd = 1;
+
 	if(argc > 1)
 		usage();
 
--- a/mkfile
+++ b/mkfile
@@ -31,7 +31,8 @@
 
 </sys/src/cmd/mkone
 
-LFLAGS=-9
+LFLAGS=-9n
+YFLAGS=$YFLAGS
 
 install:V: ${RC:%=$RCBIN/%} ${MAN:%=/sys/man/%}