+ 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);
+ else
+ s2 = testcase_dep2str_complex(pool, rd->evr, needparens);
+ if (addparens)
+ s = pool_tmpappend(pool, s, s2, ")");
+ else
+ s = pool_tmpappend(pool, s, s2, 0);
+ pool_freetmpspace(pool, s2);
+ return s;
+}
+
+const char *
+testcase_dep2str(Pool *pool, Id id)
+{
+ return testcase_dep2str_complex(pool, id, 0);
+}
+
+
+/* Convert a simple string. Also handle the :any suffix */
+static Id
+testcase_str2dep_simple(Pool *pool, const char **sp, int isname)
+{
+ int haveesc = 0;
+ int paren = 0;
+ int isany = 0;
+ Id id;
+ const char *s;
+ for (s = *sp; *s; s++)
+ {
+ if (*s == '\\')
+ haveesc++;
+ if (*s == ' ' || *(unsigned char *)s < 32)
+ break;
+ if (*s == '(')
+ paren++;
+ if (*s == ')' && paren-- <= 0)
+ break;
+ }
+ if (isname && s - *sp > 4 && !strncmp(s - 4, ":any", 4))
+ {
+ isany = 1;
+ s -= 4;
+ }
+ if (!haveesc)
+ {
+ if (s - *sp == 6 && !strncmp(*sp, "<NULL>", 6))
+ id = 0;
+ else
+ id = pool_strn2id(pool, *sp, s - *sp, 1);
+ }
+ else if (s - *sp == 3 && !strncmp(*sp, "\\00", 3))
+ id = 1;
+ else
+ {
+ char buf[128], *bp, *bp2;
+ const char *sp2;
+ bp = s - *sp >= 128 ? solv_malloc(s - *sp + 1) : buf;
+ for (bp2 = bp, sp2 = *sp; sp2 < s;)
+ {
+ *bp2++ = *sp2++;
+ if (bp2[-1] == '\\')
+ solv_hex2bin(&sp2, (unsigned char *)bp2 - 1, 1);
+ }
+ *bp2 = 0;
+ id = pool_str2id(pool, bp, 1);
+ if (bp != buf)
+ solv_free(bp);
+ }
+ if (isany)
+ {
+ id = pool_rel2id(pool, id, ARCH_ANY, REL_MULTIARCH, 1);
+ s += 4;
+ }
+ *sp = s;
+ return id;
+}
+
+
+static Id
+testcase_str2dep_complex(Pool *pool, const char **sp, int relop)
+{
+ const char *s = *sp;
+ Id flags, id, id2, namespaceid = 0;
+ struct oplist *op;
+