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;
}
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))
{
/* 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);
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
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 *
#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);