libpkgconf: PKG_ comparators become PKGCONF_CMP_ namespace

feature/tap-sh
William Pitcock 2015-09-06 11:34:09 -05:00
parent 571d9c756c
commit dd86ba43dd
4 changed files with 35 additions and 35 deletions

View File

@ -86,7 +86,7 @@ void
pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
{
parse_state_t state = OUTSIDE_MODULE;
pkgconf_pkg_comparator_t compare = PKG_ANY;
pkgconf_pkg_comparator_t compare = PKGCONF_CMP_ANY;
char cmpname[PKGCONF_BUFSIZE];
char buf[PKGCONF_BUFSIZE];
size_t package_sz = 0, version_sz = 0;
@ -155,7 +155,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
{
pkgconf_dependency_add(deplist_head, package, package_sz, NULL, 0, compare);
compare = PKG_ANY;
compare = PKGCONF_CMP_ANY;
package_sz = 0;
version_sz = 0;
}
@ -206,7 +206,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
#endif
pkgconf_dependency_add(deplist_head, package, package_sz, version, version_sz, compare);
compare = PKG_ANY;
compare = PKGCONF_CMP_ANY;
cnameptr = cmpname;
memset(cmpname, 0, sizeof cmpname);
package_sz = 0;

View File

@ -24,15 +24,15 @@
#define PKGCONF_BUFSIZE (65535)
typedef enum {
PKG_ANY = 0,
PKG_LESS_THAN,
PKG_GREATER_THAN,
PKG_LESS_THAN_EQUAL,
PKG_GREATER_THAN_EQUAL,
PKG_EQUAL,
PKG_NOT_EQUAL,
PKG_ALWAYS_MATCH,
PKG_CMP_SIZE
PKGCONF_CMP_ANY = 0,
PKGCONF_CMP_LESS_THAN,
PKGCONF_CMP_GREATER_THAN,
PKGCONF_CMP_LESS_THAN_EQUAL,
PKGCONF_CMP_GREATER_THAN_EQUAL,
PKGCONF_CMP_EQUAL,
PKGCONF_CMP_NOT_EQUAL,
PKGCONF_CMP_ALWAYS_MATCH,
PKGCONF_CMP_SIZE
} pkgconf_pkg_comparator_t;
typedef struct pkgconf_pkg_ pkgconf_pkg_t;

View File

@ -632,15 +632,15 @@ typedef struct {
pkgconf_pkg_comparator_t compare;
} pkgconf_pkg_comparator_name_t;
static pkgconf_pkg_comparator_name_t pkgconf_pkg_comparator_names[PKG_CMP_SIZE + 1] = {
{"<", PKG_LESS_THAN},
{">", PKG_GREATER_THAN},
{"<=", PKG_LESS_THAN_EQUAL},
{">=", PKG_GREATER_THAN_EQUAL},
{"=", PKG_EQUAL},
{"!=", PKG_NOT_EQUAL},
{"(any)", PKG_ANY},
{"???", PKG_CMP_SIZE},
static pkgconf_pkg_comparator_name_t pkgconf_pkg_comparator_names[PKGCONF_CMP_SIZE + 1] = {
{"<", PKGCONF_CMP_LESS_THAN},
{">", PKGCONF_CMP_GREATER_THAN},
{"<=", PKGCONF_CMP_LESS_THAN_EQUAL},
{">=", PKGCONF_CMP_GREATER_THAN_EQUAL},
{"=", PKGCONF_CMP_EQUAL},
{"!=", PKGCONF_CMP_NOT_EQUAL},
{"(any)", PKGCONF_CMP_ANY},
{"???", PKGCONF_CMP_SIZE},
};
static bool pkgconf_pkg_comparator_lt(pkgconf_pkg_t *pkg, pkgconf_dependency_t *pkgdep)
@ -689,15 +689,15 @@ static bool pkgconf_pkg_comparator_unimplemented(pkgconf_pkg_t *pkg, pkgconf_dep
return false;
}
static pkgconf_vercmp_res_func_t pkgconf_pkg_comparator_impls[PKG_CMP_SIZE + 1] = {
[PKG_ANY] = pkgconf_pkg_comparator_any,
[PKG_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKG_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKG_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKG_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKG_EQUAL] = pkgconf_pkg_comparator_eq,
[PKG_NOT_EQUAL] = pkgconf_pkg_comparator_ne,
[PKG_CMP_SIZE] = pkgconf_pkg_comparator_unimplemented,
static pkgconf_vercmp_res_func_t pkgconf_pkg_comparator_impls[PKGCONF_CMP_SIZE + 1] = {
[PKGCONF_CMP_ANY] = pkgconf_pkg_comparator_any,
[PKGCONF_CMP_LESS_THAN] = pkgconf_pkg_comparator_lt,
[PKGCONF_CMP_GREATER_THAN] = pkgconf_pkg_comparator_gt,
[PKGCONF_CMP_LESS_THAN_EQUAL] = pkgconf_pkg_comparator_lte,
[PKGCONF_CMP_GREATER_THAN_EQUAL] = pkgconf_pkg_comparator_gte,
[PKGCONF_CMP_EQUAL] = pkgconf_pkg_comparator_eq,
[PKGCONF_CMP_NOT_EQUAL] = pkgconf_pkg_comparator_ne,
[PKGCONF_CMP_SIZE] = pkgconf_pkg_comparator_unimplemented,
};
/*
@ -710,7 +710,7 @@ pkgconf_pkg_get_comparator(pkgconf_dependency_t *pkgdep)
{
const pkgconf_pkg_comparator_name_t *i;
for (i = pkgconf_pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++)
for (i = pkgconf_pkg_comparator_names; i->compare != PKGCONF_CMP_SIZE; i++)
{
if (i->compare == pkgdep->compare)
return i->name;
@ -725,7 +725,7 @@ pkgconf_pkg_get_comparator(pkgconf_dependency_t *pkgdep)
* look up the appropriate comparator bytecode in the comparator set (defined
* above, see pkgconf_pkg_comparator_names and pkgconf_pkg_comparator_impls).
*
* XXX: on error return PKG_ANY or maybe we should return PKG_CMP_SIZE which
* XXX: on error return PKGCONF_CMP_ANY or maybe we should return PKGCONF_CMP_SIZE which
* is poisoned?
*/
pkgconf_pkg_comparator_t
@ -733,13 +733,13 @@ pkgconf_pkg_comparator_lookup_by_name(const char *name)
{
const pkgconf_pkg_comparator_name_t *i;
for (i = pkgconf_pkg_comparator_names; i->compare != PKG_CMP_SIZE; i++)
for (i = pkgconf_pkg_comparator_names; i->compare != PKGCONF_CMP_SIZE; i++)
{
if (!strcmp(i->name, name))
return i->compare;
}
return PKG_ANY;
return PKGCONF_CMP_ANY;
}
/*

2
main.c
View File

@ -469,7 +469,7 @@ print_graph_node(pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{
pkgconf_dependency_t *dep = n->data;
printf(" dependency '%s'", dep->package);
if (dep->compare != PKG_ANY)
if (dep->compare != PKGCONF_CMP_ANY)
{
printf(" {\n");
printf(" comparator = '%s';\n", pkgconf_pkg_get_comparator(dep));