commit:     1ff4f0dd61135b86fe5d71e1cc584220b696783b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 17:17:21 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 17:17:21 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1ff4f0dd

libq/atom: support/parse SUBSLOT

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/atom.c | 16 +++++++++++++---
 libq/atom.h |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/libq/atom.c b/libq/atom.c
index 58565bc..5ded0d9 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -148,6 +148,12 @@ atom_explode(const char *atom)
                        ret->slotdep = ATOM_SD_ANY_IGNORE;
                        *ptr = '\0';
                }
+               
+               /* cut in two when sub-slot */
+               if ((ptr = strchr(ret->SLOT, '/')) != NULL) {
+                       *ptr++ = '\0';
+                       ret->SUBSLOT = ptr;
+               }
        }
 
        /* see if we have any suffix operators */
@@ -435,7 +441,9 @@ atom_compare(const depend_atom *a1, const depend_atom *a2)
        /* check slot only when both sides have it */
        if (a1->SLOT && a2->SLOT &&
                        a1->SLOT[0] != '\0' && a2->SLOT[0] != '\0' &&
-                       strcmp(a1->SLOT, a2->SLOT) != 0)
+                       (strcmp(a1->SLOT, a2->SLOT) != 0 ||
+                       (a1->SUBSLOT != NULL && a2->SUBSLOT != NULL &&
+                        strcmp(a1->SUBSLOT, a2->SUBSLOT) != 0)))
                return NOT_EQUAL;
 
        /* check repo */
@@ -620,8 +628,10 @@ atom_to_string(depend_atom *a)
                                atom_usecond_str[ud->sfx_cond],
                                ud->next == NULL ? "]" : ",");
        if (a->SLOT != NULL)
-               off += snprintf(buf + off, buflen - off, ":%s%s",
-                               a->SLOT, atom_slotdep_str[a->slotdep]);
+               off += snprintf(buf + off, buflen - off, ":%s%s%s%s",
+                               a->SLOT,
+                               a->SUBSLOT ? "/" : "", a->SUBSLOT ? a->SUBSLOT 
: "",
+                               atom_slotdep_str[a->slotdep]);
        if (a->REPO != NULL)
                off += snprintf(buf + off, buflen - off, "::%s", a->REPO);
 

diff --git a/libq/atom.h b/libq/atom.h
index c9a1ddb..291d637 100644
--- a/libq/atom.h
+++ b/libq/atom.h
@@ -80,6 +80,7 @@ typedef struct {
        char *P;
        atom_usedep *usedeps;
        char *SLOT;
+       char *SUBSLOT;
        atom_slotdep slotdep;
        char *REPO;
 } depend_atom;

Reply via email to