commit 7973fc49bbab8ccb02218b82c53cff02ee75b596
parent ca0e6a7f4860dc14135ddebdd7823158da1045b3
Author: nibo <nibo@relim.de>
Date: Sun, 8 Sep 2024 19:00:23 +0200
Return error when song has no title
Diffstat:
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/chordpro.c b/chordpro.c
@@ -2832,6 +2832,23 @@ struct ChoSong **cho_songs_parse(FILE *fp, struct Config *config)
so++;
songs = realloc(songs, (so+1) * sizeof(struct ChoSong *));
songs[so] = NULL;
+ bool exist_title = false;
+ for (so = 0; songs[so]; so++) {
+ for (m = 0; songs[so]->metadata[m]; m++) {
+ if (
+ !strcmp(songs[so]->metadata[m]->name, "title") &&
+ songs[so]->metadata[m]->value &&
+ strcmp(songs[so]->metadata[m]->value, "") != 0
+ ) {
+ exist_title = true;
+ }
+ }
+ if (!exist_title) {
+ fprintf(stderr, "ERR: Song no. %d has no title.\n", so+1);
+ return NULL;
+ }
+ exist_title = false;
+ }
return songs;
}
diff --git a/todo b/todo
@@ -11,8 +11,8 @@ chords
chord diagrams
strict and relaxed parsing makes no difference!?
make parser bulletproof
- should it just parse valid input correctly
- and crash on invalid input?
+ parse \r\n also as linebreak
+ should it just parse valid input correctly and crash on invalid input?
parse environment directive value when: label="Verse 1"
# pdf output