Bladeren bron

Move duplicate limiteddescription functions to src/pkg-show.c

Guillem Jover 18 jaren geleden
bovenliggende
commit
f85913b03e
6 gewijzigde bestanden met toevoegingen van 61 en 26 verwijderingen
  1. 9 0
      ChangeLog
  2. 2 0
      src/Makefile.am
  3. 0 13
      src/enquiry.c
  4. 3 0
      src/main.h
  5. 47 0
      src/pkg-show.c
  6. 0 13
      src/query.c

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2008-07-26  Guillem Jover  <guillem@debian.org>
+
+	* src/Makefile.am (dpkg_SOURCES): Add 'pkg-show.c'.
+	(dpkg_query_SOURCES): Likewise.
+	* src/main.h (limiteddescription): New function prototype.
+	* src/enquiry.c (limiteddescription): Move function to ...
+	* src/pkg-show.c: ... here. New file.
+	* src/query.c (limiteddescription): Remove duplicate function.
+
 2008-07-26  Guillem Jover  <guillem@debian.org>
 
 	* lib/showpkg.c (parseformat): Do not set cur->type to field, as

+ 2 - 0
src/Makefile.am

@@ -22,6 +22,7 @@ dpkg_SOURCES = \
 	main.c main.h \
 	packages.c \
 	pkg-list.c \
+	pkg-show.c \
 	processarc.c \
 	remove.c \
 	select.c \
@@ -40,6 +41,7 @@ dpkg_query_SOURCES = \
 	errors.c \
 	filesdb.c filesdb.h \
 	pkg-list.c \
+	pkg-show.c \
 	query.c
 
 dpkg_query_LDADD = \

+ 0 - 13
src/enquiry.c

@@ -42,19 +42,6 @@
 #include "filesdb.h"
 #include "main.h"
 
-static void limiteddescription(struct pkginfo *pkg, int maxl,
-                               const char **pdesc_r, int *l_r) {
-  const char *pdesc, *p;
-  int l;
-  
-  pdesc = pkg->installed.valid ? pkg->installed.description : NULL;
-  if (!pdesc) pdesc= _("(no description available)");
-  p= strchr(pdesc,'\n');
-  if (!p) p= pdesc+strlen(pdesc);
-  l = min(p - pdesc, maxl);
-  *pdesc_r=pdesc; *l_r=l;
-}
-
 struct badstatinfo {
   int (*yesno)(struct pkginfo*, const struct badstatinfo *bsi);
   int val;

+ 3 - 0
src/main.h

@@ -141,6 +141,9 @@ void cmpversions(const char *const *argv) NONRETURNING;
  */
 int pkglistqsortcmp(const void *a, const void *b);
 
+void limiteddescription(struct pkginfo *pkg,
+                        int maxl, const char **pdesc_r, int *l_r);
+
 /* from select.c */
 
 void getselections(const char *const *argv);

+ 47 - 0
src/pkg-show.c

@@ -0,0 +1,47 @@
+/*
+ * dpkg - main program for package management
+ * pkg-show.c - primitives for pkg information display
+ *
+ * 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>
+
+void
+limiteddescription(struct pkginfo *pkg,
+                   int maxl, const char **pdesc_r, int *l_r)
+{
+	const char *pdesc, *p;
+	int l;
+
+	pdesc = pkg->installed.valid ? pkg->installed.description : NULL;
+	if (!pdesc)
+		pdesc = _("(no description available)");
+	p = strchr(pdesc, '\n');
+	if (!p)
+		p = pdesc + strlen(pdesc);
+	l = min(p - pdesc, maxl);
+	*pdesc_r = pdesc;
+	*l_r = l;
+}
+

+ 0 - 13
src/query.c

@@ -46,19 +46,6 @@
 
 static const char* showformat		= "${Package}\t${Version}\n";
 
-static void limiteddescription(struct pkginfo *pkg, int maxl,
-                               const char **pdesc_r, int *l_r) {
-  const char *pdesc, *p;
-  int l;
-  
-  pdesc = pkg->installed.valid ? pkg->installed.description : NULL;
-  if (!pdesc) pdesc= _("(no description available)");
-  p= strchr(pdesc,'\n');
-  if (!p) p= pdesc+strlen(pdesc);
-  l = min(p - pdesc, maxl);
-  *pdesc_r=pdesc; *l_r=l;
-}
-
 static int getwidth(void) {
   int fd;
   int res;