lorid

convert chordpro to pdf
git clone git://git.relim.de/lorid.git
Log | Files | Refs | README | LICENSE

commit 65a09de40a13b048c0a98f3598bfbe3c79b7281d
parent e98c90da1f85c8303a8ff1769558a5af1db72e43
Author: nibo <nibo@relim.de>
Date:   Fri,  3 Jan 2025 14:08:52 +0100

Add 'sorttitle' metadata directive

Also prefer 'sorttitle' over 'title' when
sorting the songs

Diffstat:
Mchordpro.c | 16+++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -3102,6 +3102,11 @@ cho_song_get_title(struct ChoSong *song) { struct ChoMetadata **m; for (m = song->metadata; *m; m++) { + if (!strcmp((*m)->name, "sorttitle")) { + return (*m)->value; + } + } + for (m = song->metadata; *m; m++) { if (!strcmp((*m)->name, "title")) { return (*m)->value; } @@ -3112,9 +3117,13 @@ cho_song_get_title(struct ChoSong *song) int cho_song_compare(const void *a, const void *b) { - struct ChoSong **aa = (struct ChoSong **)a; - struct ChoSong **bb = (struct ChoSong **)b; - return str_compare(cho_song_get_title(*aa), cho_song_get_title(*bb)); + struct ChoSong *song; + const char *a_title, *b_title; + song = *(struct ChoSong **)a; + a_title = cho_song_get_title(song); + song = *(struct ChoSong **)b; + b_title = cho_song_get_title(song); + return str_compare(a_title, b_title); } static void @@ -3318,6 +3327,7 @@ cho_directive_parse(const char *name) goto END; } if ( + !strcmp(name, "sorttitle") || !strcmp(name, "artist") || !strcmp(name, "composer") || !strcmp(name, "lyricist") ||