summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai2001-03-28 20:10:25 +0000
committerMatt Kraai2001-03-28 20:10:25 +0000
commitd98e574d4125d7b54516b9fd2f7394fa10dd6eb4 (patch)
treed2efd8a0fe6cdcabe276fffe5c3374ded5ae90d6
parent7cd0cfeab696a4e5b2794dd66541b6d2a6cc3663 (diff)
downloadbusybox-d98e574d4125d7b54516b9fd2f7394fa10dd6eb4.zip
busybox-d98e574d4125d7b54516b9fd2f7394fa10dd6eb4.tar.gz
Patch bass ackwards behavior of hr flag.
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/human_readable.c23
-rw-r--r--libbb/libbb.h2
3 files changed, 15 insertions, 12 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 4c23b2b..b5c8459 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -201,7 +201,7 @@ struct sysinfo {
};
extern int sysinfo (struct sysinfo* info);
-const char *make_human_readable_str(unsigned long val, unsigned long hr);
+const char *make_human_readable_str(unsigned long val, unsigned long not_hr);
enum {
KILOBYTE = 1024,
MEGABYTE = (KILOBYTE*1024),
diff --git a/libbb/human_readable.c b/libbb/human_readable.c
index 1d7a90e..36783fa 100644
--- a/libbb/human_readable.c
+++ b/libbb/human_readable.c
@@ -31,20 +31,23 @@
static char buffer[10];
static const char *suffixes[] = { "", "k", "M", "G", "T" };
-const char *make_human_readable_str(unsigned long val, unsigned long hr)
+const char *make_human_readable_str(unsigned long val, unsigned long not_hr)
{
int suffix, base;
- for (suffix = 0, base = 1; suffix < 5; suffix++, base <<= 10) {
- if (val < (base << 10)) {
- if (suffix && val < 10 * base)
- sprintf(buffer, "%lu.%lu%s", val / base,
- (val % base) * 10 / base, suffixes[suffix]);
- else
- sprintf(buffer, "%lu%s", val / base, suffixes[suffix]);
- break;
+ if (not_hr)
+ sprintf(buffer, "%lu", val);
+ else
+ for (suffix = 0, base = 1; suffix < 5; suffix++, base <<= 10) {
+ if (val < (base << 10)) {
+ if (suffix && val < 10 * base)
+ sprintf(buffer, "%lu.%lu%s", val / base,
+ (val % base) * 10 / base, suffixes[suffix]);
+ else
+ sprintf(buffer, "%lu%s", val / base, suffixes[suffix]);
+ break;
+ }
}
- }
return buffer;
}
diff --git a/libbb/libbb.h b/libbb/libbb.h
index 4c23b2b..b5c8459 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -201,7 +201,7 @@ struct sysinfo {
};
extern int sysinfo (struct sysinfo* info);
-const char *make_human_readable_str(unsigned long val, unsigned long hr);
+const char *make_human_readable_str(unsigned long val, unsigned long not_hr);
enum {
KILOBYTE = 1024,
MEGABYTE = (KILOBYTE*1024),