diff options
author | Fabian Groffen <grobian@gentoo.org> | 2021-10-04 08:28:02 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2021-10-04 08:28:02 +0200 |
commit | ef14d5f7bb09b8a90e827262798ebd1fde58913a (patch) | |
tree | f2286f0b8339919a49e3b33985198264d96fba51 /libq/atom.c | |
parent | libq/tree: properly set SUBSLOT value when absent (PMS 7.2) (diff) | |
download | portage-utils-ef14d5f7bb09b8a90e827262798ebd1fde58913a.tar.gz portage-utils-ef14d5f7bb09b8a90e827262798ebd1fde58913a.tar.bz2 portage-utils-ef14d5f7bb09b8a90e827262798ebd1fde58913a.zip |
libq/atom: parse/set SUBSLOT when absent to SLOT (PMS 7.2)
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'libq/atom.c')
-rw-r--r-- | libq/atom.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libq/atom.c b/libq/atom.c index d210ed6e..9a51e22d 100644 --- a/libq/atom.c +++ b/libq/atom.c @@ -218,6 +218,10 @@ atom_explode_cat(const char *atom, const char *cat) /* set to NULL if there's nothing */ if (ret->SLOT[0] == '\0') ret->SLOT = NULL; + + /* PMS 7.2: SUBSLOT defaults to SLOT when unset */ + if (ret->SUBSLOT == NULL) + ret->SUBSLOT = ret->SLOT; } /* see if we have any suffix operators */ @@ -380,7 +384,7 @@ atom_clone(depend_atom *atom) rlen = strlen(atom->REPO) + 1; if (atom->SLOT != NULL) slen = strlen(atom->SLOT) + 1; - if (atom->SUBSLOT != NULL) + if (atom->SUBSLOT != NULL && atom->SUBSLOT != atom->SLOT) sslen = strlen(atom->SUBSLOT) + 1; if (atom->CATEGORY != NULL) clen = strlen(atom->CATEGORY) + 1; @@ -427,9 +431,13 @@ atom_clone(depend_atom *atom) p += slen; } if (atom->SUBSLOT != NULL) { - ret->SUBSLOT = p; - memcpy(ret->SUBSLOT, atom->SUBSLOT, sslen); - p += sslen; + if (atom->SUBSLOT == atom->SLOT) { /* PMS 7.2 */ + ret->SUBSLOT = ret->SLOT; + } else { + ret->SUBSLOT = p; + memcpy(ret->SUBSLOT, atom->SUBSLOT, sslen); + p += sslen; + } } if (atom->REPO != NULL) { ret->REPO = p; @@ -820,7 +828,8 @@ atom_to_string_r(char *buf, size_t buflen, depend_atom *a) if (a->SLOT != NULL || a->slotdep != ATOM_SD_NONE) off += snprintf(buf + off, buflen - off, ":%s%s%s%s", a->SLOT ? a->SLOT : "", - a->SUBSLOT ? "/" : "", a->SUBSLOT ? a->SUBSLOT : "", + a->SUBSLOT && a->SUBSLOT != a->SLOT ? "/" : "", + a->SUBSLOT && a->SUBSLOT != a->SLOT ? a->SUBSLOT : "", atom_slotdep_str[a->slotdep]); for (ud = a->usedeps; ud != NULL; ud = ud->next) off += snprintf(buf + off, buflen - off, "%s%s%s%s%s", @@ -933,7 +942,8 @@ atom_format_r( HN(atom->SLOT), NORM); } else if (!strncmp("SUBSLOT", fmt, len)) { - if (showit || atom->SUBSLOT) + if (showit || + (atom->SUBSLOT && atom->SUBSLOT != atom->SLOT)) append_buf(buf, buflen, "%s%s%s%s%s", YELLOW, connected ? "/" : "", |