aboutsummaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-07-01 23:05:11 +0200
committerGravatar wm4 <wm4@nowhere>2015-07-01 23:05:11 +0200
commit89f05dc7d114d805cd4d9981615cbc0b0af35863 (patch)
tree7d6cb611ae26be8da6d5f59f938892cbb4ef509e /options
parente3d85ad46dfbe8398b5e8573739b5f7222b7f1fe (diff)
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.
Diffstat (limited to 'options')
-rw-r--r--options/m_option.c9
1 files changed, 7 insertions, 2 deletions
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;
}