song/TagSongFilter: apply negation properly to multiple tag values
The old implementation didn't make a lot of sense; the "!=" operator was not actually the opposite of "==". Closes https://github.com/MusicPlayerDaemon/MPD/issues/505
This commit is contained in:
parent
0acb55cde5
commit
3bf521d5ca
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
|||||||
ver 0.21.6 (not yet released)
|
ver 0.21.6 (not yet released)
|
||||||
* protocol
|
* protocol
|
||||||
- allow loading playlists specified as absolute filesystem paths
|
- allow loading playlists specified as absolute filesystem paths
|
||||||
|
- fix negated filter expressions with multiple tag values
|
||||||
- fix "list" with filter expression
|
- fix "list" with filter expression
|
||||||
* input
|
* input
|
||||||
- cdio_paranoia: fix build failure due to missing #include
|
- cdio_paranoia: fix build failure due to missing #include
|
||||||
|
@ -43,8 +43,8 @@ TagSongFilter::Match(const Tag &tag) const noexcept
|
|||||||
visited_types[i.type] = true;
|
visited_types[i.type] = true;
|
||||||
|
|
||||||
if ((type == TAG_NUM_OF_ITEM_TYPES || i.type == type) &&
|
if ((type == TAG_NUM_OF_ITEM_TYPES || i.type == type) &&
|
||||||
filter.Match(i.value))
|
filter.MatchWithoutNegation(i.value))
|
||||||
return true;
|
return !filter.IsNegated();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type < TAG_NUM_OF_ITEM_TYPES && !visited_types[type]) {
|
if (type < TAG_NUM_OF_ITEM_TYPES && !visited_types[type]) {
|
||||||
@ -61,7 +61,7 @@ TagSongFilter::Match(const Tag &tag) const noexcept
|
|||||||
|
|
||||||
for (const auto &item : tag) {
|
for (const auto &item : tag) {
|
||||||
if (item.type == tag2 &&
|
if (item.type == tag2 &&
|
||||||
filter.Match(item.value)) {
|
filter.MatchWithoutNegation(item.value)) {
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ TagSongFilter::Match(const Tag &tag) const noexcept
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}))
|
}))
|
||||||
return result;
|
return result != filter.IsNegated();
|
||||||
|
|
||||||
/* If the search critieron was not visited during the
|
/* If the search critieron was not visited during the
|
||||||
sweep through the song's tag, it means this field
|
sweep through the song's tag, it means this field
|
||||||
@ -78,10 +78,10 @@ TagSongFilter::Match(const Tag &tag) const noexcept
|
|||||||
then it's a match as well and we should return
|
then it's a match as well and we should return
|
||||||
true. */
|
true. */
|
||||||
if (filter.empty())
|
if (filter.empty())
|
||||||
return true;
|
return !filter.IsNegated();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return filter.IsNegated();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
Reference in New Issue
Block a user