lorid

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

commit 4af09ce456b6fff07ea961a5117f3ef1e119a5c1
parent ec7555903f9aa96f70cad05acd9c05e9a7098259
Author: nibo <nibo@relim.de>
Date:   Sun,  6 Oct 2024 11:39:19 +0200

Change 'strcmp() == 0' to '!strcmp()'

Diffstat:
Mchordpro.c | 258++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mconfig.c | 16++++++++--------
Mfontconfig.c | 2+-
Mout_pdf.c | 10+++++-----
4 files changed, 143 insertions(+), 143 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -422,39 +422,39 @@ struct RGBColor *cho_color_parse(const char *str) fprintf(stderr, "cho_rgbcolor_parse failed.\n"); return NULL; } - } else if (strcmp(str, "red") == 0) { + } else if (!strcmp(str, "red")) { color->red = 255; color->green = 48; color->blue = 48; - } else if (strcmp(str, "green") == 0) { + } else if (!strcmp(str, "green")) { color->red = 0; color->green = 126; color->blue = 0; - } else if (strcmp(str, "blue") == 0) { + } else if (!strcmp(str, "blue")) { color->red = 0; color->green = 0; color->blue = 255; - } else if (strcmp(str, "yellow") == 0) { + } else if (!strcmp(str, "yellow")) { color->red = 255; color->green = 255; color->blue = 0; - } else if (strcmp(str, "magenta") == 0) { + } else if (!strcmp(str, "magenta")) { color->red = 255; color->green = 48; color->blue = 255; - } else if (strcmp(str, "cyan") == 0) { + } else if (!strcmp(str, "cyan")) { color->red = 82; color->green = 255; color->blue = 255; - } else if (strcmp(str, "white") == 0) { + } else if (!strcmp(str, "white")) { color->red = 255; color->green = 255; color->blue = 255; - } else if (strcmp(str, "grey") == 0) { + } else if (!strcmp(str, "grey")) { color->red = 191; color->green = 191; color->blue = 191; - } else if (strcmp(str, "black") == 0) { + } else if (!strcmp(str, "black")) { color->red = 0; color->green = 0; color->blue = 0; @@ -589,11 +589,11 @@ void cho_font_print(struct Font *font) enum LineStyle cho_linestyle_parse(const char *str) { - if (strcmp(str, "single") == 0) { + if (!strcmp(str, "single")) { return LS_SINGLE; - } else if (strcmp(str, "double") == 0) { + } else if (!strcmp(str, "double")) { return LS_DOUBLE; - } else if (strcmp(str, "none") == 0) { + } else if (!strcmp(str, "none")) { return LS_NONE; } else { return LS_EMPTY; @@ -936,32 +936,32 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct style = cho_style_duplicate(inherited_style); else style = cho_style_new_default(); - if (strcmp(tag_name, "span") == 0) { + if (!strcmp(tag_name, "span")) { int a = 0; while (attrs[a] != NULL) { - if (strcmp(attrs[a]->name, "font_desc") == 0) { + if (!strcmp(attrs[a]->name, "font_desc")) { font = cho_style_font_desc_parse(attrs[a]->value); if (font) { cho_font_free(style->font); style->font = font; } } else if ( - strcmp(attrs[a]->name, "font_family") == 0 || - strcmp(attrs[a]->name, "face") == 0 + !strcmp(attrs[a]->name, "font_family") || + !strcmp(attrs[a]->name, "face") ) { - if (strcmp(attrs[a]->value, "normal") == 0) { + if (!strcmp(attrs[a]->value, "normal")) { style->font->family = FF_NORMAL; - } else if (strcmp(attrs[a]->value, "sans") == 0) { + } else if (!strcmp(attrs[a]->value, "sans")) { style->font->family = FF_SANS; - } else if (strcmp(attrs[a]->value, "serif") == 0) { + } else if (!strcmp(attrs[a]->value, "serif")) { style->font->family = FF_SERIF; - } else if (strcmp(attrs[a]->value, "monospace") == 0) { + } else if (!strcmp(attrs[a]->value, "monospace")) { style->font->family = FF_MONOSPACE; } else { fprintf(stderr, "ERR: Invalid value in attribute 'font_family/face'.\n"); return NULL; } - } else if (strcmp(attrs[a]->name, "size") == 0) { + } else if (!strcmp(attrs[a]->name, "size")) { value_len = strlen(attrs[a]->value); last_char = value_len - 1; if (attrs[a]->value[last_char] == '%') { @@ -986,54 +986,54 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct fprintf(stderr, "ERR: Invalid number in attribute 'size'.\n"); return NULL; } - } else if (strcmp(attrs[a]->value, "xx-small") == 0) { + } else if (!strcmp(attrs[a]->value, "xx-small")) { style->font->size *= 0.8; style->font->size *= 0.8; style->font->size *= 0.8; - } else if (strcmp(attrs[a]->value, "x-small") == 0) { + } else if (!strcmp(attrs[a]->value, "x-small")) { style->font->size *= 0.8; style->font->size *= 0.8; - } else if (strcmp(attrs[a]->value, "small") == 0) { + } else if (!strcmp(attrs[a]->value, "small")) { style->font->size *= 0.8; - // } else if (strcmp(attrs[a]->value, "medium") == 0) { - } else if (strcmp(attrs[a]->value, "large") == 0) { + // } else if (!strcmp(attrs[a]->value, "medium")) { + } else if (!strcmp(attrs[a]->value, "large")) { style->font->size *= 1.8; - } else if (strcmp(attrs[a]->value, "x-large") == 0) { + } else if (!strcmp(attrs[a]->value, "x-large")) { style->font->size *= 1.8; style->font->size *= 1.8; - } else if (strcmp(attrs[a]->value, "xx-large") == 0) { + } else if (!strcmp(attrs[a]->value, "xx-large")) { style->font->size *= 1.8; style->font->size *= 1.8; style->font->size *= 1.8; - } else if (strcmp(attrs[a]->value, "larger") == 0) { + } else if (!strcmp(attrs[a]->value, "larger")) { style->font->size *= 1.8; - } else if (strcmp(attrs[a]->value, "smaller") == 0) { + } else if (!strcmp(attrs[a]->value, "smaller")) { style->font->size *= 0.8; } else { fprintf(stderr, "ERR: Invalid value '%s' for the attribute 'size'.\n", attrs[a]->value); return NULL; } - } else if (strcmp(attrs[a]->name, "style") == 0) { - if (strcmp(attrs[a]->value, "normal") == 0) { + } else if (!strcmp(attrs[a]->name, "style")) { + if (!strcmp(attrs[a]->value, "normal")) { style->font->style = FS_ROMAN; - } else if (strcmp(attrs[a]->value, "oblique") == 0) { + } else if (!strcmp(attrs[a]->value, "oblique")) { style->font->style = FS_OBLIQUE; - } else if (strcmp(attrs[a]->value, "italic") == 0) { + } else if (!strcmp(attrs[a]->value, "italic")) { style->font->style = FS_ITALIC; } else { fprintf(stderr, "ERR: Invalid value in attribute 'style'.\n"); return NULL; } - } else if (strcmp(attrs[a]->name, "weight") == 0) { - if (strcmp(attrs[a]->value, "normal") == 0) { + } else if (!strcmp(attrs[a]->name, "weight")) { + if (!strcmp(attrs[a]->value, "normal")) { style->font->weight = FW_REGULAR; - } else if (strcmp(attrs[a]->value, "bold") == 0) { + } else if (!strcmp(attrs[a]->value, "bold")) { style->font->weight = FW_BOLD; } else { fprintf(stderr, "ERR: Invalid value in attribute 'weight'.\n"); return NULL; } - } else if (strcmp(attrs[a]->name, "foreground") == 0) { + } else if (!strcmp(attrs[a]->name, "foreground")) { rgb_color = cho_color_parse(attrs[a]->value); if (!rgb_color) { fprintf(stderr, "cho_color_parse failed.\n"); @@ -1042,7 +1042,7 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct free(style->foreground_color); style->foreground_color = rgb_color; } - } else if (strcmp(attrs[a]->name, "background") == 0) { + } else if (!strcmp(attrs[a]->name, "background")) { rgb_color = cho_color_parse(attrs[a]->value); if (!rgb_color) { fprintf(stderr, "cho_color_parse failed.\n"); @@ -1051,18 +1051,18 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct free(style->background_color); style->background_color = rgb_color; } - } else if (strcmp(attrs[a]->name, "underline") == 0) { - if (strcmp(attrs[a]->value, "single") == 0) { + } else if (!strcmp(attrs[a]->name, "underline")) { + if (!strcmp(attrs[a]->value, "single")) { style->underline_style = LS_SINGLE; - } else if (strcmp(attrs[a]->value, "double") == 0) { + } else if (!strcmp(attrs[a]->value, "double")) { style->underline_style = LS_DOUBLE; - } else if (strcmp(attrs[a]->value, "none") == 0) { + } else if (!strcmp(attrs[a]->value, "none")) { style->underline_style = LS_NONE; } else { fprintf(stderr, "ERR: Invalid value in attribute 'underline'.\n"); return NULL; } - } else if (strcmp(attrs[a]->name, "underline_colour") == 0) { + } else if (!strcmp(attrs[a]->name, "underline_colour")) { rgb_color = cho_color_parse(attrs[a]->value); if (!rgb_color) { fprintf(stderr, "cho_color_parse failed.\n"); @@ -1071,18 +1071,18 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct free(style->underline_color); style->underline_color = rgb_color; } - } else if (strcmp(attrs[a]->name, "overline") == 0) { - if (strcmp(attrs[a]->value, "single") == 0) { + } else if (!strcmp(attrs[a]->name, "overline")) { + if (!strcmp(attrs[a]->value, "single")) { style->overline_style = LS_SINGLE; - } else if (strcmp(attrs[a]->value, "double") == 0) { + } else if (!strcmp(attrs[a]->value, "double")) { style->overline_style = LS_DOUBLE; - } else if (strcmp(attrs[a]->value, "none") == 0) { + } else if (!strcmp(attrs[a]->value, "none")) { style->overline_style = LS_NONE; } else { fprintf(stderr, "ERR: Invalid value in attribute 'overline'.\n"); return NULL; } - } else if (strcmp(attrs[a]->name, "overline_colour") == 0) { + } else if (!strcmp(attrs[a]->name, "overline_colour")) { rgb_color = cho_color_parse(attrs[a]->value); if (!rgb_color) { fprintf(stderr, "cho_color_parse failed.\n"); @@ -1091,7 +1091,7 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct free(style->overline_color); style->overline_color = rgb_color; } - } else if (strcmp(attrs[a]->name, "rise") == 0) { + } else if (!strcmp(attrs[a]->name, "rise")) { value_len = strlen(attrs[a]->value); last_char = value_len - 1; if (attrs[a]->value[0] == '-') { @@ -1145,16 +1145,16 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct return NULL; } } - } else if (strcmp(attrs[a]->name, "strikethrough") == 0) { - if (strcmp(attrs[a]->value, "true") == 0) { + } else if (!strcmp(attrs[a]->name, "strikethrough")) { + if (!strcmp(attrs[a]->value, "true")) { style->strikethrough = true; - } else if (strcmp(attrs[a]->value, "false") == 0) { + } else if (!strcmp(attrs[a]->value, "false")) { style->strikethrough = false; } else { fprintf(stderr, "ERR: Invalid value '%s' in attribute 'strikethrough'.\n", attrs[a]->value); return NULL; } - } else if (strcmp(attrs[a]->name, "strikethrough_colour") == 0) { + } else if (!strcmp(attrs[a]->name, "strikethrough_colour")) { rgb_color = cho_color_parse(attrs[a]->value); if (!rgb_color) { fprintf(stderr, "cho_color_parse failed.\n"); @@ -1163,7 +1163,7 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct free(style->strikethrough_color); style->strikethrough_color = rgb_color; } - } else if (strcmp(attrs[a]->name, "href") == 0) { + } else if (!strcmp(attrs[a]->name, "href")) { style->href = strdup(attrs[a]->value); } else { fprintf(stderr, "ERR: Invalid attribute '%s'.\n", attrs[a]->name); @@ -1171,25 +1171,25 @@ struct Style *cho_style_parse(const char *tag_name, struct Attr **attrs, struct } a++; } - } else if (strcmp(tag_name, "b") == 0) { + } else if (!strcmp(tag_name, "b")) { style->font->weight = FW_BOLD; - } else if (strcmp(tag_name, "big") == 0) { + } else if (!strcmp(tag_name, "big")) { style->font->size *= 0.8; - } else if (strcmp(tag_name, "i") == 0) { + } else if (!strcmp(tag_name, "i")) { style->font->style = FS_ITALIC; - } else if (strcmp(tag_name, "s") == 0) { + } else if (!strcmp(tag_name, "s")) { style->strikethrough = true; - } else if (strcmp(tag_name, "sub") == 0) { + } else if (!strcmp(tag_name, "sub")) { style->font->size *= 0.8; style->rise = -style->font->size * 0.3; - } else if (strcmp(tag_name, "sup") == 0) { + } else if (!strcmp(tag_name, "sup")) { style->font->size *= 0.8; style->rise = style->font->size * 0.3; - } else if (strcmp(tag_name, "small") == 0) { + } else if (!strcmp(tag_name, "small")) { style->font->size *= 0.8; - } else if (strcmp(tag_name, "tt") == 0) { + } else if (!strcmp(tag_name, "tt")) { style->font->family = FF_MONOSPACE; - } else if (strcmp(tag_name, "u") == 0) { + } else if (!strcmp(tag_name, "u")) { style->underline_style = LS_SINGLE; } else { fprintf(stderr, "ERR: Invalid tag name '%s'.\n", tag_name); @@ -1328,7 +1328,7 @@ static bool cho_tag_close_last_unclosed(const char *tag_name, struct Tag **tags, { int i = last_index; while (i >= 0) { - if (strcmp(tags[i]->name, tag_name) == 0 && !tags[i]->is_closed) { + if (!strcmp(tags[i]->name, tag_name) && !tags[i]->is_closed) { tags[i]->is_closed = true; return true; } @@ -1368,7 +1368,7 @@ const char *cho_metadata_get(struct ChoMetadata **metadata, const char *name) { int m; for (m = 0; metadata[m]; m++) { - if (strcmp(metadata[m]->name, name) == 0) { + if (!strcmp(metadata[m]->name, name)) { return metadata[m]->value; } } @@ -1657,19 +1657,19 @@ static int cho_chord_bass_parse(const char *str, struct ChoChord *chord) for (i = 0; i<7; i++) { sharp = g_config->parser->notes[i]->sharp; out_sharp = g_config->output->notes[i]->sharp; - if (sharp && strcmp((char *)&str[1], sharp) == 0) { + if (sharp && !strcmp((char *)&str[1], sharp)) { chord->bass = strdup(out_sharp); return strlen(sharp) + 1; } flat = g_config->parser->notes[i]->flat; out_flat = g_config->output->notes[i]->flat; - if (flat && strcmp((char *)&str[1], flat) == 0) { + if (flat && !strcmp((char *)&str[1], flat)) { chord->bass = strdup(out_flat); return strlen(flat) + 1; } note = g_config->parser->notes[i]->note; out_note = g_config->parser->notes[i]->note; - if (strcmp((char *)&str[1], note) == 0) { + if (!strcmp((char *)&str[1], note)) { chord->bass = strdup(out_note); return strlen(note) + 1; } @@ -2067,8 +2067,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) struct ChoDirective *directive = cho_directive_new(); int i = 0; if ( - strcmp(name, environment_directives[START_OF_CHORUS]) == 0 || - strcmp(name, environment_directives[SOC]) == 0 + !strcmp(name, environment_directives[START_OF_CHORUS]) || + !strcmp(name, environment_directives[SOC]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_START; @@ -2076,8 +2076,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_CHORUS; goto END; } else if ( - strcmp(name, environment_directives[END_OF_CHORUS]) == 0 || - strcmp(name, environment_directives[EOC]) == 0 + !strcmp(name, environment_directives[END_OF_CHORUS]) || + !strcmp(name, environment_directives[EOC]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_END; @@ -2085,8 +2085,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(name, environment_directives[START_OF_VERSE]) == 0 || - strcmp(name, environment_directives[SOV]) == 0 + !strcmp(name, environment_directives[START_OF_VERSE]) || + !strcmp(name, environment_directives[SOV]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_START; @@ -2094,8 +2094,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(name, environment_directives[END_OF_VERSE]) == 0 || - strcmp(name, environment_directives[EOV]) == 0 + !strcmp(name, environment_directives[END_OF_VERSE]) || + !strcmp(name, environment_directives[EOV]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_END; @@ -2103,8 +2103,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(name, environment_directives[START_OF_BRIDGE]) == 0 || - strcmp(name, environment_directives[SOB]) == 0 + !strcmp(name, environment_directives[START_OF_BRIDGE]) || + !strcmp(name, environment_directives[SOB]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_START; @@ -2112,8 +2112,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(name, environment_directives[END_OF_BRIDGE]) == 0 || - strcmp(name, environment_directives[EOB]) == 0 + !strcmp(name, environment_directives[END_OF_BRIDGE]) || + !strcmp(name, environment_directives[EOB]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_END; @@ -2121,8 +2121,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(name, environment_directives[START_OF_TAB]) == 0 || - strcmp(name, environment_directives[SOT]) == 0 + !strcmp(name, environment_directives[START_OF_TAB]) || + !strcmp(name, environment_directives[SOT]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_START; @@ -2130,8 +2130,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TAB; goto END; } else if ( - strcmp(name, environment_directives[END_OF_TAB]) == 0 || - strcmp(name, environment_directives[EOT]) == 0 + !strcmp(name, environment_directives[END_OF_TAB]) || + !strcmp(name, environment_directives[EOT]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_END; @@ -2139,8 +2139,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(name, environment_directives[START_OF_GRID]) == 0 || - strcmp(name, environment_directives[SOG]) == 0 + !strcmp(name, environment_directives[START_OF_GRID]) || + !strcmp(name, environment_directives[SOG]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_START; @@ -2148,8 +2148,8 @@ static struct ChoDirective *cho_directive_parse(const char *name) directive->ftype = SF_GRID; goto END; } else if ( - strcmp(name, environment_directives[END_OF_GRID]) == 0 || - strcmp(name, environment_directives[EOG]) == 0 + !strcmp(name, environment_directives[END_OF_GRID]) || + !strcmp(name, environment_directives[EOG]) ) { directive->dtype = DT_ENVIRONMENT; directive->position = POS_END; @@ -2158,7 +2158,7 @@ static struct ChoDirective *cho_directive_parse(const char *name) goto END; } while (metadata_directives[i] != NULL) { - if (strcmp(metadata_directives[i], name) == 0) { + if (!strcmp(metadata_directives[i], name)) { directive->dtype = DT_METADATA; goto END; } @@ -2166,34 +2166,34 @@ static struct ChoDirective *cho_directive_parse(const char *name) } i = 0; if ( - strcmp(formatting_directives[COMMENT], name) == 0 || - strcmp(formatting_directives[C], name) == 0 || - strcmp(formatting_directives[HIGHLIGHT], name) == 0 + !strcmp(formatting_directives[COMMENT], name) || + !strcmp(formatting_directives[C], name) || + !strcmp(formatting_directives[HIGHLIGHT], name) ) { directive->style->background_color = cho_rgbcolor_new(228, 228, 228); directive->dtype = DT_FORMATTING; goto END; } else if ( - strcmp(formatting_directives[COMMENT_ITALIC], name) == 0 || - strcmp(formatting_directives[CI], name) == 0 + !strcmp(formatting_directives[COMMENT_ITALIC], name) || + !strcmp(formatting_directives[CI], name) ) { directive->style->font->style = FS_ITALIC; directive->dtype = DT_FORMATTING; goto END; } else if ( - strcmp(formatting_directives[COMMENT_BOX], name) == 0 || - strcmp(formatting_directives[CB], name) == 0 + !strcmp(formatting_directives[COMMENT_BOX], name) || + !strcmp(formatting_directives[CB], name) ) { directive->style->boxed = true; directive->dtype = DT_FORMATTING; goto END; } - if (strcmp(image_directives[IMAGE], name) == 0) { + if (!strcmp(image_directives[IMAGE], name)) { directive->dtype = DT_IMAGE; goto END; } while (preamble_directives[i] != NULL) { - if (strcmp(preamble_directives[i], name) == 0) { + if (!strcmp(preamble_directives[i], name)) { directive->dtype = DT_PREAMBLE; directive->stype = ST_NEWSONG; goto END; @@ -2201,122 +2201,122 @@ static struct ChoDirective *cho_directive_parse(const char *name) i++; } if ( - strcmp(font_directives[CHORDFONT], name) == 0 || - strcmp(font_directives[CF], name) == 0 + !strcmp(font_directives[CHORDFONT], name) || + !strcmp(font_directives[CF], name) ) { directive->dtype = DT_FONT; directive->sprop = SPT_FONT; directive->ftype = SF_CHORD; goto END; } else if ( - strcmp(font_directives[CHORDSIZE], name) == 0 || - strcmp(font_directives[CS], name) == 0 + !strcmp(font_directives[CHORDSIZE], name) || + !strcmp(font_directives[CS], name) ) { directive->dtype = DT_FONT; directive->sprop = SPT_SIZE; directive->ftype = SF_CHORD; goto END; - } else if (strcmp(font_directives[CHORDCOLOR], name) == 0) { + } else if (!strcmp(font_directives[CHORDCOLOR], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_COLOR; directive->ftype = SF_CHORD; goto END; - } else if (strcmp(font_directives[CHORUSFONT], name) == 0) { + } else if (!strcmp(font_directives[CHORUSFONT], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_FONT; directive->ftype = SF_CHORUS; goto END; - } else if (strcmp(font_directives[CHORUSSIZE], name) == 0) { + } else if (!strcmp(font_directives[CHORUSSIZE], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_SIZE; directive->ftype = SF_CHORUS; goto END; - } else if (strcmp(font_directives[CHORUSCOLOR], name) == 0) { + } else if (!strcmp(font_directives[CHORUSCOLOR], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_COLOR; directive->ftype = SF_CHORUS; goto END; - } else if (strcmp(font_directives[GRIDFONT], name) == 0) { + } else if (!strcmp(font_directives[GRIDFONT], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_FONT; directive->ftype = SF_GRID; goto END; - } else if (strcmp(font_directives[GRIDSIZE], name) == 0) { + } else if (!strcmp(font_directives[GRIDSIZE], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_SIZE; directive->ftype = SF_GRID; goto END; - } else if (strcmp(font_directives[GRIDCOLOR], name) == 0) { + } else if (!strcmp(font_directives[GRIDCOLOR], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_COLOR; directive->ftype = SF_GRID; goto END; - } else if (strcmp(font_directives[TABFONT], name) == 0) { + } else if (!strcmp(font_directives[TABFONT], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_FONT; directive->ftype = SF_TAB; goto END; - } else if (strcmp(font_directives[TABSIZE], name) == 0) { + } else if (!strcmp(font_directives[TABSIZE], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_SIZE; directive->ftype = SF_TAB; goto END; - } else if (strcmp(font_directives[TABCOLOR], name) == 0) { + } else if (!strcmp(font_directives[TABCOLOR], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_COLOR; directive->ftype = SF_TAB; goto END; } else if ( - strcmp(font_directives[TEXTFONT], name) == 0 || - strcmp(font_directives[TF], name) == 0 + !strcmp(font_directives[TEXTFONT], name) || + !strcmp(font_directives[TF], name) ) { directive->dtype = DT_FONT; directive->sprop = SPT_FONT; directive->ftype = SF_TEXT; goto END; } else if ( - strcmp(font_directives[TEXTSIZE], name) == 0 || - strcmp(font_directives[TS], name) == 0 + !strcmp(font_directives[TEXTSIZE], name) || + !strcmp(font_directives[TS], name) ) { directive->dtype = DT_FONT; directive->sprop = SPT_SIZE; directive->ftype = SF_TEXT; goto END; - } else if (strcmp(font_directives[TEXTCOLOR], name) == 0) { + } else if (!strcmp(font_directives[TEXTCOLOR], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_COLOR; directive->ftype = SF_TEXT; goto END; - } else if (strcmp(font_directives[TITLEFONT], name) == 0) { + } else if (!strcmp(font_directives[TITLEFONT], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_FONT; directive->ftype = SF_TITLE; goto END; - } else if (strcmp(font_directives[TITLESIZE], name) == 0) { + } else if (!strcmp(font_directives[TITLESIZE], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_SIZE; directive->ftype = SF_TITLE; goto END; - } else if (strcmp(font_directives[TITLECOLOR], name) == 0) { + } else if (!strcmp(font_directives[TITLECOLOR], name)) { directive->dtype = DT_FONT; directive->sprop = SPT_COLOR; directive->ftype = SF_TITLE; goto END; } - if (strcmp(chord_directives[TRANSPOSE], name) == 0) { + if (!strcmp(chord_directives[TRANSPOSE], name)) { directive->dtype = DT_CHORD; goto END; } if ( - strcmp(output_directives[NEW_PAGE], name) == 0 || - strcmp(output_directives[NP], name) == 0 + !strcmp(output_directives[NEW_PAGE], name) || + !strcmp(output_directives[NP], name) ) { directive->dtype = DT_OUTPUT; directive->btype = BT_PAGE; goto END; } else if ( - strcmp(output_directives[COLUMN_BREAK], name) == 0 || - strcmp(output_directives[COLB], name) == 0 + !strcmp(output_directives[COLUMN_BREAK], name) || + !strcmp(output_directives[COLB], name) ) { directive->dtype = DT_OUTPUT; directive->btype = BT_COLUMN; @@ -2690,7 +2690,7 @@ struct ChoSong **cho_songs_parse(FILE *fp, struct Config *config) } break; case DT_METADATA: - if (strcmp(directive_name, "meta") == 0) { + if (!strcmp(directive_name, "meta")) { metadata = cho_metadata_split(directive_value); if (metadata) { songs[so]->metadata = realloc(songs[so]->metadata, (m+1) * sizeof(struct ChoMetadata *)); @@ -2705,12 +2705,12 @@ struct ChoSong **cho_songs_parse(FILE *fp, struct Config *config) songs[so]->metadata[m] = cho_metadata_new(); songs[so]->metadata[m]->name = strdup(directive_name); songs[so]->metadata[m]->value = str_remove_leading_whitespace(directive_value); - if (strcmp(directive_name, "title") == 0) { + if (!strcmp(directive_name, "title")) { g_prev_ftype = g_current_ftype; g_current_ftype = SF_TITLE; songs[so]->metadata[m]->style = cho_style_new_default(); g_current_ftype = g_prev_ftype; - } else if (strcmp(directive_name, "subtitle") == 0) { + } else if (!strcmp(directive_name, "subtitle")) { g_prev_ftype = g_current_ftype; g_current_ftype = SF_SUBTITLE; songs[so]->metadata[m]->style = cho_style_new_default(); diff --git a/config.c b/config.c @@ -121,7 +121,7 @@ struct PrintableItem *config_printable_item_get(struct PrintableItem **items, co { int i = 0; while (items[i] != NULL) { - if (strcmp(items[i]->name, name) == 0) { + if (!strcmp(items[i]->name, name)) { return items[i]; } i++; @@ -131,17 +131,17 @@ struct PrintableItem *config_printable_item_get(struct PrintableItem **items, co static enum NamingSystem config_naming_system_parse(const char *str) { - if (strcmp(str, naming_systems[NS_COMMON]) == 0 || strcmp(str, "dutch") == 0) { + if (!strcmp(str, naming_systems[NS_COMMON]) || !strcmp(str, "dutch")) { return NS_COMMON; - } else if (strcmp(str, naming_systems[NS_GERMAN]) == 0) { + } else if (!strcmp(str, naming_systems[NS_GERMAN])) { return NS_GERMAN; - } else if (strcmp(str, naming_systems[NS_SCANDINAVIAN]) == 0) { + } else if (!strcmp(str, naming_systems[NS_SCANDINAVIAN])) { return NS_SCANDINAVIAN; - } else if (strcmp(str, naming_systems[NS_LATIN]) == 0) { + } else if (!strcmp(str, naming_systems[NS_LATIN])) { return NS_LATIN; - } else if (strcmp(str, naming_systems[NS_ROMAN]) == 0) { + } else if (!strcmp(str, naming_systems[NS_ROMAN])) { return NS_ROMAN; - } else if (strcmp(str, naming_systems[NS_NASHVILLE]) == 0) { + } else if (!strcmp(str, naming_systems[NS_NASHVILLE])) { return NS_NASHVILLE; } else { return NS_CUSTOM; @@ -545,7 +545,7 @@ static bool config_is_style(const char *str) { int i = 0; while (g_valid_styles[i] != NULL) { - if (strcmp(g_valid_styles[i], str) == 0) + if (!strcmp(g_valid_styles[i], str)) return true; i++; } diff --git a/fontconfig.c b/fontconfig.c @@ -15,7 +15,7 @@ static bool file_extension_is_ttc(const char *filepath) } i++; } - if (strcmp(&filepath[mark+1], "ttc") == 0) + if (!strcmp(&filepath[mark+1], "ttc")) return true; return false; } diff --git a/out_pdf.c b/out_pdf.c @@ -18,7 +18,7 @@ static pdfio_obj_t *out_pdf_fnt_obj_get_by_name(const char *name) { int i = 0; while (g_fonts[i] != NULL) { - if (strcmp(g_fonts[i]->name, name) == 0) + if (!strcmp(g_fonts[i]->name, name)) return g_fonts[i]->font; i++; } @@ -36,7 +36,7 @@ static bool out_pdf_font_add_if_not_in(struct Font *font, struct Font ***array) } else { while ((*array)[a] != NULL) { if ( - strcmp((*array)[a]->name, font->name) == 0 && + !strcmp((*array)[a]->name, font->name) && (*array)[a]->family == font->family && (*array)[a]->style == font->style && (*array)[a]->weight == font->weight @@ -313,7 +313,7 @@ static void out_pdf_fnt_add(struct Fnt *fnt, struct Fnt ***array) static bool out_pdf_font_set(pdfio_stream_t *stream, struct Font *font) { char *name = out_pdf_fnt_name_create(font); - if (strcmp(name, g_current_font_name) == 0 && font->size == g_current_font_size) { + if (!strcmp(name, g_current_font_name) && font->size == g_current_font_size) { free(name); return true; } @@ -737,7 +737,7 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) text[t] = malloc(sizeof(struct Text)); text[t]->lines = NULL; for (m = 0; songs[so]->metadata[m]; m++) { - if (strcmp(songs[so]->metadata[m]->name, "title") == 0) { + if (!strcmp(songs[so]->metadata[m]->name, "title")) { fits = text_fits(songs[so]->metadata[m]->value, songs[so]->metadata[m]->style); if (fits == B_ERROR) { fprintf(stderr, "text_fits failed.\n"); @@ -784,7 +784,7 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) } } for (m = 0; songs[so]->metadata[m]; m++) { - if (strcmp(songs[so]->metadata[m]->name, "subtitle") == 0) { + if (!strcmp(songs[so]->metadata[m]->name, "subtitle")) { fits = text_fits(songs[so]->metadata[m]->value, songs[so]->metadata[m]->style); if (fits == B_ERROR) { fprintf(stderr, "text_fits failed.\n");