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: Tue, 03 Apr 2018 13:39:42
Message-Id: 1522761930.d01affcd8541a539a7e5b329efef1cc49f31569f.grobian@gentoo
1 commit: d01affcd8541a539a7e5b329efef1cc49f31569f
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Tue Apr 3 13:25:30 2018 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Tue Apr 3 13:25:30 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d01affcd
7
8 qsize: use make_human_readable_str to format sizes by default
9
10 This way, sizes are by default converted to the unit that matches the
11 quantity of the value. This behaviour can be overridden by the -b, -k
12 and -m options for constant values. Simplifies code, and makes it
13 easier to grasp for humans.
14
15 qsize.c | 27 ++++++++-------------------
16 1 file changed, 8 insertions(+), 19 deletions(-)
17
18 diff --git a/qsize.c b/qsize.c
19 index 9cd66cf..c485aa6 100644
20 --- a/qsize.c
21 +++ b/qsize.c
22 @@ -1,5 +1,5 @@
23 /*
24 - * Copyright 2005-2014 Gentoo Foundation
25 + * Copyright 2005-2018 Gentoo Foundation
26 * Distributed under the terms of the GNU General Public License v2
27 *
28 * Copyright 2005-2010 Ned Ludd - <solar@g.o>
29 @@ -120,15 +120,9 @@ qsize_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
30 num_files, num_nonfiles);
31 if (num_ignored)
32 printf("%'zu names-ignored, ", num_ignored);
33 - if (state->disp_units)
34 - printf("%s %s\n",
35 - make_human_readable_str(num_bytes, 1, state->disp_units),
36 - state->str_disp_units);
37 - else
38 - printf("%'"PRIu64"%s%"PRIu64" KiB\n",
39 - num_bytes / KILOBYTE,
40 - decimal_point,
41 - ((num_bytes % KILOBYTE) * 1000) / KILOBYTE);
42 + printf("%s %s\n",
43 + make_human_readable_str(num_bytes, 1, state->disp_units),
44 + state->disp_units ? state->str_disp_units : "");
45 }
46
47 return EXIT_SUCCESS;
48 @@ -194,15 +188,10 @@ int qsize_main(int argc, char **argv)
49 state.num_all_files, state.num_all_nonfiles);
50 if (state.num_all_ignored)
51 printf("%'zu names-ignored, ", state.num_all_ignored);
52 - if (state.disp_units)
53 - printf("%s %s\n",
54 - make_human_readable_str(state.num_all_bytes, 1, state.disp_units),
55 - state.str_disp_units);
56 - else
57 - printf("%'"PRIu64"%s%"PRIu64" MiB\n",
58 - state.num_all_bytes / MEGABYTE,
59 - decimal_point,
60 - ((state.num_all_bytes % MEGABYTE) * 1000) / MEGABYTE);
61 + printf("%s %s\n",
62 + make_human_readable_str(
63 + state.num_all_bytes, 1, state.disp_units),
64 + state.disp_units ? state.str_disp_units : "");
65 }
66
67 array_for_each(state.atoms, i, atom)