The following commit has been merged in the master branch: commit c9fd580a2e32608172c8a86d00a8dfc7713f8178 Author: Guillem Jover <guil...@debian.org> Date: Wed Feb 24 20:16:34 2010 +0100
Refactor glob functions into its own module diff --git a/src/Makefile.am b/src/Makefile.am index ddde846..5af70c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -56,6 +56,7 @@ dpkg_query_LDADD = \ $(LIBINTL) dpkg_statoverride_SOURCES = \ + glob.c glob.h \ filesdb.c filesdb.h \ statdb.c \ statcmd.c diff --git a/lib/dpkg/pkg-list.c b/src/glob.c similarity index 64% copy from lib/dpkg/pkg-list.c copy to src/glob.c index 88f65c9..475e7da 100644 --- a/lib/dpkg/pkg-list.c +++ b/src/glob.c @@ -1,8 +1,8 @@ /* * dpkg - main program for package management - * pkg-list.c - primitives for pkg linked list handling + * glob.c - file globing functions * - * Copyright © 2009 Guillem Jover <guil...@debian.org> + * Copyright © 2009, 2010 Guillem Jover <guil...@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,37 +24,28 @@ #include <stdlib.h> #include <dpkg/dpkg.h> -#include <dpkg/dpkg-db.h> -#include <dpkg/pkg-list.h> -struct pkg_list * -pkg_list_new(struct pkginfo *pkg, struct pkg_list *next) +#include "glob.h" + +void +glob_list_prepend(struct glob_node **list, char *pattern) { - struct pkg_list *node; + struct glob_node *node; node = m_malloc(sizeof(*node)); - node->pkg = pkg; - node->next = next; - - return node; + node->pattern = pattern; + node->next = *list; + *list = node; } void -pkg_list_free(struct pkg_list *head) +glob_list_free(struct glob_node *head) { while (head) { - struct pkg_list *node; + struct glob_node *node = head; - node = head; head = head->next; - + free(node->pattern); free(node); } } - -void -pkg_list_prepend(struct pkg_list **head, struct pkginfo *pkg) -{ - *head = pkg_list_new(pkg, *head); -} - diff --git a/lib/dpkg/pkg.h b/src/glob.h similarity index 69% copy from lib/dpkg/pkg.h copy to src/glob.h index 9195134..fbab69a 100644 --- a/lib/dpkg/pkg.h +++ b/src/glob.h @@ -1,8 +1,8 @@ /* * dpkg - main program for package management - * pkg.h - primitives for pkg handling + * glob.h - file globing functions * - * Copyright © 2009 Guillem Jover <guil...@debian.org> + * Copyright © 2009, 2010 Guillem Jover <guil...@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,17 +18,21 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef LIBDPKG_PKG_H -#define LIBDPKG_PKG_H +#ifndef DPKG_GLOB_H +#define DPKG_GLOB_H #include <dpkg/macros.h> DPKG_BEGIN_DECLS -typedef int pkg_sorter_func(const void *a, const void *b); +struct glob_node { + struct glob_node *next; + char *pattern; +}; -int pkg_sorter_by_name(const void *a, const void *b); +void glob_list_prepend(struct glob_node **list, char *pattern); +void glob_list_free(struct glob_node *head); DPKG_END_DECLS -#endif /* LIBDPKG_PKG_H */ +#endif /* DPKG_GLOB_H */ diff --git a/src/statcmd.c b/src/statcmd.c index fe9dac3..b398650 100644 --- a/src/statcmd.c +++ b/src/statcmd.c @@ -45,6 +45,7 @@ #include <dpkg/myopt.h> #include "main.h" +#include "glob.h" #include "filesdb.h" const char thisname[] = "dpkg-statoverrides"; @@ -329,34 +330,6 @@ statoverride_remove(const char *const *argv) return 0; } -struct glob_node { - struct glob_node *next; - char *pattern; -}; - -static void -glob_list_prepend(struct glob_node **list, char *pattern) -{ - struct glob_node *node; - - node = m_malloc(sizeof(*node)); - node->pattern = pattern; - node->next = *list; - *list = node; -} - -static void -glob_list_free(struct glob_node *head) -{ - while (head) { - struct glob_node *node = head; - - head = head->next; - free(node->pattern); - free(node); - } -} - static int statoverride_list(const char *const *argv) { -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org