Use has_prefix() instead of strncmp() throughout

This is safer than hardcoded string lengths.
This commit is contained in:
Simon Ser 2025-01-07 13:21:56 +01:00 committed by Kenny Levinsen
parent c55dff95bc
commit 0c60d1581f
19 changed files with 44 additions and 49 deletions

View file

@ -13,9 +13,9 @@ struct cmd_results *cmd_font(int argc, char **argv) {
char *font = join_args(argv, argc);
free(config->font);
if (strncmp(font, "pango:", 6) == 0) {
if (has_prefix(font, "pango:")) {
config->pango_markup = true;
config->font = strdup(font + 6);
config->font = strdup(font + strlen("pango:"));
free(font);
} else {
config->pango_markup = false;