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

libdpkg: Uppercase and namespace pkgpriority enum values

Guillem Jover лет назад: 12
Родитель
Сommit
8fc618ad8e

+ 1 - 1
dpkg-deb/build.c

@@ -382,7 +382,7 @@ check_new_pkg(const char *dir)
   if (strspn(pkg->set->name, "abcdefghijklmnopqrstuvwxyz0123456789+-.") !=
       strlen(pkg->set->name))
     ohshit(_("package name has characters that aren't lowercase alphanums or `-+.'"));
-  if (pkg->priority == pri_other)
+  if (pkg->priority == PKG_PRIO_OTHER)
     warning(_("'%s' contains user-defined Priority value '%s'"),
             controlfile, pkg->otherpriority);
   for (field = pkg->available.arbs; field; field = field->next) {

+ 2 - 2
dselect/pkgcmds.cc

@@ -47,9 +47,9 @@ packagelist::affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith) {
   default:
     internerr("unknown statsortorder %d", statsortorder);
   }
-  if (comparewith->priority != pri_unset &&
+  if (comparewith->priority != PKG_PRIO_UNSET &&
       (comparewith->priority != pkg->priority ||
-       (comparewith->priority == pri_other &&
+       (comparewith->priority == PKG_PRIO_OTHER &&
         strcasecmp(comparewith->otherpriority, pkg->otherpriority))))
     return false;
   if (comparewith->section &&

+ 7 - 7
dselect/pkglist.cc

@@ -66,7 +66,7 @@ int packagelist::compareentries(const struct perpackagestate *a,
     strcasecmp(asection,bsection);
   int c_priority=
     a->pkg->priority - b->pkg->priority;
-  if (!c_priority && a->pkg->priority == pri_other)
+  if (!c_priority && a->pkg->priority == PKG_PRIO_OTHER)
     c_priority= strcasecmp(a->pkg->otherpriority, b->pkg->otherpriority);
   int c_name=
     a->pkg->set->name && b->pkg->set->name ?
@@ -273,7 +273,7 @@ void packagelist::sortmakeheads() {
         this, sortorder, statsortorder);
 
   int nrealitems= nitems;
-  addheading(ssa_none, sss_none, pri_unset, nullptr, nullptr);
+  addheading(ssa_none, sss_none, PKG_PRIO_UNSET, nullptr, nullptr);
 
   assert(sortorder != so_unsorted);
   if (sortorder == so_alpha && statsortorder == sso_unsorted) { sortinplace(); return; }
@@ -308,7 +308,7 @@ void packagelist::sortmakeheads() {
 
     int prioritydiff= (!lastpkg ||
                        thispkg->priority != lastpkg->priority ||
-                       (thispkg->priority == pri_other &&
+                       (thispkg->priority == PKG_PRIO_OTHER &&
                         strcasecmp(thispkg->otherpriority,lastpkg->otherpriority)));
     int sectiondiff= (!lastpkg ||
                       strcasecmp(thispkg->section ? thispkg->section : "",
@@ -321,7 +321,7 @@ void packagelist::sortmakeheads() {
           thispkg->clientdata->ssavail, thispkg->clientdata->ssstate,
           ssdiff ? "*diff" : "same",
           thispkg->priority,
-          thispkg->priority != pri_other ? "<none>" :
+          thispkg->priority != PKG_PRIO_OTHER ? "<none>" :
           thispkg->otherpriority ? thispkg->otherpriority : "<null>",
           prioritydiff ? "*diff*" : "same",
           thispkg->section ? thispkg->section : "<null>",
@@ -329,11 +329,11 @@ void packagelist::sortmakeheads() {
 
     if (ssdiff)
       addheading(ssavail,ssstate,
-                 pri_unset, nullptr, nullptr);
+                 PKG_PRIO_UNSET, nullptr, nullptr);
 
     if (sortorder == so_section && sectiondiff)
       addheading(ssavail,ssstate,
-                 pri_unset, nullptr,
+                 PKG_PRIO_UNSET, nullptr,
                  thispkg->section ? thispkg->section : "");
 
     if (sortorder == so_priority && prioritydiff)
@@ -404,7 +404,7 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) {
         state->original == PKG_WANT_UNKNOWN) {
       state->suggested=
         pkg->status == stat_installed ||
-          pkg->priority <= pri_standard /* FIXME: configurable */
+          pkg->priority <= PKG_PRIO_STANDARD /* FIXME: configurable */
             ? PKG_WANT_INSTALL : PKG_WANT_PURGE;
       state->spriority= sp_inherit;
     } else {

+ 2 - 1
dselect/pkglist.h

@@ -67,7 +67,8 @@ struct perpackagestate {
   /* The ‘heading’ entries in the list, for “all packages of type foo”,
    * point to a made-up pkginfo, which has pkg->name==0.
    * pkg->priority and pkg->section are set to the values if appropriate, or to
-   * pri_unset resp. null if the heading refers to all priorities resp. sections.
+   * PKG_PRIO_UNSET resp. null if the heading refers to all priorities resp.
+   * sections.
    * uprec is used when constructing the list initially and when tearing it
    * down and should not otherwise be used; other fields are undefined.
    */

+ 5 - 5
dselect/pkgtop.cc

@@ -37,12 +37,12 @@
 static const char *
 pkgprioritystring(const struct pkginfo *pkg)
 {
-  if (pkg->priority == pri_unset) {
+  if (pkg->priority == PKG_PRIO_UNSET) {
     return nullptr;
-  } else if (pkg->priority == pri_other) {
+  } else if (pkg->priority == PKG_PRIO_OTHER) {
     return pkg->otherpriority;
   } else {
-    assert(pkg->priority <= pri_unknown);
+    assert(pkg->priority <= PKG_PRIO_UNKNOWN);
     return gettext(prioritystrings[pkg->priority]);
   }
 }
@@ -167,7 +167,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
 
       mvwprintw(listpad, screenline, priority_column - 1, " %-*.*s",
                 priority_width, priority_width,
-                pkg->priority == pri_other ? pkg->otherpriority :
+                pkg->priority == PKG_PRIO_OTHER ? pkg->otherpriority :
                 gettext(prioritystrings[pkg->priority]));
     } else {
       mvwaddch(listpad, screenline, 0, eflagchars[pkg->eflag]);
@@ -183,7 +183,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
 
       wmove(listpad, screenline, priority_column - 1);
       waddch(listpad, ' ');
-      if (pkg->priority == pri_other) {
+      if (pkg->priority == PKG_PRIO_OTHER) {
         for (i=priority_width, p=pkg->otherpriority;
              i > 0 && *p;
              i--, p++)

+ 8 - 8
lib/dpkg/dpkg-db.h

@@ -177,14 +177,14 @@ enum pkgstatus {
 };
 
 enum pkgpriority {
-	pri_required,
-	pri_important,
-	pri_standard,
-	pri_optional,
-	pri_extra,
-	pri_other,
-	pri_unknown,
-	pri_unset = -1,
+	PKG_PRIO_REQUIRED,
+	PKG_PRIO_IMPORTANT,
+	PKG_PRIO_STANDARD,
+	PKG_PRIO_OPTIONAL,
+	PKG_PRIO_EXTRA,
+	PKG_PRIO_OTHER,
+	PKG_PRIO_UNKNOWN,
+	PKG_PRIO_UNSET = -1,
 };
 
 /**

+ 2 - 2
lib/dpkg/dump.c

@@ -229,9 +229,9 @@ w_priority(struct varbuf *vb,
            const struct pkginfo *pkg, const struct pkgbin *pkgbin,
            enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  if (pkg->priority == pri_unknown)
+  if (pkg->priority == PKG_PRIO_UNKNOWN)
     return;
-  assert(pkg->priority <= pri_unknown);
+  assert(pkg->priority <= PKG_PRIO_UNKNOWN);
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Priority: ");
   varbuf_add_str(vb, pkg_priority_name(pkg));

+ 1 - 1
lib/dpkg/fields.c

@@ -207,7 +207,7 @@ f_priority(struct pkginfo *pkg, struct pkgbin *pkgbin,
   if (!*value) return;
   pkg->priority = parse_nv_last(ps, _("word in 'Priority' field"),
                                 priorityinfos, value);
-  if (pkg->priority == pri_other)
+  if (pkg->priority == PKG_PRIO_OTHER)
     pkg->otherpriority = nfstrsave(value);
 }
 

+ 3 - 3
lib/dpkg/parse.c

@@ -449,11 +449,11 @@ pkg_parse_copy(struct parsedb_state *ps,
       !((ps->flags & pdb_weakclassification) &&
         str_is_set(dst_pkg->section)))
     dst_pkg->section = src_pkg->section;
-  if (src_pkg->priority != pri_unknown &&
+  if (src_pkg->priority != PKG_PRIO_UNKNOWN &&
       !((ps->flags & pdb_weakclassification) &&
-        dst_pkg->priority != pri_unknown)) {
+        dst_pkg->priority != PKG_PRIO_UNKNOWN)) {
     dst_pkg->priority = src_pkg->priority;
-    if (src_pkg->priority == pri_other)
+    if (src_pkg->priority == PKG_PRIO_OTHER)
       dst_pkg->otherpriority = src_pkg->otherpriority;
   }
 

+ 7 - 7
lib/dpkg/pkg-namevalue.c

@@ -40,13 +40,13 @@ const struct namevalue multiarchinfos[] = {
 };
 
 const struct namevalue priorityinfos[] = {
-	NAMEVALUE_DEF("required",		pri_required),
-	NAMEVALUE_DEF("important",		pri_important),
-	NAMEVALUE_DEF("standard",		pri_standard),
-	NAMEVALUE_DEF("optional",		pri_optional),
-	NAMEVALUE_DEF("extra",			pri_extra),
-	NAMEVALUE_FALLBACK_DEF("this is a bug - please report", pri_other),
-	NAMEVALUE_DEF("unknown",		pri_unknown),
+	NAMEVALUE_DEF("required",		PKG_PRIO_REQUIRED),
+	NAMEVALUE_DEF("important",		PKG_PRIO_IMPORTANT),
+	NAMEVALUE_DEF("standard",		PKG_PRIO_STANDARD),
+	NAMEVALUE_DEF("optional",		PKG_PRIO_OPTIONAL),
+	NAMEVALUE_DEF("extra",			PKG_PRIO_EXTRA),
+	NAMEVALUE_FALLBACK_DEF("this is a bug - please report", PKG_PRIO_OTHER),
+	NAMEVALUE_DEF("unknown",		PKG_PRIO_UNKNOWN),
 	{ .name = NULL }
 };
 

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

@@ -216,7 +216,7 @@ pkg_status_name(const struct pkginfo *pkg)
 const char *
 pkg_priority_name(const struct pkginfo *pkg)
 {
-	if (pkg->priority == pri_other)
+	if (pkg->priority == PKG_PRIO_OTHER)
 		return pkg->otherpriority;
 	else
 		return priorityinfos[pkg->priority].name;

+ 1 - 1
lib/dpkg/pkg.c

@@ -115,7 +115,7 @@ pkg_blank(struct pkginfo *pkg)
 	pkg->status = stat_notinstalled;
 	pkg->eflag = PKG_EFLAG_OK;
 	pkg->want = PKG_WANT_UNKNOWN;
-	pkg->priority = pri_unknown;
+	pkg->priority = PKG_PRIO_UNKNOWN;
 	pkg->otherpriority = NULL;
 	pkg->section = NULL;
 	dpkg_version_blank(&pkg->configversion);

+ 1 - 1
src/querycmd.c

@@ -461,7 +461,7 @@ enqperpackage(const char *const *argv)
     switch (cipaction->arg_int) {
     case act_status:
       if (pkg->status == stat_notinstalled &&
-          pkg->priority == pri_unknown &&
+          pkg->priority == PKG_PRIO_UNKNOWN &&
           str_is_unset(pkg->section) &&
           !pkg->files &&
           pkg->want == PKG_WANT_UNKNOWN &&