Просмотр исходного кода

libdpkg: Move pkg_sorter_by_name() from pkg module to pkg-show

The function is being used for showing purposes.
Guillem Jover лет назад: 14
Родитель
Сommit
77da8357e8
5 измененных файлов с 23 добавлено и 22 удалено
  1. 20 0
      lib/dpkg/pkg-show.c
  2. 2 0
      lib/dpkg/pkg-show.h
  3. 0 20
      lib/dpkg/pkg.c
  4. 0 2
      lib/dpkg/pkg.h
  5. 1 0
      src/select.c

+ 20 - 0
lib/dpkg/pkg-show.c

@@ -166,3 +166,23 @@ pkg_abbrev_eflag(const struct pkginfo *pkg)
 {
 	return " R"[pkg->eflag];
 }
+
+/**
+ * Compare a package to be sorted by name.
+ *
+ * @param a A pointer of a pointer to a struct pkginfo.
+ * @param b A pointer of a pointer to a struct pkginfo.
+ *
+ * @return An integer with the result of the comparison.
+ * @retval -1 a is earlier than b.
+ * @retval 0 a is equal to b.
+ * @retval 1 a is later than b.
+ */
+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->set->name, pb->set->name);
+}

+ 2 - 0
lib/dpkg/pkg-show.h

@@ -26,6 +26,8 @@
 
 DPKG_BEGIN_DECLS
 
+int pkg_sorter_by_name(const void *a, const void *b);
+
 const char *pkg_summary(const struct pkginfo *pkg, const struct pkgbin *pkgbin,
                         int *len_ret);
 int pkg_abbrev_want(const struct pkginfo *pkg);

+ 0 - 20
lib/dpkg/pkg.c

@@ -237,23 +237,3 @@ pkg_is_informative(struct pkginfo *pkg, struct pkgbin *pkgbin)
 
 	return false;
 }
-
-/**
- * Compare a package to be sorted by name.
- *
- * @param a A pointer of a pointer to a struct pkginfo.
- * @param b A pointer of a pointer to a struct pkginfo.
- *
- * @return An integer with the result of the comparison.
- * @retval -1 a is earlier than b.
- * @retval 0 a is equal to b.
- * @retval 1 a is later than b.
- */
-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->set->name, pb->set->name);
-}

+ 0 - 2
lib/dpkg/pkg.h

@@ -28,8 +28,6 @@ DPKG_BEGIN_DECLS
 
 typedef int pkg_sorter_func(const void *a, const void *b);
 
-int pkg_sorter_by_name(const void *a, const void *b);
-
 void pkgset_link_pkg(struct pkgset *set, struct pkginfo *pkg);
 
 void pkg_set_status(struct pkginfo *pkg, enum pkgstatus status);

+ 1 - 0
src/select.c

@@ -32,6 +32,7 @@
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/pkg-array.h>
+#include <dpkg/pkg-show.h>
 #include <dpkg/options.h>
 
 #include "filesdb.h"