]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
refactor complex deps code a bit
authorMichael Schroeder <mls@suse.de>
Thu, 19 Mar 2015 15:42:16 +0000 (16:42 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 19 Mar 2015 15:42:16 +0000 (16:42 +0100)
src/cplxdeps.c
src/rules.c

index 9e421942023962285f3f91ff11852a0723eecf52..ad9457e6a032d2cbbd68340e8f7fc06a8f2cbf04 100644 (file)
@@ -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;
@@ -151,7 +178,7 @@ normalize_dep(Pool *pool, Id dep, Queue *bq, int todnf)
 
          /* 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*/
+         /* 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);
          if (r == 0)
            {
@@ -284,27 +311,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;
 }
index 88c6d5b4ddd265081b600ce04aef1546b6bd07ca..039eb867e89ca3a28a01e379e2004a5232216b55 100644 (file)
@@ -528,6 +528,17 @@ add_package_link(Solver *solv, Solvable *s, Map *m, Queue *workq)
 
 #ifdef ENABLE_COMPLEX_DEPS
 
+static inline Id
+pool_idstowhatprovides(Pool *pool, int count, Id *elements)
+{
+  /* hack: create fake queue 'q' so that we can call pool_queuetowhatprovides */
+  Queue q;
+  memset(&q, 0, sizeof(q));
+  q.count = count;
+  q.elements = elements;
+  return pool_queuetowhatprovides(pool, &q);
+}
+
 static void
 add_complex_deprules(Solver *solv, Id p, Id dep, int type, int dontfix, Queue *workq, Map *m)
 {
@@ -667,12 +678,7 @@ add_complex_deprules(Solver *solv, Id p, Id dep, int type, int dontfix, Queue *w
              break;
          if (j == qcnt)
            {
-             /* hack: create fake queue 'q' so that we can call pool_queuetowhatprovides */
-             Queue q;
-             memset(&q, 0, sizeof(q));
-             q.count = qcnt - 1;
-             q.elements = qele + 1;
-             addpkgrule(solv, qele[0], pool_queuetowhatprovides(pool, &q), type, dep);
+             addpkgrule(solv, qele[0], pool_idstowhatprovides(pool, qcnt - 1, qele + 1), type, dep);
              if (m)
                for (j = 0; j < qcnt; j++)
                  if (qele[j] > 0 && !MAPTST(m, qele[j]))