diff options
author | Guillem Jover <guillem@debian.org> | 2012-05-08 04:32:22 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2012-05-10 04:41:10 +0200 |
commit | ef8c24b49ec8a14070b7a05d9503348b69f80867 (patch) | |
tree | 4a6b5915e1ea8c18a51e7752ea1415650fdc56cf | |
parent | b9d2ac6beb13f9e068d27529dc7e6af3e0fd1c00 (diff) | |
download | dpkg-ef8c24b49ec8a14070b7a05d9503348b69f80867.tar.gz |
libdpkg: Rework enum depverrel into new enum dpkg_relation
Use more meaningful enum value names, and simplify them by having the
minimum amount of values required.
-rw-r--r-- | dselect/pkgdepcon.cc | 2 | ||||
-rw-r--r-- | dselect/pkgsublist.cc | 26 | ||||
-rw-r--r-- | lib/dpkg/dpkg-db.h | 27 | ||||
-rw-r--r-- | lib/dpkg/dump.c | 14 | ||||
-rw-r--r-- | lib/dpkg/fields.c | 18 | ||||
-rw-r--r-- | lib/dpkg/vercmp.c | 22 | ||||
-rw-r--r-- | src/depcon.c | 4 | ||||
-rw-r--r-- | src/enquiry.c | 4 | ||||
-rw-r--r-- | src/packages.c | 9 | ||||
-rw-r--r-- | src/processarc.c | 2 |
10 files changed, 70 insertions, 58 deletions
diff --git a/dselect/pkgdepcon.cc b/dselect/pkgdepcon.cc index 9fb26c209..028ed6d57 100644 --- a/dselect/pkgdepcon.cc +++ b/dselect/pkgdepcon.cc @@ -398,7 +398,7 @@ packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade) return false; } } - if (possi->verrel != dvr_none) + if (possi->verrel != dpkg_relation_none) return false; deppossi *provider; diff --git a/dselect/pkgsublist.cc b/dselect/pkgsublist.cc index 27a322023..051decfe2 100644 --- a/dselect/pkgsublist.cc +++ b/dselect/pkgsublist.cc @@ -128,15 +128,25 @@ packagelist::add(dependency *depends, showpriority displayimportance) possi=possi->next, comma=(possi && possi->next ? ", " : _(" or "))) { info(comma); info(possi->ed->name); - if (possi->verrel != dvr_none) { + if (possi->verrel != dpkg_relation_none) { switch (possi->verrel) { - case dvr_earlierequal: info(" (<= "); break; - case dvr_laterequal: info(" (>= "); break; - case dvr_earlierstrict: info(" (<< "); break; - case dvr_laterstrict: info(" (>> "); break; - case dvr_exact: info(" (= "); break; + case dpkg_relation_le: + info(" (<= "); + break; + case dpkg_relation_ge: + info(" (>= "); + break; + case dpkg_relation_lt: + info(" (<< "); + break; + case dpkg_relation_gt: + info(" (>> "); + break; + case dpkg_relation_eq: + info(" (= "); + break; default: - internerr("unknown verrel %d", possi->verrel); + internerr("unknown dpkg_relation %d", possi->verrel); } info(versiondescribe(&possi->version, vdew_nonambig)); info(")"); @@ -146,7 +156,7 @@ packagelist::add(dependency *depends, showpriority displayimportance) add(depends->up,info.string(),displayimportance); for (possi=depends->list; possi; possi=possi->next) { add(&possi->ed->pkg, info.string(), displayimportance); - if (possi->verrel == dvr_none && depends->type != dep_provides) { + if (possi->verrel == dpkg_relation_none && depends->type != dep_provides) { // providers aren't relevant if a version was specified, or // if we're looking at a provider relationship already deppossi *provider; diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h index e258929cf..c1a7c7db8 100644 --- a/lib/dpkg/dpkg-db.h +++ b/lib/dpkg/dpkg-db.h @@ -41,6 +41,15 @@ DPKG_BEGIN_DECLS * @{ */ +enum dpkg_relation { + dpkg_relation_none = 0, + dpkg_relation_eq = 001, + dpkg_relation_lt = 002, + dpkg_relation_le = dpkg_relation_lt | dpkg_relation_eq, + dpkg_relation_gt = 004, + dpkg_relation_ge = dpkg_relation_gt | dpkg_relation_eq, +}; + enum deptype { dep_suggests, dep_recommends, @@ -53,20 +62,6 @@ enum deptype { dep_enhances }; -enum depverrel { - dvrf_earlier= 0001, - dvrf_later= 0002, - dvrf_strict= 0010, - dvrf_orequal= 0020, - dvrf_builtup= 0100, - dvr_none= 0200, - dvr_earlierequal= dvrf_builtup | dvrf_earlier | dvrf_orequal, - dvr_earlierstrict= dvrf_builtup | dvrf_earlier | dvrf_strict, - dvr_laterequal= dvrf_builtup | dvrf_later | dvrf_orequal, - dvr_laterstrict= dvrf_builtup | dvrf_later | dvrf_strict, - dvr_exact= 0400 -}; - struct dependency { struct pkginfo *up; struct dependency *next; @@ -80,7 +75,7 @@ struct deppossi { struct deppossi *next, *rev_next, *rev_prev; const struct dpkg_arch *arch; struct dpkg_version version; - enum depverrel verrel; + enum dpkg_relation verrel; bool arch_is_implicit; bool cyclebreak; }; @@ -390,7 +385,7 @@ void varbufdependency(struct varbuf *vb, struct dependency *dep); bool versionsatisfied3(const struct dpkg_version *it, const struct dpkg_version *ref, - enum depverrel verrel); + enum dpkg_relation verrel); int versioncompare(const struct dpkg_version *version, const struct dpkg_version *refversion); diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c index 72615b4d2..fd1eb652e 100644 --- a/lib/dpkg/dump.c +++ b/lib/dpkg/dump.c @@ -304,26 +304,26 @@ void varbufdependency(struct varbuf *vb, struct dependency *dep) { varbuf_add_str(vb, dop->ed->name); if (!dop->arch_is_implicit) varbuf_add_archqual(vb, dop->arch); - if (dop->verrel != dvr_none) { + if (dop->verrel != dpkg_relation_none) { varbuf_add_str(vb, " ("); switch (dop->verrel) { - case dvr_exact: + case dpkg_relation_eq: varbuf_add_char(vb, '='); break; - case dvr_laterequal: + case dpkg_relation_ge: varbuf_add_str(vb, ">="); break; - case dvr_earlierequal: + case dpkg_relation_le: varbuf_add_str(vb, "<="); break; - case dvr_laterstrict: + case dpkg_relation_gt: varbuf_add_str(vb, ">>"); break; - case dvr_earlierstrict: + case dpkg_relation_lt: varbuf_add_str(vb, "<<"); break; default: - internerr("unknown verrel '%d'", dop->verrel); + internerr("unknown dpkg_relation %d", dop->verrel); } varbuf_add_char(vb, ' '); varbufversion(vb,&dop->version,vdew_nonambig); diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c index 912fe4b49..ed655f9a8 100644 --- a/lib/dpkg/fields.c +++ b/lib/dpkg/fields.c @@ -476,28 +476,28 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin, c1= *p; if (c1 == '<' || c1 == '>') { c2= *++p; - dop->verrel= (c1 == '<') ? dvrf_earlier : dvrf_later; + dop->verrel = (c1 == '<') ? dpkg_relation_lt : dpkg_relation_gt; if (c2 == '=') { - dop->verrel |= (dvrf_orequal | dvrf_builtup); + dop->verrel |= dpkg_relation_eq; p++; } else if (c2 == c1) { - dop->verrel |= (dvrf_strict | dvrf_builtup); + /* Either ‘<<’ or ‘>>’. */ p++; } else if (c2 == '<' || c2 == '>') { parse_error(ps, _("`%s' field, reference to `%.255s':\n" " bad version relationship %c%c"), fip->name, depname.buf, c1, c2); - dop->verrel= dvr_none; + dop->verrel = dpkg_relation_none; } else { parse_warn(ps, _("`%s' field, reference to `%.255s':\n" " `%c' is obsolete, use `%c=' or `%c%c' instead"), fip->name, depname.buf, c1, c1, c1, c1); - dop->verrel |= (dvrf_orequal | dvrf_builtup); + dop->verrel |= dpkg_relation_eq; } } else if (c1 == '=') { - dop->verrel= dvr_exact; + dop->verrel = dpkg_relation_eq; p++; } else { parse_warn(ps, @@ -505,9 +505,9 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin, " implicit exact match on version number, " "suggest using `=' instead"), fip->name, depname.buf); - dop->verrel= dvr_exact; + dop->verrel = dpkg_relation_eq; } - if ((dop->verrel!=dvr_exact) && (fip->integer==dep_provides)) + if ((dop->verrel != dpkg_relation_eq) && (fip->integer == dep_provides)) parse_warn(ps, _("Only exact versions may be used for Provides")); @@ -548,7 +548,7 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin, "error in version"), fip->name, depname.buf); p++; while (isspace(*p)) p++; } else { - dop->verrel= dvr_none; + dop->verrel = dpkg_relation_none; dpkg_version_blank(&dop->version); } if (!*p || *p == ',') break; diff --git a/lib/dpkg/vercmp.c b/lib/dpkg/vercmp.c index 49f8b12a8..56fcbcad3 100644 --- a/lib/dpkg/vercmp.c +++ b/lib/dpkg/vercmp.c @@ -87,20 +87,26 @@ versioncompare(const struct dpkg_version *version, bool versionsatisfied3(const struct dpkg_version *it, const struct dpkg_version *ref, - enum depverrel verrel) + enum dpkg_relation verrel) { int r; - if (verrel == dvr_none) + + if (verrel == dpkg_relation_none) return true; r= versioncompare(it,ref); switch (verrel) { - case dvr_earlierequal: return r <= 0; - case dvr_laterequal: return r >= 0; - case dvr_earlierstrict: return r < 0; - case dvr_laterstrict: return r > 0; - case dvr_exact: return r == 0; + case dpkg_relation_eq: + return r == 0; + case dpkg_relation_lt: + return r < 0; + case dpkg_relation_le: + return r <= 0; + case dpkg_relation_gt: + return r > 0; + case dpkg_relation_ge: + return r >= 0; default: - internerr("unknown depverrel '%d'", verrel); + internerr("unknown dpkg_relation %d", verrel); } return false; } diff --git a/src/depcon.c b/src/depcon.c index a51891ea0..9a09dfd1d 100644 --- a/src/depcon.c +++ b/src/depcon.c @@ -454,7 +454,7 @@ depisok(struct dependency *dep, struct varbuf *whynot, deppossi_pkg_iter_free(possi_iter); /* If there was no version specified we try looking for Providers. */ - if (possi->verrel == dvr_none) { + if (possi->verrel == dpkg_relation_none) { /* See if the package we're about to install Provides it. */ for (provider = possi->ed->depended.available; provider; @@ -593,7 +593,7 @@ depisok(struct dependency *dep, struct varbuf *whynot, } /* If there was no version specified we try looking for Providers. */ - if (possi->verrel == dvr_none) { + if (possi->verrel == dpkg_relation_none) { /* See if the package we're about to install Provides it. */ for (provider = possi->ed->depended.available; provider; diff --git a/src/enquiry.c b/src/enquiry.c index 0e00eb6ca..fe9e30106 100644 --- a/src/enquiry.c +++ b/src/enquiry.c @@ -355,7 +355,7 @@ assert_version_support(const char *const *argv, return 0; case stat_unpacked: case stat_halfconfigured: case stat_halfinstalled: case stat_triggersawaited: - if (versionsatisfied3(&pkg->configversion, version, dvr_laterequal)) + if (versionsatisfied3(&pkg->configversion, version, dpkg_relation_ge)) return 0; printf(_("Version of dpkg with working %s support not yet configured.\n" " Please use 'dpkg --configure dpkg', and then try again.\n"), @@ -484,7 +484,7 @@ predeppackage(const char *const *argv) pkg = trypkg; break; } - if (possi->verrel != dvr_none) + if (possi->verrel != dpkg_relation_none) continue; for (provider = possi->ed->depended.available; !pkg && provider; diff --git a/src/packages.c b/src/packages.c index 491e4d911..4e4dd02e8 100644 --- a/src/packages.c +++ b/src/packages.c @@ -365,7 +365,7 @@ deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby, pkg_name(possdependee, pnaw_nonambig), versiondescribe(&possdependee->installed.version, vdew_nonambig)); - assert(checkversion->verrel != dvr_none); + assert(checkversion->verrel != dpkg_relation_none); if (fc_dependsversion) thisf = (dependtry >= 3) ? found_forced : found_defer; debug(dbg_depcondetail," bad version, returning %d",thisf); @@ -494,7 +494,7 @@ breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok, pkg_name(broken, pnaw_nonambig), versiondescribe(&broken->installed.version, vdew_nonambig), virtbroken->name); - } else if (breaks->verrel != dvr_none) { + } else if (breaks->verrel != dpkg_relation_none) { varbuf_printf(aemsgs, _(" Version of %s to be configured is %s.\n"), pkg_name(broken, pnaw_nonambig), versiondescribe(&broken->installed.version, vdew_nonambig)); @@ -513,7 +513,8 @@ breaks_check_target(struct varbuf *aemsgs, enum dep_check *ok, for (possi = target->depended.installed; possi; possi = possi->rev_next) { if (possi->up->type != dep_breaks) continue; - if (virtbroken && possi->verrel != dvr_none) continue; + if (virtbroken && possi->verrel != dpkg_relation_none) + continue; breaks_check_one(aemsgs, ok, possi, broken, possi->up->up, virtbroken); } } @@ -595,7 +596,7 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing, } deppossi_pkg_iter_free(possi_iter); - if (found != found_ok && possi->verrel == dvr_none) { + if (found != found_ok && possi->verrel == dpkg_relation_none) { for (provider = possi->ed->depended.installed; found != found_ok && provider; provider = provider->rev_next) { diff --git a/src/processarc.c b/src/processarc.c index 6e34e1fbc..c3d99a6a5 100644 --- a/src/processarc.c +++ b/src/processarc.c @@ -1155,7 +1155,7 @@ void process_archive(const char *filename) { newpossi->arch_is_implicit = possi->arch_is_implicit; newpossi->arch = possi->arch; newpossi->verrel= possi->verrel; - if (possi->verrel != dvr_none) + if (possi->verrel != dpkg_relation_none) newpossi->version= possi->version; else dpkg_version_blank(&newpossi->version); |