Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Thu, 26 Sep 2019 14:06:53
Message-Id: 1569506062.ae999cf28829aad734b43255941b2c4449fc951b.grobian@gentoo
1 commit: ae999cf28829aad734b43255941b2c4449fc951b
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 26 13:54:22 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 26 13:54:22 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ae999cf2
7
8 qlop: sort average output before display
9
10 sort the package lists using atom order for some consistency after set
11 usage
12
13 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
14
15 qlop.c | 29 +++++++++++++++++++++--------
16 1 file changed, 21 insertions(+), 8 deletions(-)
17
18 diff --git a/qlop.c b/qlop.c
19 index b75988a..4347699 100644
20 --- a/qlop.c
21 +++ b/qlop.c
22 @@ -279,6 +279,25 @@ static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e)
23 return _elapsed_buf;
24 }
25
26 +struct pkg_match {
27 + char id[BUFSIZ];
28 + depend_atom *atom;
29 + time_t tbegin;
30 + time_t time;
31 + size_t cnt;
32 +};
33 +
34 +static int
35 +pkg_sort_cb(const void *l, const void *r)
36 +{
37 + struct pkg_match *pl = *(struct pkg_match **)l;
38 + struct pkg_match *pr = *(struct pkg_match **)r;
39 + depend_atom *al = pl->atom;
40 + depend_atom *ar = pr->atom;
41 +
42 + return atom_compar_cb(al, ar);
43 +}
44 +
45 /* The format of the sync log has changed over time.
46
47 Old format:
48 @@ -348,14 +367,6 @@ static int do_emerge_log(
49 size_t parallel_emerge = 0;
50 bool all_atoms = false;
51 char afmt[BUFSIZ];
52 -
53 - struct pkg_match {
54 - char id[BUFSIZ];
55 - depend_atom *atom;
56 - time_t tbegin;
57 - time_t time;
58 - size_t cnt;
59 - };
60 struct pkg_match *pkg;
61 struct pkg_match *pkgw;
62
63 @@ -917,6 +928,7 @@ static int do_emerge_log(
64 DECLARE_ARRAY(avgs);
65
66 values_set(merge_averages, avgs);
67 + xarraysort(avgs, pkg_sort_cb);
68 array_for_each(avgs, i, pkg) {
69 printf("%s: %s average for %s%zd%s merge%s\n",
70 atom_format(flags->fmt, pkg->atom),
71 @@ -928,6 +940,7 @@ static int do_emerge_log(
72 xarrayfree_int(avgs);
73
74 values_set(unmerge_averages, avgs);
75 + xarraysort(avgs, pkg_sort_cb);
76 array_for_each(avgs, i, pkg) {
77 printf("%s: %s average for %s%zd%s unmerge%s\n",
78 atom_format(flags->fmt, pkg->atom),