From abf2630e7039c53126faf6585769e2abfba657dd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 10 Jan 2023 18:45:42 +0100 Subject: m + implement libfonts_do_{decoded_,}font_descriptions_match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libfonts_do_font_descriptions_match.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 libfonts_do_font_descriptions_match.c (limited to 'libfonts_do_font_descriptions_match.c') diff --git a/libfonts_do_font_descriptions_match.c b/libfonts_do_font_descriptions_match.c new file mode 100644 index 0000000..1bf6069 --- /dev/null +++ b/libfonts_do_font_descriptions_match.c @@ -0,0 +1,43 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +int +libfonts_do_font_descriptions_match(const char *desc, const char *spec) +{ + if (!spec) + return !desc; + if (!desc) + return 0; + + while (*spec && *desc) { + if (spec[0] == '*' && (!spec[1] || spec[1] == '-')) { + spec++; + while (*desc && *desc != '-') + desc++; + } else { + while (*spec && *desc && *spec != '-' && *desc != '-') { + if (*spec != *desc && *spec != '?') + return 0; + } + } + if (*spec != *desc || (*spec && *spec != '-')) + return 0; + } + + return *spec == *desc; +} + + +#else + + +int +main(void) +{ + return 0; /* XXX add test */ +} + + +#endif -- cgit v1.2.3-70-g09d2