From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/, /
Date: Mon, 16 Aug 2021 13:23:57 +0000 (UTC) [thread overview]
Message-ID: <1629120117.18c65792094cb90b6876940b86a35e21e3da488c.grobian@gentoo> (raw)
commit: 18c65792094cb90b6876940b86a35e21e3da488c
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 16 13:21:57 2021 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug 16 13:21:57 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=18c65792
libq/atom: introduce atom_compare_flg
atom_compare_flg allows to give match behaviour flags, such that often
used exceptions can now be handled without having to modify the input
atoms.
atom_compare is now a macro calling atom_compare_flg with
flags=ATOM_COMP_DEFAULT.
Updated all callers that can use this feature.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/atom.c | 50 ++++++++++++++++++++++++++++----------------------
libq/atom.h | 10 +++++++++-
qlop.c | 19 +++++++++----------
qmerge.c | 17 +++--------------
quse.c | 8 +++-----
5 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/libq/atom.c b/libq/atom.c
index f4c7c1e..0959be5 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -514,7 +514,7 @@ _atom_compare_match(int ret, atom_operator op)
* foo-1 <NOT_EQUAL> bar-1
*/
atom_equality
-atom_compare(const depend_atom *data, const depend_atom *query)
+atom_compare_flg(const depend_atom *data, const depend_atom *query, int flags)
{
atom_operator pfx_op;
atom_operator sfx_op;
@@ -551,27 +551,32 @@ atom_compare(const depend_atom *data, const depend_atom *query)
*/
bl_op = query->blocker;
if (bl_op == ATOM_BL_ANTISLOT) {
- /* ^perl -> match anything with a SLOT */
- if (query->SLOT == NULL && data->SLOT == NULL)
- return NOT_EQUAL;
- if (query->SLOT != NULL) {
- if (query->SUBSLOT == NULL) {
- /* ^perl:0 -> match different SLOT */
- if (data->SLOT == NULL ||
- strcmp(query->SLOT, data->SLOT) == 0)
- return NOT_EQUAL;
- } else {
- /* ^perl:0/5.28 -> match SLOT, but different SUBSLOT */
- if (data->SLOT == NULL ||
- strcmp(query->SLOT, data->SLOT) != 0)
- return NOT_EQUAL;
- if (data->SUBSLOT == NULL ||
- strcmp(query->SUBSLOT, data->SUBSLOT) == 0)
- return NOT_EQUAL;
+ /* just disable/ignore antislot op when SLOT is supposed to be
+ * ignored */
+ if (!(flags & ATOM_COMP_NOSLOT)) {
+ /* ^perl -> match anything with a SLOT */
+ if (query->SLOT == NULL && data->SLOT == NULL)
+ return NOT_EQUAL;
+ if (query->SLOT != NULL) {
+ if (query->SUBSLOT == NULL || flags & ATOM_COMP_NOSUBSLOT) {
+ /* ^perl:0 -> match different SLOT */
+ if (data->SLOT == NULL ||
+ strcmp(query->SLOT, data->SLOT) == 0)
+ return NOT_EQUAL;
+ } else {
+ /* ^perl:0/5.28 -> match SLOT, but different SUBSLOT */
+ if (data->SLOT == NULL ||
+ strcmp(query->SLOT, data->SLOT) != 0)
+ return NOT_EQUAL;
+ if (!(flags & ATOM_COMP_NOSUBSLOT))
+ if (data->SUBSLOT == NULL ||
+ strcmp(query->SUBSLOT, data->SUBSLOT) == 0)
+ return NOT_EQUAL;
+ }
}
}
bl_op = ATOM_BL_NONE; /* ease work below */
- } else if (query->SLOT != NULL) {
+ } else if (query->SLOT != NULL && !(flags & ATOM_COMP_NOSLOT)) {
/* check SLOT only when query side has it */
if (data->SLOT == NULL) {
if (bl_op == ATOM_BL_NONE)
@@ -581,7 +586,7 @@ atom_compare(const depend_atom *data, const depend_atom *query)
/* slot has differs */
if (bl_op == ATOM_BL_NONE)
return NOT_EQUAL;
- } else {
+ } else if (!(flags & ATOM_COMP_NOSUBSLOT)) {
if (query->SUBSLOT != NULL) {
if (data->SUBSLOT == NULL) {
if (bl_op == ATOM_BL_NONE)
@@ -623,7 +628,7 @@ atom_compare(const depend_atom *data, const depend_atom *query)
}
/* check REPO, if query has it, ignore blocker stuff for this one */
- if (query->REPO != NULL) {
+ if (query->REPO != NULL && !(flags & ATOM_COMP_NOREPO)) {
if (data->REPO == NULL)
return NOT_EQUAL;
if (strcmp(query->REPO, data->REPO) != 0)
@@ -753,8 +758,9 @@ atom_compare(const depend_atom *data, const depend_atom *query)
return EQUAL;
/* Make sure the -r# is the same. */
- if ((sfx_op == ATOM_OP_STAR && !query->PR_int) ||
+ if ((sfx_op == ATOM_OP_STAR && query->PR_int == 0) ||
pfx_op == ATOM_OP_PV_EQUAL ||
+ flags & ATOM_COMP_NOREV ||
data->PR_int == query->PR_int)
return _atom_compare_match(EQUAL, pfx_op);
else if (data->PR_int < query->PR_int)
diff --git a/libq/atom.h b/libq/atom.h
index ead9154..8291daf 100644
--- a/libq/atom.h
+++ b/libq/atom.h
@@ -96,11 +96,19 @@ typedef enum {
OLDER
} atom_equality;
+/* bitflags to control compare behaviour */
+#define ATOM_COMP_DEFAULT (0<<0)
+#define ATOM_COMP_NOREV (1<<0)
+#define ATOM_COMP_NOSLOT (1<<1)
+#define ATOM_COMP_NOSUBSLOT (1<<2)
+#define ATOM_COMP_NOREPO (1<<3)
+
depend_atom *atom_explode_cat(const char *atom, const char *cat);
#define atom_explode(A) atom_explode_cat(A, NULL)
depend_atom *atom_clone(depend_atom *atom);
void atom_implode(depend_atom *atom);
-atom_equality atom_compare(const depend_atom *a1, const depend_atom *a2);
+atom_equality atom_compare_flg(const depend_atom *a1, const depend_atom *a2, int flags);
+#define atom_compare(A,B) atom_compare_flg(A, B, ATOM_COMP_DEFAULT)
atom_equality atom_compare_str(const char * const s1, const char * const s2);
char *atom_to_string_r(char *buf, size_t buflen, depend_atom *a);
char *atom_format_r(char *buf, size_t buflen,
diff --git a/qlop.c b/qlop.c
index 4783528..0e381bd 100644
--- a/qlop.c
+++ b/qlop.c
@@ -593,7 +593,7 @@ static int do_emerge_log(
continue;
/* are we interested in this line? */
- if (flags->show_emerge && verbose && (strpfx(p, " *** emerge ") == 0))
+ if (flags->show_emerge && verbose && p[7] == 'm' /* emerge */)
{
char shortopts[8]; /* must hold as many opts converted below */
int numopts = 0;
@@ -753,15 +753,17 @@ static int do_emerge_log(
/* see if we need this atom */
atomw = NULL;
if (atomset == NULL) {
- int orev = atom->PR_int;
- if (flags->do_predict)
- atom->PR_int = 0; /* allow matching a revision */
+ /* match without revisions when we try to predict,
+ * such that our set remains rich enough to cover
+ * various predictions */
array_for_each(atoms, i, atomw) {
- if (atom_compare(atom, atomw) == EQUAL)
+ if (atom_compare_flg(atom, atomw,
+ flags->do_predict
+ ? ATOM_COMP_NOREV
+ : ATOM_COMP_DEFAULT) == EQUAL)
break;
atomw = NULL;
}
- atom->PR_int = orev;
} else {
snprintf(afmt, sizeof(afmt), "%s/%s",
atom->CATEGORY, atom->PN);
@@ -1229,11 +1231,8 @@ static int do_emerge_log(
array_for_each(avgs, j, pkg) {
if (pkgstate == P_INIT) {
- int orev = pkg->atom->PR_int;
atom_equality eq;
- pkg->atom->PR_int = 0;
- eq = atom_compare(pkg->atom, atom);
- pkg->atom->PR_int = orev;
+ eq = atom_compare_flg(pkg->atom, atom, ATOM_COMP_NOREV);
switch (eq) {
case EQUAL:
/* version-less atoms equal any versioned
diff --git a/qmerge.c b/qmerge.c
index a624b89..cf511ad 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1095,23 +1095,12 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
previnst = best_version(slotatom, BV_INSTALLED);
if (previnst != NULL) {
- char *orepo;
- char *osubslot;
-
/* drop REPO and SUBSLOT from query, we don't care about where
* the replacement comes from here, SUBSLOT only affects rebuild
* triggering */
- orepo = previnst->atom->REPO;
- osubslot = previnst->atom->SUBSLOT;
- previnst->atom->REPO = NULL;
- previnst->atom->SUBSLOT = NULL;
-
- replacing = atom_compare(mpkg->atom, previnst->atom);
- replver = previnst->atom->PVR;
-
- /* restore atom for later printing/handling */
- previnst->atom->REPO = orepo;
- previnst->atom->SUBSLOT = osubslot;
+ replacing = atom_compare_flg(mpkg->atom, previnst->atom,
+ ATOM_COMP_NOSUBSLOT | ATOM_COMP_NOREPO);
+ replver = previnst->atom->PVR;
}
(void)qprint_tree_node(level, mpkg, previnst, replacing);
diff --git a/quse.c b/quse.c
index 400339a..ad0d9a2 100644
--- a/quse.c
+++ b/quse.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
@@ -140,11 +140,9 @@ quse_search_use_local_desc(int portdirfd, struct quse_state *state)
if ((atom = atom_explode(buf)) == NULL)
continue;
- atom->REPO = (char *)state->repo;
- if (state->match != NULL)
- atom->SLOT = state->match->SLOT; /* fake match */
if (state->match == NULL ||
- atom_compare(atom, state->match) == EQUAL)
+ atom_compare_flg(atom, state->match,
+ ATOM_COMP_NOSLOT | ATOM_COMP_NOREPO) == EQUAL)
{
if (state->do_list) {
state->retv[i] = xstrdup(q);
next reply other threads:[~2021-08-16 20:48 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 13:23 Fabian Groffen [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-06-27 19:19 [gentoo-commits] proj/portage-utils:master commit in: libq/, / Fabian Groffen
2024-03-29 10:57 Fabian Groffen
2024-01-02 7:57 Fabian Groffen
2023-02-07 8:25 Fabian Groffen
2023-02-07 8:10 Fabian Groffen
2020-02-21 8:18 Fabian Groffen
2020-01-05 13:28 Fabian Groffen
2020-01-02 11:19 Fabian Groffen
2020-01-01 19:52 Fabian Groffen
2019-12-31 9:05 Fabian Groffen
2019-12-30 17:24 Fabian Groffen
2019-12-29 13:26 Fabian Groffen
2019-12-27 16:57 Fabian Groffen
2019-07-13 10:04 Fabian Groffen
2019-06-19 10:44 Fabian Groffen
2019-06-05 9:15 Fabian Groffen
2019-05-09 20:19 Fabian Groffen
2019-05-05 18:13 Fabian Groffen
2019-04-28 15:20 Fabian Groffen
2019-03-27 20:18 Fabian Groffen
2019-03-27 10:55 Fabian Groffen
2019-03-22 9:57 Fabian Groffen
2019-03-19 20:32 Fabian Groffen
2019-03-19 20:32 Fabian Groffen
2019-03-09 18:58 Fabian Groffen
2018-03-23 11:56 Fabian Groffen
2016-12-29 2:25 Mike Frysinger
2016-11-26 23:17 Mike Frysinger
2015-11-28 2:44 Mike Frysinger
2015-02-24 1:26 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1629120117.18c65792094cb90b6876940b86a35e21e3da488c.grobian@gentoo \
--to=grobian@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox