Fix byte prefix at low rates so it is two spaces, not one

This commit is contained in:
Andrew Wood
2023-07-23 17:13:14 +01:00
parent 909355619b
commit c39e97ec5a
2 changed files with 8 additions and 2 deletions
+1
View File
@@ -1,4 +1,5 @@
0.0.20230723-UNRELEASED
* fix: correct byte prefix size to 2 spaces in rate display, so progress display size remains constant at low transfer rates
* cleanup: Rewrote `configure.in` as per suggestions in newer "`autoconf`" manuals
* cleanup: replaced `header.in` with one generated by "`autoheader`", moving custom logic to a separate header file "`config-aux.h`"
* cleanup: added copyright notice to all source files as per GNU standards
+7 -2
View File
@@ -199,8 +199,13 @@ static void pv__si_prefix(long double *value, char *prefix,
prefix[0] = *i;
}
if (is_bytes && prefix[0] != ' ') {
prefix[1] = 'i';
/*
* Byte prefixes are of the form "KiB" rather than "KB", so that's
* two characters, not one - meaning that for just "B", the prefix
* is two spaces, not one.
*/
if (is_bytes) {
prefix[1] = (prefix[0] == ' ' ? ' ' : 'i');
prefix[2] = 0;
}
}