2 * Copyright (c) 2015, SUSE Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
8 /* this is used by repo_rpmmd, repo_rpmdb, and repo_susetags */
13 #include "pool_parserpmrichdep.h"
18 static struct RichOpComp {
25 { "AND", 3, REL_AND },
29 { "IF", 2, REL_COND },
30 { "THEN", 4, REL_THEN },
32 { "ELSE", 4, REL_ELSE },
38 parseRichDep(Pool *pool, const char **depp, Id chainfl)
40 const char *p = *depp;
44 struct RichOpComp *op;
46 if (!chainfl && *p++ != '(')
54 id = parseRichDep(pool, &p, 0);
62 while (*p && !(*p == ' ' || *p == ',' || (*p == ')' && bl-- <= 0)))
67 id = pool_strn2id(pool, n, p - n, 1);
90 while (*p && !(*p == ' ' || *p == ',' || (*p == ')' && bl-- <= 0)))
93 if (p - n > 2 && n[0] == '0' && n[1] == ':')
94 n += 2; /* strip zero epoch */
97 id = pool_rel2id(pool, id, pool_strn2id(pool, n, p - n, 1), fl, 1);
111 while (*p && *p != ' ')
113 for (op = RichOps; op->n; op++)
114 if (p - n == op->l && !strncmp(n, op->n, op->l))
119 if (chainfl == REL_THEN && fl == REL_ELSE)
121 if (chainfl && fl != chainfl)
123 evr = parseRichDep(pool, &p, fl);
127 return pool_rel2id(pool, id, evr, fl, 1);
131 pool_parserpmrichdep(Pool *pool, const char *dep)
133 Id id = parseRichDep(pool, &dep, 0);