From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 096A0138A87 for ; Tue, 24 Feb 2015 01:26:37 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C5355E08E9; Tue, 24 Feb 2015 01:26:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 31C7CE08E9 for ; Tue, 24 Feb 2015 01:26:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1D213340959 for ; Tue, 24 Feb 2015 01:26:09 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 279F1126BD for ; Tue, 24 Feb 2015 01:26:05 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1424736487.c85ef7b89c7b7bf9a7b462e76c309855b1be4e4e.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qmerge.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: c85ef7b89c7b7bf9a7b462e76c309855b1be4e4e X-VCS-Branch: master Date: Tue, 24 Feb 2015 01:26:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 39f67d64-4196-40f5-9295-bfbd72148a4c X-Archives-Hash: 7d6c921ec3d327f63ea69b84e5375ee4 commit: c85ef7b89c7b7bf9a7b462e76c309855b1be4e4e Author: Mike Frysinger gentoo org> AuthorDate: Tue Feb 24 00:03:15 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Tue Feb 24 00:08:07 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=c85ef7b8 qmerge: pull atom up a level in the merge logic --- qmerge.c | 75 ++++++++++++++++++++++------------------------------------------ 1 file changed, 26 insertions(+), 49 deletions(-) diff --git a/qmerge.c b/qmerge.c index 4660eff..be28cb7 100644 --- a/qmerge.c +++ b/qmerge.c @@ -1210,15 +1210,12 @@ _q_static int unlink_empty(const char *buf) return -1; } -_q_static int match_pkg(queue *ll, const struct pkg_t *pkg) +_q_static int match_pkg(const queue *ll, const depend_atom *atom, const struct pkg_t *pkg) { - depend_atom *atom; - char buf[255], buf2[255]; + char buf[255]; int match = 0; snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF); - if ((atom = atom_explode(buf)) == NULL) - errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF); /* verify this is the requested package */ if (strcmp(ll->name, buf) == 0) @@ -1227,20 +1224,14 @@ _q_static int match_pkg(queue *ll, const struct pkg_t *pkg) if (strcmp(ll->name, pkg->PF) == 0) match = 2; - snprintf(buf2, sizeof(buf2), "%s/%s", pkg->CATEGORY, atom->PN); + snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN); - if (strcmp(ll->name, buf2) == 0) + if (strcmp(ll->name, buf) == 0) match = 3; if (strcmp(ll->name, atom->PN) == 0) match = 4; - if (match) - goto match_done; - -match_done: - atom_implode(atom); - return match; } @@ -1287,28 +1278,19 @@ pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *at } _q_static -void pkg_process(queue *todo, const struct pkg_t *pkg) +void pkg_process(const queue *todo, const depend_atom *atom, const struct pkg_t *pkg) { - queue *ll; - depend_atom *atom; - char buf[255]; - - snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF); - if ((atom = atom_explode(buf)) == NULL) - errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF); + const queue *ll; ll = todo; while (ll) { - if (ll->name[0] != '-' && match_pkg(ll, pkg)) { + if (ll->name[0] != '-' && match_pkg(ll, atom, pkg)) { /* fetch all requested packages */ pkg_fetch(0, atom, pkg); } ll = ll->next; } - - /* free the atom */ - atom_implode(atom); } _q_static void @@ -1382,19 +1364,15 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg) } _q_static void -print_Pkg(int full, struct pkg_t *pkg) +print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg) { char *p = NULL; char buf[512]; - depend_atom *atom = NULL; - - if (!pkg->CATEGORY[0]) errf("CATEGORY is NULL"); - if (!pkg->PF[0]) errf("PF is NULL"); - printf("%s%s/%s%s%s%s%s%s\n", BOLD, pkg->CATEGORY, BLUE, pkg->PF, NORM, + printf("%s%s/%s%s%s%s%s%s\n", BOLD, atom->CATEGORY, BLUE, pkg->PF, NORM, !quiet ? " [" : "", !quiet ? make_human_readable_str(pkg->SIZE, 1, KILOBYTE) : "", - !quiet ? "KiB]" : ""); + !quiet ? " KiB]" : ""); if (full == 0) return; @@ -1419,10 +1397,6 @@ print_Pkg(int full, struct pkg_t *pkg) if (strcmp(pkg->REPO, "gentoo") != 0) printf(" %sRepo%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->REPO); - snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF); - atom = atom_explode(buf); - if ((atom = atom_explode(buf)) == NULL) - return; if ((p = best_version(pkg->CATEGORY, atom->PN)) != NULL) { if (*p) { int ret; @@ -1437,7 +1411,6 @@ print_Pkg(int full, struct pkg_t *pkg) printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM); } } - atom_implode(atom); } _q_static int @@ -1701,15 +1674,17 @@ parse_packages(queue *todo) size_t buflen; char *buf, *p; struct pkg_t Pkg; + depend_atom *pkg_atom; fp = open_binpkg_index(); + pkg_atom = NULL; memset(&Pkg, 0, sizeof(Pkg)); buf = NULL; while (getline(&buf, &buflen, fp) != -1) { if (*buf == '\n') { - if ((strlen(Pkg.PF) > 0) && (strlen(Pkg.CATEGORY) > 0)) { + if (pkg_atom) { struct pkg_t *pkg = xmalloc(sizeof(*pkg)); *pkg = Pkg; @@ -1717,16 +1692,18 @@ parse_packages(queue *todo) if (todo) { queue *ll = todo; while (ll) { - if ((match_pkg(ll, pkg) > 0) || (strcmp(ll->name, pkg->CATEGORY) == 0)) - print_Pkg(verbose, pkg); + if ((match_pkg(ll, pkg_atom, pkg) > 0) || (strcmp(ll->name, pkg->CATEGORY) == 0)) + print_Pkg(verbose, pkg_atom, pkg); ll = ll->next; } } else - print_Pkg(verbose, pkg); + print_Pkg(verbose, pkg_atom, pkg); } else - pkg_process(todo, pkg); + pkg_process(todo, pkg_atom, pkg); free(pkg); + atom_implode(pkg_atom); + pkg_atom = NULL; } memset(&Pkg, 0, sizeof(Pkg)); continue; @@ -1766,14 +1743,12 @@ parse_packages(queue *todo) case 'C': if (strcmp(buf, "CATEGORY") == 0) strncpy(Pkg.CATEGORY, p, sizeof(Pkg.CATEGORY)); if (strcmp(buf, "CPV") == 0) { - depend_atom *atom; - if ((atom = atom_explode(p)) != NULL) { - if (atom->PR_int) - snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int); + if ((pkg_atom = atom_explode(p)) != NULL) { + if (pkg_atom->PR_int) + snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i", pkg_atom->PN, pkg_atom->PV, pkg_atom->PR_int); else - snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s", atom->PN, atom->PV); - strncpy(Pkg.CATEGORY, atom->CATEGORY, sizeof(Pkg.CATEGORY)); - atom_implode(atom); + snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s", pkg_atom->PN, pkg_atom->PV); + strncpy(Pkg.CATEGORY, pkg_atom->CATEGORY, sizeof(Pkg.CATEGORY)); } } break; @@ -1787,6 +1762,8 @@ parse_packages(queue *todo) free(buf); fclose(fp); + if (pkg_atom) + atom_implode(pkg_atom); return EXIT_SUCCESS; }