[pacman-dev] [PATCH] package.c: prettify package size printing

Allan McRae allan at archlinux.org
Sun Apr 12 06:01:51 UTC 2015


On 12/04/15 15:27, Ganesh Ajjanagadde wrote:
> The motivation was something I observed: when I run pacman -Qi on a
> package, everything is neatly aligned, except for an additional space in
> front of the "Installed size" field of the package. Perhaps limiting this
> change to just the "Installed Size" field would be a better solution?
> 

Bad!  No top posting.

I'm guessing this was originally added to align the various sizes.  That
does not work now (did it ever?).

$ pacman -Si pacman
...
Download Size  : 665.62 KiB
Installed Size : 4472.00 KiB

I'd agree with Andrew's suggestion of just using "%.2f" for the format
specifier.  I'd guess (without testing...) this fixes the "make check"
issue too.

Resubmit the patch with that change and I will pull.

A


> On Sun, Apr 12, 2015 at 12:15 AM, Andrew Gregory <andrew.gregory.8 at gmail.com
>> wrote:
> 
>> On 04/10/15 at 12:42am, Ganesh Ajjanagadde wrote:
>>> Unnecessary whitespace after the colon in the package size field is
>>> removed by left-justifying the size value.
>>>
>>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>>> ---
>>
>> Why keep the width specifier if you want to left-justify the field?
>> Having the extra space between the value and unit looks even stranger:
>>  $ src/pacman/pacman -Si valgrind | grep Size
>>  Download Size  : 7.21   MiB
>>  Installed Size : 61.34  MiB
>>
>> This also breaks a test:
>>  $ make check
>>  1..1
>>  # Running 'query006'
>>  # ==> Generating test environment
>>  # ==> Running test
>>  # ==> Checking rules
>>      1..6
>>      ok 1 - PACMAN_RETCODE=0
>>      ok 2 - PACMAN_OUTPUT=^Name.*overflow
>>      ok 3 - PACMAN_OUTPUT=^Description.*Overflow size and date values if
>> possible
>>      not ok 4 - PACMAN_OUTPUT=^Installed Size.*9.31 GiB
>>      ok 5 - PACMAN_OUTPUT=^Build Date.* 2065
>>      ok 6 - PACMAN_OUTPUT=^Install Date.* 2286
>>  not ok 1 - Query info on a package (overflow long values)
>>  FAIL: test/pacman/tests/query006.py 1 - Query info on a package (overflow
>> long values)
>>
>> apg
>>
>>>  src/pacman/package.c | 6 +++---
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/pacman/package.c b/src/pacman/package.c
>>> index 33184bd..ba4f877 100644
>>> --- a/src/pacman/package.c
>>> +++ b/src/pacman/package.c
>>> @@ -167,10 +167,10 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
>>>
>>>       size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label);
>>>       if(from == ALPM_PKG_FROM_SYNCDB) {
>>> -             printf("%s%s%s %6.2f %s\n", config->colstr.title,
>> _("Download Size  :"),
>>> +             printf("%s%s%s %-6.2f %s\n", config->colstr.title,
>> _("Download Size  :"),
>>>                       config->colstr.nocolor, size, label);
>>>       } else if(from == ALPM_PKG_FROM_FILE) {
>>> -             printf("%s%s%s %6.2f %s\n", config->colstr.title,
>> _("Compressed Size:"),
>>> +             printf("%s%s%s %-6.2f %s\n", config->colstr.title,
>> _("Compressed Size:"),
>>>                       config->colstr.nocolor, size, label);
>>>       } else {
>>>               // autodetect size for "Installed Size"
>>> @@ -178,7 +178,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
>>>       }
>>>
>>>       size = humanize_size(alpm_pkg_get_isize(pkg), label[0], 2, &label);
>>> -     printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed
>> Size :"),
>>> +     printf("%s%s%s %-6.2f %s\n", config->colstr.title, _("Installed
>> Size :"),
>>>                       config->colstr.nocolor, size, label);
>>>
>>>       string_display(_("Packager       :"), alpm_pkg_get_packager(pkg),
>> cols);
>>> --
>>> 2.3.5
>>
> 
> 


More information about the pacman-dev mailing list