From 89f05dc7d114d805cd4d9981615cbc0b0af35863 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 1 Jul 2015 23:05:11 +0200 Subject: options: fix conversion of flags to strings This flags stuff tried to be too clever - if there are overlapping flags (e.g. exclusive or combined flags), the one matching with most bits has to be chosen. This fixes logging of the seek command. E.g. "relative" and "absolute" overlap to make them exclusive, but "relative" was always printed as it happened to match first. --- options/m_option.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'options') diff --git a/options/m_option.c b/options/m_option.c index 7d95d93fb9..020bd371ce 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -743,13 +743,18 @@ static int apply_flag(const struct m_option *opt, int *val, bstr flag) static const char *find_next_flag(const struct m_option *opt, int *val) { + struct m_opt_choice_alternatives *best = NULL; struct m_opt_choice_alternatives *alt; for (alt = opt->priv; alt->name; alt++) { if (alt->value && (alt->value & (*val)) == alt->value) { - *val = *val & ~(unsigned)alt->value; - return alt->name; + if (!best || av_popcount64(alt->value) > av_popcount64(best->value)) + best = alt; } } + if (best) { + *val = *val & ~(unsigned)best->value; + return best->name; + } *val = 0; // if there are still flags left, there's not much we can do return NULL; } -- cgit v1.2.3