lorid

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

commit b3a116831e8abf8553f93971fa94b755a6b51504
parent afc140535cb1270958e031b53ed85ba48103f39c
Author: nibo <nibo@relim.de>
Date:   Thu, 15 Aug 2024 03:06:03 +0200

config: load default config->chords->notes

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

diff --git a/config.c b/config.c @@ -111,6 +111,15 @@ static void config_note_free(struct Note *note) free(note); } +static void config_notes_free(struct Note **notes) +{ + int n; + for (n = 0; notes[n]; n++) { + config_note_free(notes[n]); + } + free(notes); +} + static struct Note **config_notes_new_default(enum NamingSystem system) { struct Note **notes_default = malloc(8 * sizeof(struct Note *)); @@ -482,6 +491,7 @@ static bool config_is_style(const char *str) struct Config *config_load(const char *filepath) { struct Config *config = config_load_default(); + config->chords->notes = config_notes_new_default(NS_COMMON); char *home = getenv("HOME"); char path[26+strlen(home)+1]; if (!filepath) { @@ -540,7 +550,10 @@ struct Config *config_load(const char *filepath) toml_table_t *notes = toml_table_table(chords, "notes"); if (notes) { notes_custom = config_notes_load(notes, value.u.s); - if (!notes_custom) { + if (notes_custom) { + config_notes_free(config->chords->notes); + config->chords->notes = notes_custom; + } else { fprintf(stderr, "config_notes_load failed.\n"); fprintf(stderr, "WARN: Continuing with default naming system 'common'.\n"); } @@ -558,11 +571,11 @@ struct Config *config_load(const char *filepath) free(value.u.s); } } - if (notes_custom) { + /* if (notes_custom) { config->chords->notes = notes_custom; } else { config->chords->notes = config_notes_new_default(config->chords->system); - } + } */ toml_free(table); fclose(fp); return config;