Skip to content

Commit

Permalink
package_query: Fix filter_version with non EQ comparator
Browse files Browse the repository at this point in the history
The current implementation of the filter_version and filter_release
filters always uses the cmp_eq comparator. This means that these filters
only work with EQ and NEQ comparisons. The patch fixes these filters to
work correctly with LT, LTE, GT, and GTE comparisons as well.
  • Loading branch information
m-blaha authored and j-mracek committed Jan 16, 2024
1 parent 692245f commit 50277b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libdnf5/rpm/package_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ inline static void filter_version_internal(
std::string vr(pool.split_evr(pool.get_evr(candidate_id)).v);
vr.append("-0");
int cmp = pool.evrcmp_str(vr.c_str(), formatted_c_pattern, EVRCMP_COMPARE);
if (cmp_eq(cmp)) {
if (cmp_fnc(cmp)) {
filter_result.add_unsafe(candidate_id);
}
}
Expand Down Expand Up @@ -1050,7 +1050,7 @@ inline static void filter_release_internal(
std::string vr("0-");
vr.append(pool.split_evr(pool.get_evr(candidate_id)).r);
int cmp = pool.evrcmp_str(vr.c_str(), formatted_c_pattern, EVRCMP_COMPARE);
if (cmp_eq(cmp)) {
if (cmp_fnc(cmp)) {
filter_result.add_unsafe(candidate_id);
}
}
Expand Down

0 comments on commit 50277b6

Please sign in to comment.