Explorar o código

Move duplicate pkglistqsortcmp functions to src/pkg-list.c

Guillem Jover %!s(int64=18) %!d(string=hai) anos
pai
achega
13122b76e5
Modificáronse 5 ficheiros con 48 adicións e 13 borrados
  1. 8 0
      ChangeLog
  2. 2 0
      src/Makefile.am
  3. 0 6
      src/enquiry.c
  4. 38 0
      src/pkg-list.c
  5. 0 7
      src/query.c

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-07-22  Guillem Jover  <guillem@debian.org>
+
+	* src/Makefile.am (dpkg_SOURCES): Add 'pkg-list.c'.
+	(dpkg_query_SOURCES): Likewise.
+	* src/enquiry.c (pkglistqsortcmp): Move function to ...
+	* src/pkg-list.c: ... here. New file.
+	* src/query.c (pkglistqsortcmp): Remove duplicate function.
+
 2008-07-22  Guillem Jover  <guillem@debian.org>
 
 	* src/main.h (struct pkg_deconf_list): Move declaration ...

+ 2 - 0
src/Makefile.am

@@ -21,6 +21,7 @@ dpkg_SOURCES = \
 	help.c \
 	main.c main.h \
 	packages.c \
+	pkg-list.c \
 	processarc.c \
 	remove.c \
 	select.c \
@@ -38,6 +39,7 @@ dpkg_LDADD = \
 dpkg_query_SOURCES = \
 	errors.c \
 	filesdb.c filesdb.h \
+	pkg-list.c \
 	query.c
 
 dpkg_query_LDADD = \

+ 0 - 6
src/enquiry.c

@@ -42,12 +42,6 @@
 #include "filesdb.h"
 #include "main.h"
 
-int pkglistqsortcmp(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);
-}
-
 static void limiteddescription(struct pkginfo *pkg, int maxl,
                                const char **pdesc_r, int *l_r) {
   const char *pdesc, *p;

+ 38 - 0
src/pkg-list.c

@@ -0,0 +1,38 @@
+/*
+ * dpkg - main program for package management
+ * pkg-list.c - primitives for pkg list handling
+ *
+ * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with dpkg; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <dpkg.h>
+#include <dpkg-db.h>
+#include <dpkg-priv.h>
+
+int
+pkglistqsortcmp(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);
+}
+

+ 0 - 7
src/query.c

@@ -46,13 +46,6 @@
 
 static const char* showformat		= "${Package}\t${Version}\n";
 
-
-int pkglistqsortcmp(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);
-}
-
 static void limiteddescription(struct pkginfo *pkg, int maxl,
                                const char **pdesc_r, int *l_r) {
   const char *pdesc, *p;