commit 2e3a70e669bb009089ed7ab01ec0a78586749b5c
parent 69e439cf4aa92e3f2d1e5cdf4023bbe1f06e67b4
Author: nibo <nibo@relim.de>
Date: Thu, 15 Aug 2024 03:10:06 +0200
Change function names to clarify intent
Stringified enum values end in 'to_string'
while config string values end in 'to_config_string'
Diffstat:
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/chordpro.c b/chordpro.c
@@ -479,7 +479,7 @@ enum FontFamily cho_font_family_parse(const char *str)
}
}
-const char *cho_font_family_to_string(enum FontFamily font_family)
+const char *cho_font_family_to_config_string(enum FontFamily font_family)
{
switch (font_family) {
case FF_SANS:
@@ -506,7 +506,7 @@ enum FontStyle cho_font_style_parse(const char *str)
}
}
-const char *cho_font_style_to_string(enum FontStyle style)
+const char *cho_font_style_to_config_string(enum FontStyle style)
{
if (style == FS_ITALIC)
return "italic";
@@ -526,7 +526,7 @@ enum FontWeight cho_font_weight_parse(const char *str)
}
}
-const char *cho_font_weight_to_string(enum FontWeight weight)
+const char *cho_font_weight_to_config_string(enum FontWeight weight)
{
if (weight == FW_BOLD)
return "bold";
@@ -538,9 +538,9 @@ void cho_font_print_as_toml(struct Font *font, const char *section)
printf("[styles.%s.font]\n", section);
printf("\n");
printf("name = \"%s\"\n", font->name);
- printf("family = \"%s\"\n", cho_font_family_to_string(font->family));
- printf("style = \"%s\"\n", cho_font_style_to_string(font->style));
- printf("weight = \"%s\"\n", cho_font_weight_to_string(font->weight));
+ printf("family = \"%s\"\n", cho_font_family_to_config_string(font->family));
+ printf("style = \"%s\"\n", cho_font_style_to_config_string(font->style));
+ printf("weight = \"%s\"\n", cho_font_weight_to_config_string(font->weight));
printf("size = %.1f\n", font->size);
printf("\n");
}
@@ -552,9 +552,9 @@ void cho_font_print(struct Font *font)
printf("font name: %s\n", font->name);
else
printf("font name: NULL\n");
- printf("font family: %s\n", cho_font_family_to_string(font->family));
- printf("font style: %s\n", cho_font_style_to_string(font->style));
- printf("font weight: %s\n", cho_font_weight_to_string(font->weight));
+ printf("font family: %s\n", cho_font_family_to_config_string(font->family));
+ printf("font style: %s\n", cho_font_style_to_config_string(font->style));
+ printf("font weight: %s\n", cho_font_weight_to_config_string(font->weight));
printf("font size: %f\n", font->size);
printf("---- END FONT ------\n");
}
@@ -572,7 +572,7 @@ enum LineStyle cho_linestyle_parse(const char *str)
}
}
-const char *cho_linestyle_to_string(enum LineStyle linestyle)
+const char *cho_linestyle_to_config_string(enum LineStyle linestyle)
{
switch (linestyle) {
case LS_SINGLE:
@@ -1122,9 +1122,9 @@ void cho_style_print_as_toml(struct Style *style, const char *section)
{
printf("foreground_color = \"%s\"\n", cho_rgbcolor_to_string(style->foreground_color));
printf("background_color = \"%s\"\n", cho_rgbcolor_to_string(style->background_color));
- printf("underline_style = \"%s\"\n", cho_linestyle_to_string(style->underline_style));
+ printf("underline_style = \"%s\"\n", cho_linestyle_to_config_string(style->underline_style));
printf("underline_color = \"%s\"\n", cho_rgbcolor_to_string(style->underline_color));
- printf("overline_style = \"%s\"\n", cho_linestyle_to_string(style->overline_style));
+ printf("overline_style = \"%s\"\n", cho_linestyle_to_config_string(style->overline_style));
printf("overline_color = \"%s\"\n", cho_rgbcolor_to_string(style->overline_color));
printf("strikethrough = %s\n", style->strikethrough ? "true" : "false");
printf("strikethrough_color = \"%s\"\n", cho_rgbcolor_to_string(style->strikethrough_color));
@@ -2882,9 +2882,9 @@ void cho_debug_style_print(struct Style *style)
cho_font_print(style->font);
printf("foreground_color: %s\n", cho_rgbcolor_to_string(style->foreground_color));
printf("background_color: %s\n", cho_rgbcolor_to_string(style->background_color));
- printf("underline_style: %s\n", cho_linestyle_to_string(style->underline_style));
+ printf("underline_style: %s\n", cho_linestyle_to_config_string(style->underline_style));
printf("underline_color: %s\n", cho_rgbcolor_to_string(style->underline_color));
- printf("overline_style: %s\n", cho_linestyle_to_string(style->overline_style));
+ printf("overline_style: %s\n", cho_linestyle_to_config_string(style->overline_style));
printf("overline_color: %s\n", cho_rgbcolor_to_string(style->overline_color));
printf("strikethrough: %d\n", style->strikethrough);
printf("strikethrough_color: %s\n", cho_rgbcolor_to_string(style->strikethrough_color));
diff --git a/chordpro.h b/chordpro.h
@@ -272,11 +272,11 @@ struct Font *cho_font_duplicate(struct Font *font);
void cho_fonts_free(struct Font **fonts);
char *cho_font_name_normalize(const char *name);
enum FontFamily cho_font_family_parse(const char *str);
-const char *cho_font_family_to_string(enum FontFamily font_family);
+const char *cho_font_family_to_config_string(enum FontFamily font_family);
enum FontStyle cho_font_style_parse(const char *str);
-const char *cho_font_style_to_string(enum FontStyle style);
+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_string(enum FontWeight weight);
+const char *cho_font_weight_to_config_string(enum FontWeight weight);
void cho_font_print_as_toml(struct Font *font, const char *section);
#ifdef DEBUG
diff --git a/config.c b/config.c
@@ -205,7 +205,7 @@ static struct Note **config_notes_load(toml_table_t *notes, const char *system)
return NULL;
}
-static const char *config_parse_mode_to_string(enum ParseMode mode)
+static const char *config_parse_mode_to_config_string(enum ParseMode mode)
{
if (mode == PM_RELAXED) {
return "relaxed";
@@ -213,7 +213,7 @@ static const char *config_parse_mode_to_string(enum ParseMode mode)
return "strict";
}
-static const char *config_naming_system_to_string(enum NamingSystem system)
+static const char *config_naming_system_to_config_string(enum NamingSystem system)
{
switch (system) {
case NS_GERMAN:
@@ -286,8 +286,8 @@ void config_print_default(void)
i++;
}
printf("[chords]\n\n");
- printf("mode = \"%s\"\n", config_parse_mode_to_string(config->chords->mode));
- printf("system = \"%s\"\n\n", config_naming_system_to_string(config->chords->system));
+ printf("mode = \"%s\"\n", config_parse_mode_to_config_string(config->chords->mode));
+ printf("system = \"%s\"\n\n", config_naming_system_to_config_string(config->chords->system));
printf("[chords.notes]\n\n");
printf("common = [\n");
printf("\t{ note = \"C\", sharp = \"C#\" },\n");
diff --git a/out_pdf.c b/out_pdf.c
@@ -257,9 +257,9 @@ static struct Fnt *out_pdf_fnt_new(void)
static char *out_pdf_fnt_name_create(struct Font *font)
{
char *name = str_normalize(font->name);
- const char *family = cho_font_family_to_string(font->family);
- const char *style = cho_font_style_to_string(font->style);
- const char *weight = cho_font_weight_to_string(font->weight);
+ const char *family = cho_font_family_to_config_string(font->family);
+ const char *style = cho_font_style_to_config_string(font->style);
+ const char *weight = cho_font_weight_to_config_string(font->weight);
int n = 0;
int i = 0;
char *fnt_name = malloc((strlen(name) + strlen(family) + strlen(style) + strlen(weight) + 4) * sizeof(char));