]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add SELECTION_FILTER_SWAPPED support
authorMichael Schroeder <mls@suse.de>
Mon, 20 Nov 2017 12:34:13 +0000 (13:34 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 20 Nov 2017 12:34:13 +0000 (13:34 +0100)
bindings/solv.i
src/selection.c
src/selection.h

index 2a4a0e988c6cd8ff0a9d2bb343604c6f0ed8a22d..35466879056b8464031c780622c2ddd7e130b815 100644 (file)
@@ -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;
index 1059e9c49354bda3281c3b96b3d5a09afba38117..d6a1c18dc4767d0d210e8816a78c61e2b57b75af 100644 (file)
@@ -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 *
index 8fe2d7944236b522afc7b8d95c26bc4d4c4989a6..9938c2f925ed515385c79f2da2fc657ae2d4ffe1 100644 (file)
@@ -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);