lorid

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

commit 935668c89438267ae74ae1435c6657884c1b3766
parent ff258b07f7513ea9edb6afec7c80116d01d3815d
Author: nibo <nibo@relim.de>
Date:   Sat, 11 Jan 2025 17:57:29 +0100

Make chordpro.c functions static if possible

Diffstat:
Mchordpro.c | 25++++++++-----------------
Mchordpro.h | 6+-----
Mout_pdf.c | 2+-
3 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -554,7 +554,7 @@ cho_color_copy(struct RGBColor *color) return cho_rgbcolor_copy(color); } -struct Font * +static struct Font * cho_font_new(void) { struct Font *font = emalloc(sizeof(struct Font)); @@ -664,7 +664,7 @@ cho_font_weight_to_config_string(enum FontWeight weight) return font_weights[weight]; } -void +static void cho_font_print_as_toml(struct Font *font, const char *section) { printf("[output.styles.%s.font]\n", section); @@ -874,13 +874,13 @@ cho_style_copy(struct ChoStyle *style) return copy; } -struct ChoStyle * +static struct ChoStyle * cho_style_new_from_config(enum SongFragmentType ftype) { return cho_style_copy(g_config->output->styles[ftype]); } -struct ChoStyle * +static struct ChoStyle * cho_style_new_default(void) { struct ChoStyle *style = cho_style_new_from_config(g_current_ftype); @@ -909,7 +909,7 @@ cho_style_free(struct ChoStyle *style) free(style); } -struct Font * +static struct Font * cho_style_font_desc_parse(const char *str) { if (strlen(str) == 0) { @@ -1021,7 +1021,7 @@ cho_style_font_desc_parse(const char *str) return font; } -struct ChoStyle * +static struct ChoStyle * cho_style_parse(const char *tag_name, struct Attr **attrs, struct ChoStyle *inherited_style) { size_t value_len, last_char; @@ -1732,7 +1732,7 @@ cho_chord_compare(const void *a, const void *b) } size_t -cho_chords_len(struct ChoChord **chords) +cho_chord_count(struct ChoChord **chords) { if (!chords) { return 0; @@ -2901,14 +2901,6 @@ cho_text_copy(struct ChoText *text) return copy; } -int -cho_text_above_count(struct ChoLineItemAbove **text_above) -{ - int i; - for (i = 0; text_above[i]; i++); - return i; -} - static void cho_text_above_free(struct ChoLineItemAbove *text_above) { @@ -3005,7 +2997,6 @@ cho_line_free(struct ChoLine *line) free(line); } -/* TODO: Does this still work? */ static int cho_line_compute_text_above_position(struct ChoLine *line, int ly, int te) { @@ -3102,7 +3093,7 @@ cho_song_count(struct ChoSong **songs) return i; } -const char * +static const char * cho_song_get_title(struct ChoSong *song) { struct ChoMetadata **m; diff --git a/chordpro.h b/chordpro.h @@ -336,12 +336,11 @@ int cho_song_compare(const void *a, const void *b); void cho_songs_free(struct ChoSong **song); int cho_line_item_count(struct ChoLineItem **items); -int cho_text_above_count(struct ChoLineItemAbove **text_above); char *cho_chord_name_generate(struct ChoChord *chord); void cho_chords_add(struct ChoChord ***chords, struct ChoChord *chord); bool cho_chords_has(struct ChoChord **chords, struct ChoChord *chord); -size_t cho_chords_len(struct ChoChord **chords); +size_t cho_chord_count(struct ChoChord **chords); int cho_chord_compare(const void *a, const void *b); void cho_chords_free(struct ChoChord **chords); @@ -350,7 +349,6 @@ const char *cho_metadata_get(struct ChoMetadata **metadata, const char *name); struct ChoStyle *cho_style_new(void); void cho_style_free(struct ChoStyle *style); struct ChoStyle *cho_style_copy(struct ChoStyle *style); -struct Font *cho_style_font_desc_parse(const char *str); void cho_style_print_as_toml(struct ChoStyle *style, const char *section); struct RGBColor *cho_color_parse(const char *str); @@ -359,7 +357,6 @@ enum LineStyle cho_linestyle_parse(const char *str); // const char *cho_image_name_create(struct ChoImage *image, const char *dirname); -struct Font *cho_font_new(void); void cho_font_free(struct Font *font); void cho_font_print(struct Font *font); struct Font *cho_font_copy(struct Font *font); @@ -371,7 +368,6 @@ enum FontStyle cho_font_style_parse(const char *str); const char *cho_font_style_to_config_string(enum FontStyle style); enum FontWeight cho_font_weight_parse(const char *str); const char *cho_font_weight_to_config_string(enum FontWeight weight); -void cho_font_print_as_toml(struct Font *font, const char *section); void cho_debug_style_print(struct ChoStyle *style); // void cho_debug_songs_print(struct ChoSong **songs); diff --git a/out_pdf.c b/out_pdf.c @@ -1947,7 +1947,7 @@ pdf_content_create( return false; } if (chords) { - qsort(chords, cho_chords_len(chords), sizeof(struct ChoChord *), cho_chord_compare); + qsort(chords, cho_chord_count(chords), sizeof(struct ChoChord *), cho_chord_compare); dgrams = chord_diagrams_create(config, &chords, songs[s]->diagrams); dgrams_begin = dgrams; while (*dgrams) {