Bladeren bron

libdpkg: Refactor pkg status to abbreviations mapping into new functions

Guillem Jover 14 jaren geleden
bovenliggende
commit
b9ca9a28b0
3 gewijzigde bestanden met toevoegingen van 26 en 5 verwijderingen
  1. 19 1
      lib/dpkg/pkg-show.c
  2. 4 1
      lib/dpkg/pkg-show.h
  3. 3 3
      src/querycmd.c

+ 19 - 1
lib/dpkg/pkg-show.c

@@ -3,7 +3,7 @@
  * pkg-show.c - primitives for pkg information display
  *
  * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2008-2010 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2011 Guillem Jover <guillem@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
@@ -47,3 +47,21 @@ pkg_summary(const struct pkginfo *pkg, int *len_ret)
 
 	return pdesc;
 }
+
+int
+pkg_abbrev_want(const struct pkginfo *pkg)
+{
+	return "uihrp"[pkg->want];
+}
+
+int
+pkg_abbrev_status(const struct pkginfo *pkg)
+{
+	return "ncHUFWti"[pkg->status];
+}
+
+int
+pkg_abbrev_eflag(const struct pkginfo *pkg)
+{
+	return " R"[pkg->eflag];
+}

+ 4 - 1
lib/dpkg/pkg-show.h

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * pkg-show.h - primitives for pkg information display
  *
- * Copyright © 2010 Guillem Jover <guillem@debian.org>
+ * Copyright © 2010-2011 Guillem Jover <guillem@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
@@ -27,6 +27,9 @@
 DPKG_BEGIN_DECLS
 
 const char *pkg_summary(const struct pkginfo *pkg, int *len_ret);
+int pkg_abbrev_want(const struct pkginfo *pkg);
+int pkg_abbrev_status(const struct pkginfo *pkg);
+int pkg_abbrev_eflag(const struct pkginfo *pkg);
 
 DPKG_END_DECLS
 

+ 3 - 3
src/querycmd.c

@@ -187,9 +187,9 @@ list1package(struct pkginfo *pkg, struct list_format *fmt, struct pkg_array *arr
   l = min(l, fmt->dw);
 
   printf(fmt->format,
-         "uihrp"[pkg->want],
-         "ncHUFWti"[pkg->status],
-         " R"[pkg->eflag],
+         pkg_abbrev_want(pkg),
+         pkg_abbrev_status(pkg),
+         pkg_abbrev_eflag(pkg),
          pkg->set->name,
          versiondescribe(&pkg->installed.version, vdew_nonambig),
          l, pdesc);