From 79a32360e76cb0739312e15299fc22941e51b64b Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Tue, 19 Nov 2024 01:30:56 +0100 Subject: Fix error in format_option_match --- src/format.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/format.c') diff --git a/src/format.c b/src/format.c index 2a2ee03..0f25084 100644 --- a/src/format.c +++ b/src/format.c @@ -92,17 +92,18 @@ static size_t format_option_cmp(const char *a, const char *b) static bool format_option_match(format_pair_t *part, const format_option_t *option) { format_mark_t mark = 0; - size_t off = 0; + size_t off = 0, tmp = 0; for (format_pair_t *ps = option->prefixes; ps != NULL && ps->string != NULL; ps++) { - off = format_option_cmp(part->string, ps->string); - if (off != 0) { + tmp = format_option_cmp(part->string, ps->string); + if (tmp != 0) { + off += tmp; mark |= ps->mark; break; } } - size_t tmp = format_option_cmp(part->string + off, option->option.string); + tmp = format_option_cmp(part->string + off, option->option.string); if (tmp == 0) return false; off += tmp; mark |= option->option.mark; @@ -110,12 +111,13 @@ static bool format_option_match(format_pair_t *part, const format_option_t *opti for (format_pair_t *ss = option->suffixes; ss != NULL && ss->string != NULL; ss++) { tmp = format_option_cmp(part->string + off, ss->string); if (tmp != 0) { + off += tmp; mark |= ss->mark; break; } } - if (part->string[tmp] != '\0') + if (part->string[off] != '\0') return false; part->mark = mark; -- cgit v1.2.3