lorid

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

commit 5a6cd3087a38aad1e01c42fd429a00827ef024ac
parent 47798453e83e62ffbd99a95f8cb282c4e987d878
Author: nibo <nibo@relim.de>
Date:   Sun, 29 Sep 2024 11:42:27 +0200

Parse song correctly when no ending line break exists

Diffstat:
Mchordpro.c | 23++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -2826,15 +2826,28 @@ struct ChoSong **cho_songs_parse(FILE *fp, struct Config *config) e++; } free(tags); - cho_line_item_free(songs[so]->sections[se]->lines[li]->lyrics[ly]); - free(songs[so]->sections[se]->lines[li]->lyrics); - free(songs[so]->sections[se]->lines[li]->text_above); - free(songs[so]->sections[se]->lines[li]); + if (songs[so]->sections[se]->lines[li]->lyrics[ly]->text) { + songs[so]->sections[se]->lines[li]->lyrics[ly]->text = realloc(songs[so]->sections[se]->lines[li]->lyrics[ly]->text, (te+1) * sizeof(char)); + songs[so]->sections[se]->lines[li]->lyrics[ly]->text[te] = 0; + ly++; + songs[so]->sections[se]->lines[li]->lyrics = realloc(songs[so]->sections[se]->lines[li]->lyrics, (ly+1) * sizeof(struct ChoLineItem *)); + songs[so]->sections[se]->lines[li]->lyrics[ly] = NULL; + songs[so]->sections[se]->lines[li]->text_above = realloc(songs[so]->sections[se]->lines[li]->text_above, (c+1) * sizeof(struct ChoLineItemAbove *)); + songs[so]->sections[se]->lines[li]->text_above[c] = NULL; + li++; + songs[so]->sections[se]->lines = realloc(songs[so]->sections[se]->lines, (li+1) * sizeof(struct ChoLine *)); + songs[so]->sections[se]->lines[li] = NULL; + } else { + cho_line_item_free(songs[so]->sections[se]->lines[li]->lyrics[ly]); + free(songs[so]->sections[se]->lines[li]->lyrics); + free(songs[so]->sections[se]->lines[li]->text_above); + free(songs[so]->sections[se]->lines[li]); + songs[so]->sections[se]->lines[li] = NULL; + } if (!cho_style_reset_default()) { fprintf(stderr, "cho_style_reset_default failed.\n"); return NULL; } - songs[so]->sections[se]->lines[li] = NULL; songs[so]->metadata = realloc(songs[so]->metadata, (m+1) * sizeof(struct ChoMetadata *)); songs[so]->metadata[m] = NULL; se++;