aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c9
-rw-r--r--lib/lib.h8
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 27305ec9..058c6386 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -870,7 +870,7 @@ void names_to_pid(char **names, int (*callback)(pid_t pid, char *name))
int human_readable(char *buf, unsigned long long num, int style)
{
unsigned long long snap = 0;
- int len, unit, divisor = (style&HR_SI) ? 1024 : 1000;
+ int len, unit, divisor = (style&HR_1000) ? 1000 : 1024;
// Divide rounding up until we have 3 or fewer digits. Since the part we
// print is decimal, the test is 999 even when we divide by 1024.
@@ -879,7 +879,7 @@ int human_readable(char *buf, unsigned long long num, int style)
for (unit = 0; num > 999; unit++) num = ((snap = num)+(divisor/2))/divisor;
len = sprintf(buf, "%llu", num);
if (unit && len == 1) {
- // Redo rounding for 1.2M case, this works with HR_SI and not.
+ // Redo rounding for 1.2M case, this works with and without HR_1000.
num = snap/divisor;
snap -= num*divisor;
snap = ((snap*100)+50)/divisor;
@@ -890,10 +890,9 @@ int human_readable(char *buf, unsigned long long num, int style)
if (unit) {
unit = " kMGTPE"[unit];
- if (!(style&HR_SI)) unit = toupper(unit);
+ if (!(style&HR_1000)) unit = toupper(unit);
buf[len++] = unit;
- }
- if (style & HR_B) buf[len++] = 'B';
+ } else if (style & HR_B) buf[len++] = 'B';
buf[len] = 0;
return len;
diff --git a/lib/lib.h b/lib/lib.h
index 41f38d1b..5bfba22a 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -176,13 +176,13 @@ void delete_tempfile(int fdin, int fdout, char **tempname);
void replace_tempfile(int fdin, int fdout, char **tempname);
void crc_init(unsigned int *crc_table, int little_endian);
void base64_init(char *p);
-int yesno(char *prompt, int def);
+int yesno(int def);
int qstrcmp(const void *a, const void *b);
int xpoll(struct pollfd *fds, int nfds, int timeout);
-#define HR_SPACE 1
-#define HR_B 2
-#define HR_SI 4
+#define HR_SPACE 1 // Space between number and units
+#define HR_B 2 // Use "B" for single byte units
+#define HR_1000 4 // Use decimal instead of binary units
int human_readable(char *buf, unsigned long long num, int style);
// interestingtimes.c