summaryrefslogtreecommitdiff
path: root/src/cplxdeps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cplxdeps.c')
-rw-r--r--src/cplxdeps.c119
1 files changed, 71 insertions, 48 deletions
diff --git a/src/cplxdeps.c b/src/cplxdeps.c
index 9e42194..1be6868 100644
--- a/src/cplxdeps.c
+++ b/src/cplxdeps.c
@@ -68,6 +68,33 @@ expand_simpledeps(Pool *pool, Queue *bq, int start, int split)
return newsplit;
}
+#ifdef CPLXDEBUG
+static void
+print_depblocks(Pool *pool, Queue *bq, int start)
+{
+ int i;
+
+ for (i = start; i < bq->count; i++)
+ {
+ if (bq->elements[i] == pool->nsolvables)
+ {
+ Id *dp = pool->whatprovidesdata + bq->elements[++i];
+ printf(" (");
+ while (*dp)
+ printf(" %s", pool_solvid2str(pool, *dp++));
+ printf(" )");
+ }
+ else if (bq->elements[i] > 0)
+ printf(" %s", pool_solvid2str(pool, bq->elements[i]));
+ else if (bq->elements[i] < 0)
+ printf(" -%s", pool_solvid2str(pool, -bq->elements[i]));
+ else
+ printf(" ||");
+ }
+ printf("\n");
+}
+#endif
+
/* invert all literals in the blocks. note that this also turns DNF into CNF and vice versa */
static void
invert_depblocks(Pool *pool, Queue *bq, int start)
@@ -82,7 +109,7 @@ invert_depblocks(Pool *pool, Queue *bq, int start)
bq->elements[i] = -bq->elements[i];
continue;
}
- /* end of block reached, reorder */
+ /* end of block reached, reverse */
if (i - 1 > j)
{
int k;
@@ -104,11 +131,12 @@ invert_depblocks(Pool *pool, Queue *bq, int start)
* -1: at least one block
*/
static int
-normalize_dep(Pool *pool, Id dep, Queue *bq, int todnf)
+normalize_dep(Pool *pool, Id dep, Queue *bq, int flags)
{
int bqcnt = bq->count;
int bqcnt2;
- Id dp;
+ int todnf = flags & CPLXDEPS_TODNF ? 1 : 0;
+ Id p, dp;
#ifdef CPLXDEBUG
printf("normalize_dep %s todnf:%d\n", pool_dep2str(pool, dep), todnf);
@@ -118,58 +146,60 @@ normalize_dep(Pool *pool, Id dep, Queue *bq, int todnf)
Reldep *rd = GETRELDEP(pool, dep);
if (rd->flags == REL_AND || rd->flags == REL_OR || rd->flags == REL_COND)
{
- int flags = rd->flags;
+ int rdflags = rd->flags;
int r, mode;
/* in inverted mode, COND means AND. otherwise it means OR NOT */
- if (flags == REL_COND && todnf)
- flags = REL_AND;
- mode = flags == REL_AND ? 0 : 1;
+ if (rdflags == REL_COND && todnf)
+ rdflags = REL_AND;
+ mode = rdflags == REL_AND ? 0 : 1;
/* get blocks of first argument */
- r = normalize_dep(pool, rd->name, bq, todnf);
+ r = normalize_dep(pool, rd->name, bq, flags);
if (r == 0)
{
- if (flags == REL_AND)
+ if (rdflags == REL_AND && (flags & CPLXDEPS_DONTFIX) == 0)
return 0;
- if (flags == REL_COND)
+ if (rdflags == REL_COND)
{
- r = normalize_dep(pool, rd->evr, bq, todnf ^ 1);
+ r = normalize_dep(pool, rd->evr, bq, (flags ^ CPLXDEPS_TODNF) & ~CPLXDEPS_DONTFIX);
if (r == 0 || r == 1)
return r == 0 ? 1 : 0;
invert_depblocks(pool, bq, bqcnt); /* invert block for COND */
return r;
}
- return normalize_dep(pool, rd->evr, bq, todnf);
+ return normalize_dep(pool, rd->evr, bq, flags);
}
if (r == 1)
{
- if (flags != REL_AND)
+ if (rdflags != REL_AND)
return 1;
- return normalize_dep(pool, rd->evr, bq, todnf);
+ return normalize_dep(pool, rd->evr, bq, flags);
}
/* get blocks of second argument */
bqcnt2 = bq->count;
- /* COND is OR with NEG on evr block, so we invert the todnf flag in that case*/
- r = normalize_dep(pool, rd->evr, bq, flags == REL_COND ? todnf ^ 1 : todnf);
+ /* COND is OR with NEG on evr block, so we invert the todnf flag in that case */
+ r = normalize_dep(pool, rd->evr, bq, rdflags == REL_COND ? ((flags ^ CPLXDEPS_TODNF) & ~CPLXDEPS_DONTFIX) : flags);
if (r == 0)
{
- if (flags == REL_OR)
+ if (rdflags == REL_OR)
+ return -1;
+ if (rdflags == REL_AND && (flags & CPLXDEPS_DONTFIX) != 0)
return -1;
queue_truncate(bq, bqcnt);
- return flags == REL_COND ? 1 : 0;
+ return rdflags == REL_COND ? 1 : 0;
}
if (r == 1)
{
- if (flags == REL_OR)
+ if (rdflags == REL_OR)
{
queue_truncate(bq, bqcnt);
return 1;
}
return -1;
}
- if (flags == REL_COND)
+ if (rdflags == REL_COND)
invert_depblocks(pool, bq, bqcnt2); /* invert 2nd block */
if (mode == todnf)
{
@@ -247,16 +277,29 @@ normalize_dep(Pool *pool, Id dep, Queue *bq, int todnf)
return dp == 2 ? 1 : 0;
if (pool->whatprovidesdata[dp] == SYSTEMSOLVABLE)
return 1;
- if (todnf)
+ bqcnt = bq->count;
+ if ((flags & CPLXDEPS_NAME) != 0)
{
- for (; pool->whatprovidesdata[dp]; dp++)
- queue_push2(bq, pool->whatprovidesdata[dp], 0);
+ while ((p = pool->whatprovidesdata[dp++]) != 0)
+ {
+ if (!pool_match_nevr(pool, pool->solvables + p, dep))
+ continue;
+ queue_push(bq, p);
+ if (todnf)
+ queue_push(bq, 0);
+ }
}
- else
+ else if (todnf)
{
- queue_push2(bq, pool->nsolvables, dp); /* not yet expanded marker */
- queue_push(bq, 0);
+ while ((p = pool->whatprovidesdata[dp++]) != 0)
+ queue_push2(bq, p, 0);
}
+ else
+ queue_push2(bq, pool->nsolvables, dp); /* not yet expanded marker + offset */
+ if (bq->count == bqcnt)
+ return 0; /* no provider */
+ if (!todnf)
+ queue_push(bq, 0); /* finish block */
return -1;
}
@@ -265,7 +308,7 @@ pool_normalize_complex_dep(Pool *pool, Id dep, Queue *bq, int flags)
{
int i, bqcnt = bq->count;
- i = normalize_dep(pool, dep, bq, (flags & CPLXDEPS_TODNF) ? 1 : 0);
+ i = normalize_dep(pool, dep, bq, flags);
if ((flags & CPLXDEPS_EXPAND) != 0)
{
if (i != 0 && i != 1)
@@ -284,27 +327,7 @@ pool_normalize_complex_dep(Pool *pool, Id dep, Queue *bq, int flags)
else if (i == 1)
printf("ALL\n");
else
- {
- for (i = bqcnt; i < bq->count; i++)
- {
- if (bq->elements[i] == pool->nsolvables)
- {
- Id *dp = pool->whatprovidesdata + bq->elements[++i];
- printf(" (");
- while (*dp)
- printf(" %s", pool_solvid2str(pool, *dp++));
- printf(" )");
- }
- else if (bq->elements[i] > 0)
- printf(" %s", pool_solvid2str(pool, bq->elements[i]));
- else if (bq->elements[i] < 0)
- printf(" -%s", pool_solvid2str(pool, -bq->elements[i]));
- else
- printf(" ||");
- }
- printf("\n");
- i = -1;
- }
+ print_depblocks(pool, bq, bqcnt);
#endif
return i;
}