pkg: clean up foreach_list_entry* macros (issue #10)

feature/tap-sh
William Pitcock 2012-05-06 22:55:00 -05:00
parent 9eea62fbc6
commit 4eb08d7c1f
6 changed files with 22 additions and 22 deletions

View File

@ -77,7 +77,7 @@ pkg_dependency_append(pkg_dependency_t *head, pkg_dependency_t *tail)
return tail;
/* skip to end of list */
foreach_list_entry(head, node)
PKG_FOREACH_LIST_ENTRY(head, node)
{
if (node->next == NULL)
break;
@ -94,7 +94,7 @@ pkg_dependency_free(pkg_dependency_t *head)
{
pkg_dependency_t *node, *next;
foreach_list_entry_safe(head, next, node)
PKG_FOREACH_LIST_ENTRY_SAFE(head, next, node)
{
if (node->package != NULL)
free(node->package);

View File

@ -33,7 +33,7 @@ pkg_fragment_append(pkg_fragment_t *head, pkg_fragment_t *tail)
return tail;
/* skip to end of list */
foreach_list_entry(head, node)
PKG_FOREACH_LIST_ENTRY(head, node)
{
if (node->next == NULL)
break;
@ -71,7 +71,7 @@ pkg_fragment_exists(pkg_fragment_t *head, pkg_fragment_t *base)
{
pkg_fragment_t *node;
foreach_list_entry(head, node)
PKG_FOREACH_LIST_ENTRY(head, node)
{
if (base->type != node->type)
continue;
@ -117,7 +117,7 @@ pkg_fragment_free(pkg_fragment_t *head)
{
pkg_fragment_t *node, *next;
foreach_list_entry_safe(head, next, node)
PKG_FOREACH_LIST_ENTRY_SAFE(head, next, node)
pkg_fragment_delete(node);
}

24
main.c
View File

@ -100,7 +100,7 @@ collect_cflags(pkg_t *pkg, void *data)
pkg_fragment_t **list = data;
pkg_fragment_t *frag;
foreach_list_entry(pkg->cflags, frag)
PKG_FOREACH_LIST_ENTRY(pkg->cflags, frag)
*list = pkg_fragment_copy(*list, frag);
}
@ -109,7 +109,7 @@ print_cflags(pkg_fragment_t *list)
{
pkg_fragment_t *frag;
foreach_list_entry(list, frag)
PKG_FOREACH_LIST_ENTRY(list, frag)
{
if (want_cflags == WANT_CFLAGS_ONLY_I && frag->type != 'I')
continue;
@ -126,12 +126,12 @@ collect_libs(pkg_t *pkg, void *data)
pkg_fragment_t **list = data;
pkg_fragment_t *frag;
foreach_list_entry(pkg->libs, frag)
PKG_FOREACH_LIST_ENTRY(pkg->libs, frag)
*list = pkg_fragment_copy(*list, frag);
if (want_static)
{
foreach_list_entry(pkg->libs_private, frag)
PKG_FOREACH_LIST_ENTRY(pkg->libs_private, frag)
*list = pkg_fragment_copy(*list, frag);
}
}
@ -141,7 +141,7 @@ print_libs(pkg_fragment_t *list)
{
pkg_fragment_t *frag;
foreach_list_entry(list, frag)
PKG_FOREACH_LIST_ENTRY(list, frag)
{
if (want_libs == WANT_LIBS_ONLY_LDPATH && frag->type != 'L')
continue;
@ -180,7 +180,7 @@ print_variables(pkg_t *pkg, void *unused)
pkg_tuple_t *node;
(void) unused;
foreach_list_entry(pkg->vars, node)
PKG_FOREACH_LIST_ENTRY(pkg->vars, node)
printf("%s\n", node->key);
}
@ -190,7 +190,7 @@ print_requires(pkg_t *pkg, void *unused)
pkg_dependency_t *node;
(void) unused;
foreach_list_entry(pkg->requires, node)
PKG_FOREACH_LIST_ENTRY(pkg->requires, node)
{
printf("%s", node->package);
@ -207,7 +207,7 @@ print_requires_private(pkg_t *pkg, void *unused)
pkg_dependency_t *node;
(void) unused;
foreach_list_entry(pkg->requires_private, node)
PKG_FOREACH_LIST_ENTRY(pkg->requires_private, node)
{
printf("%s", node->package);
@ -226,7 +226,7 @@ print_digraph_node(pkg_t *pkg, void *unused)
printf("\"%s\" [fontname=Sans fontsize=8]\n", pkg->id);
foreach_list_entry(pkg->requires, node)
PKG_FOREACH_LIST_ENTRY(pkg->requires, node)
{
printf("\"%s\" -- \"%s\" [fontname=Sans fontsize=8]\n", node->package, pkg->id);
}
@ -279,7 +279,7 @@ pkg_queue_walk(pkg_queue_t *head)
else if (maximum_traverse_depth > 0)
maximum_traverse_depth++;
foreach_list_entry_safe(head, next_pkgq, pkgq)
PKG_FOREACH_LIST_ENTRY_SAFE(head, next_pkgq, pkgq)
{
pkg_dependency_t *pkgdep;
@ -350,7 +350,7 @@ pkg_queue_walk(pkg_queue_t *head)
want_cflags = 0;
want_libs = 0;
foreach_list_entry(world.requires, iter)
PKG_FOREACH_LIST_ENTRY(world.requires, iter)
{
pkg_t *pkg;
@ -371,7 +371,7 @@ pkg_queue_walk(pkg_queue_t *head)
want_cflags = 0;
want_libs = 0;
foreach_list_entry(world.requires, iter)
PKG_FOREACH_LIST_ENTRY(world.requires, iter)
{
pkg_t *pkg;

2
pkg.c
View File

@ -468,7 +468,7 @@ pkg_walk_list(pkg_dependency_t *deplist,
unsigned int eflags = PKG_ERRF_OK;
pkg_dependency_t *node;
foreach_list_entry(deplist, node)
PKG_FOREACH_LIST_ENTRY(deplist, node)
{
pkg_t *pkgdep;

4
pkg.h
View File

@ -56,10 +56,10 @@ typedef struct pkg_dependency_ pkg_dependency_t;
typedef struct pkg_tuple_ pkg_tuple_t;
typedef struct pkg_fragment_ pkg_fragment_t;
#define foreach_list_entry(head, value) \
#define PKG_FOREACH_LIST_ENTRY(head, value) \
for ((value) = (head); (value) != NULL; (value) = (value)->next)
#define foreach_list_entry_safe(head, nextiter, value) \
#define PKG_FOREACH_LIST_ENTRY_SAFE(head, nextiter, value) \
for ((value) = (head), (nextiter) = (head) != NULL ? (head)->next : NULL; (value) != NULL; (value) = (nextiter), (nextiter) = (nextiter) != NULL ? (nextiter)->next : NULL)
#define PKG_LOCAL_COPY(a) \

View File

@ -44,7 +44,7 @@ pkg_tuple_find(pkg_tuple_t *head, const char *key)
{
pkg_tuple_t *node;
foreach_list_entry(head, node)
PKG_FOREACH_LIST_ENTRY(head, node)
{
if (!strcasecmp(node->key, key))
return node->value;
@ -109,7 +109,7 @@ pkg_tuple_free(pkg_tuple_t *head)
{
pkg_tuple_t *node, *next;
foreach_list_entry_safe(head, next, node)
PKG_FOREACH_LIST_ENTRY_SAFE(head, next, node)
{
free(node->key);
free(node->value);