The following commit has been merged in the master branch:
commit 30a6d6d131a516c4bcd67705487a54e6ee2085bf
Author: Guillem Jover <[email protected]>
Date: Sat Oct 3 21:02:47 2009 +0200
libdpkg: Move pkg_sorter code to a new pkg module
diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index d45bcd4..09cd900 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -40,6 +40,7 @@ libdpkg_a_SOURCES = \
parsehelp.c \
parsedump.h \
path.c path.h \
+ pkg.c pkg.h \
pkg-array.c pkg-array.h \
pkg-list.c pkg-list.h \
progress.c progress.h \
diff --git a/lib/dpkg/pkg-array.c b/lib/dpkg/pkg-array.c
index 1b2e1c3..5a3ad9e 100644
--- a/lib/dpkg/pkg-array.c
+++ b/lib/dpkg/pkg-array.c
@@ -31,15 +31,6 @@
#include <dpkg/dpkg-db.h>
#include <dpkg/pkg-array.h>
-int
-pkg_sorter_by_name(const void *a, const void *b)
-{
- const struct pkginfo *pa = *(const struct pkginfo **)a;
- const struct pkginfo *pb = *(const struct pkginfo **)b;
-
- return strcmp(pa->name, pb->name);
-}
-
void
pkg_array_init_from_db(struct pkg_array *a)
{
diff --git a/lib/dpkg/pkg-array.h b/lib/dpkg/pkg-array.h
index 939b386..71d35b8 100644
--- a/lib/dpkg/pkg-array.h
+++ b/lib/dpkg/pkg-array.h
@@ -26,11 +26,10 @@
#include <compat.h>
#include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
DPKG_BEGIN_DECLS
-typedef int pkg_sorter_func(const void *a, const void *b);
-
struct pkg_array {
int n_pkgs;
struct pkginfo **pkgs;
diff --git a/lib/dpkg/pkg-list.h b/lib/dpkg/pkg.c
similarity index 66%
copy from lib/dpkg/pkg-list.h
copy to lib/dpkg/pkg.c
index 10635b2..2001786 100644
--- a/lib/dpkg/pkg-list.h
+++ b/lib/dpkg/pkg.c
@@ -1,7 +1,8 @@
/*
* dpkg - main program for package management
- * pkg-list.h - primitives for pkg linked list handling
+ * pkg-array.c - primitives for pkg handling
*
+ * Copyright © 1995, 1996 Ian Jackson <[email protected]>
* Copyright © 2009 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
@@ -19,25 +20,20 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef DPKG_PKG_LIST_H
-#define DPKG_PKG_LIST_H
-
#include <config.h>
#include <compat.h>
-#include <dpkg/dpkg-db.h>
-
-DPKG_BEGIN_DECLS
+#include <string.h>
-struct pkg_list {
- struct pkg_list *next;
- struct pkginfo *pkg;
-};
+#include <dpkg/dpkg-db.h>
+#include <dpkg/pkg.h>
-struct pkg_list *pkg_list_new(struct pkginfo *pkg, struct pkg_list *next);
-void pkg_list_free(struct pkg_list *head);
-void pkg_list_prepend(struct pkg_list **head, struct pkginfo *pkg);
+int
+pkg_sorter_by_name(const void *a, const void *b)
+{
+ const struct pkginfo *pa = *(const struct pkginfo **)a;
+ const struct pkginfo *pb = *(const struct pkginfo **)b;
-DPKG_END_DECLS
+ return strcmp(pa->name, pb->name);
+}
-#endif /* DPKG_PKG_LIST_H */
diff --git a/lib/dpkg/string.h b/lib/dpkg/pkg.h
similarity index 69%
copy from lib/dpkg/string.h
copy to lib/dpkg/pkg.h
index a7bc5ae..c107a49 100644
--- a/lib/dpkg/string.h
+++ b/lib/dpkg/pkg.h
@@ -1,8 +1,8 @@
/*
- * libdpkg - Debian packaging suite library routines
- * string.h - string handling routines
+ * dpkg - main program for package management
+ * pkg.h - primitives for pkg handling
*
- * Copyright © 2008, 2009 Guillem Jover <[email protected]>
+ * Copyright © 2009 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -19,17 +19,17 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef DPKG_STRING_H
-#define DPKG_STRING_H
+#ifndef DPKG_PKG_H
+#define DPKG_PKG_H
#include <dpkg/macros.h>
DPKG_BEGIN_DECLS
-char *str_escape_fmt(char *dest, const char *src);
-char *str_strip_quotes(char *str);
+typedef int pkg_sorter_func(const void *a, const void *b);
-DPKG_END_DECLS
+int pkg_sorter_by_name(const void *a, const void *b);
-#endif /* DPKG_STRING_H */
+DPKG_END_DECLS
+#endif /* DPKG_PKG_H */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b3eb6c5..d06318b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -18,6 +18,7 @@ lib/dpkg/nfmalloc.c
lib/dpkg/parse.c
lib/dpkg/parsehelp.c
lib/dpkg/path.c
+lib/dpkg/pkg.c
lib/dpkg/pkg-array.c
lib/dpkg/pkg-list.c
lib/dpkg/progress.c
diff --git a/src/main.h b/src/main.h
index 47a09c8..cbcc2df 100644
--- a/src/main.h
+++ b/src/main.h
@@ -165,11 +165,6 @@ void printarch(const char *const *argv);
void printinstarch(const char *const *argv);
void cmpversions(const char *const *argv) DPKG_ATTR_NORET;
-/* Intended for use as a comparison function for qsort when
- * sorting an array of pointers to struct pkginfo:
- */
-int pkg_sorter_by_name(const void *a, const void *b);
-
void limiteddescription(struct pkginfo *pkg,
int maxl, const char **pdesc_r, int *l_r);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]