+ Reldep *rd;
+ const char *s2;
+ int needparens;
+ struct oplist *op;
+
+ if (!ISRELDEP(id))
+ {
+ s2 = testcase_id2str(pool, id, 1);
+ s = pool_tmpappend(pool, s, s2, 0);
+ pool_freetmpspace(pool, s2);
+ return s;
+ }
+ rd = GETRELDEP(pool, id);
+
+ /* check for special shortcuts */
+ if (rd->flags == REL_NAMESPACE && !ISRELDEP(rd->name) && !strncmp(pool_id2str(pool, rd->name), "namespace:", 10))
+ {
+ s = pool_tmpappend(pool, s, pool_id2str(pool, rd->name), "(");
+ s = testcase_dep2str_complex(pool, s, rd->evr, 0);
+ return pool_tmpappend(pool, s, ")", 0);
+ }
+ if (rd->flags == REL_MULTIARCH && !ISRELDEP(rd->name) && rd->evr == ARCH_ANY)
+ {
+ /* append special :any suffix */
+ s2 = testcase_id2str(pool, rd->name, 1);
+ s = pool_tmpappend(pool, s, s2, ":any");
+ pool_freetmpspace(pool, s2);
+ return s;
+ }
+
+ needparens = 0;
+ if (ISRELDEP(rd->name))
+ {
+ Reldep *rd2 = GETRELDEP(pool, rd->name);
+ needparens = 1;
+ if (rd->flags > 7 && rd->flags != REL_COMPAT && rd2->flags && rd2->flags <= 7)
+ needparens = 0;
+ }
+
+ if (addparens)
+ s = pool_tmpappend(pool, s, "(", 0);
+ s = testcase_dep2str_complex(pool, s, rd->name, needparens);
+
+ for (op = oplist; op->flags; op++)
+ if (rd->flags == op->flags)
+ break;
+ if (op->flags)
+ {
+ s = pool_tmpappend(pool, s, " ", op->opname);
+ s = pool_tmpappend(pool, s, " ", 0);
+ }
+ else
+ {
+ char buf[64];
+ sprintf(buf, " <%u> ", rd->flags);
+ s = pool_tmpappend(pool, s, buf, 0);
+ }
+
+ needparens = 0;
+ if (ISRELDEP(rd->evr))
+ {
+ Reldep *rd2 = GETRELDEP(pool, rd->evr);
+ needparens = 1;
+ if (rd->flags > 7 && rd2->flags && rd2->flags <= 7)
+ needparens = 0;
+ if (rd->flags == REL_AND && rd2->flags == REL_AND)
+ needparens = 0; /* chain */
+ if (rd->flags == REL_OR && rd2->flags == REL_OR)
+ needparens = 0; /* chain */
+ if (rd->flags > 0 && rd->flags < 8 && rd2->flags == REL_COMPAT)
+ needparens = 0; /* chain */
+ }
+ if (!ISRELDEP(rd->evr))
+ {
+ s2 = testcase_id2str(pool, rd->evr, 0);
+ s = pool_tmpappend(pool, s, s2, 0);
+ pool_freetmpspace(pool, s2);
+ }
+ else
+ s = (char *)testcase_dep2str_complex(pool, s, rd->evr, needparens);
+ if (addparens)
+ s = pool_tmpappend(pool, s, ")", 0);
+ return s;
+}
+
+const char *
+testcase_dep2str(Pool *pool, Id id)
+{
+ char *s;
+ if (!ISRELDEP(id))
+ return testcase_id2str(pool, id, 1);
+ s = pool_alloctmpspace(pool, 1);
+ *s = 0;
+ return testcase_dep2str_complex(pool, s, id, 0);
+}
+