From 405df830d236df9708964159830406ac6c3d70a1 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 20 Nov 2017 13:34:13 +0100 Subject: [PATCH] Add SELECTION_FILTER_SWAPPED support --- bindings/solv.i | 1 + src/selection.c | 28 +++++++++++++++++++++++----- src/selection.h | 3 +++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 2a4a0e98..35466879 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1272,6 +1272,7 @@ typedef struct { static const Id SELECTION_SUBTRACT = SELECTION_SUBTRACT; static const Id SELECTION_FILTER = SELECTION_FILTER; static const Id SELECTION_FILTER_KEEP_IFEMPTY = SELECTION_FILTER_KEEP_IFEMPTY; + static const Id SELECTION_FILTER_SWAPPED = SELECTION_FILTER_SWAPPED; Selection(Pool *pool) { Selection *s; diff --git a/src/selection.c b/src/selection.c index 1059e9c4..d6a1c18d 100644 --- a/src/selection.c +++ b/src/selection.c @@ -1309,7 +1309,16 @@ selection_make(Pool *pool, Queue *selection, const char *name, int flags) else if ((flags & SELECTION_MODEBITS) == SELECTION_SUBTRACT) selection_subtract(pool, selection, &q); else if (ret || !(flags & SELECTION_FILTER_KEEP_IFEMPTY)) - selection_filter(pool, selection, &q); + { + if ((flags & SELECTION_FILTER_SWAPPED) != 0) + { + selection_filter(pool, &q, selection); + queue_free(selection); + queue_init_clone(selection, &q); + } + else + selection_filter(pool, selection, &q); + } queue_free(&q); return ret; } @@ -1635,7 +1644,16 @@ selection_make_matchdeps_common(Pool *pool, Queue *selection, const char *name, else if ((flags & SELECTION_MODEBITS) == SELECTION_FILTER) { if (ret || !(flags & SELECTION_FILTER_KEEP_IFEMPTY)) - selection_filter(pool, selection, &q); + { + if ((flags & SELECTION_FILTER_SWAPPED) != 0) + { + selection_filter(pool, &q, selection); + queue_free(selection); + queue_init_clone(selection, &q); + } + else + selection_filter(pool, selection, &q); + } } else if (ret || !(flags & SELECTION_FILTER_KEEP_IFEMPTY)) { @@ -1864,7 +1882,7 @@ selection_filter_int(Pool *pool, Queue *sel1, Queue *sel2, int invert) /* now filter sel1 with the map */ if (invert) map_invertall(&m2); - if (sel2->count == 2) /* XXX: AND all setmasks instead? */ + if (sel2->count == 2) setflags = sel2->elements[0] & SOLVER_SETMASK & ~SOLVER_NOAUTOSET; selection_filter_map(pool, sel1, &m2, setflags); map_free(&m2); @@ -1873,7 +1891,7 @@ selection_filter_int(Pool *pool, Queue *sel1, Queue *sel2, int invert) void selection_filter(Pool *pool, Queue *sel1, Queue *sel2) { - return selection_filter_int(pool, sel1, sel2, 0); + selection_filter_int(pool, sel1, sel2, 0); } void @@ -1886,7 +1904,7 @@ selection_add(Pool *pool, Queue *sel1, Queue *sel2) void selection_subtract(Pool *pool, Queue *sel1, Queue *sel2) { - return selection_filter_int(pool, sel1, sel2, 1); + selection_filter_int(pool, sel1, sel2, 1); } const char * diff --git a/src/selection.h b/src/selection.h index 8fe2d794..9938c2f9 100644 --- a/src/selection.h +++ b/src/selection.h @@ -51,9 +51,12 @@ extern "C" { #define SELECTION_ADD (1 << 28) #define SELECTION_SUBTRACT (2 << 28) #define SELECTION_FILTER (3 << 28) + #define SELECTION_MODEBITS (3 << 28) /* internal */ +/* extra SELECTION_FILTER bits */ #define SELECTION_FILTER_KEEP_IFEMPTY (1 << 30) +#define SELECTION_FILTER_SWAPPED (1 << 31) extern int selection_make(Pool *pool, Queue *selection, const char *name, int flags); -- 2.47.2