mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2024-11-25 21:00:10 +00:00
Patch bass ackwards behavior of hr flag.
This commit is contained in:
parent
7cd0cfeab6
commit
d98e574d41
@ -201,7 +201,7 @@ struct sysinfo {
|
|||||||
};
|
};
|
||||||
extern int sysinfo (struct sysinfo* info);
|
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 {
|
enum {
|
||||||
KILOBYTE = 1024,
|
KILOBYTE = 1024,
|
||||||
MEGABYTE = (KILOBYTE*1024),
|
MEGABYTE = (KILOBYTE*1024),
|
||||||
|
@ -31,20 +31,23 @@
|
|||||||
static char buffer[10];
|
static char buffer[10];
|
||||||
static const char *suffixes[] = { "", "k", "M", "G", "T" };
|
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;
|
int suffix, base;
|
||||||
|
|
||||||
for (suffix = 0, base = 1; suffix < 5; suffix++, base <<= 10) {
|
if (not_hr)
|
||||||
if (val < (base << 10)) {
|
sprintf(buffer, "%lu", val);
|
||||||
if (suffix && val < 10 * base)
|
else
|
||||||
sprintf(buffer, "%lu.%lu%s", val / base,
|
for (suffix = 0, base = 1; suffix < 5; suffix++, base <<= 10) {
|
||||||
(val % base) * 10 / base, suffixes[suffix]);
|
if (val < (base << 10)) {
|
||||||
else
|
if (suffix && val < 10 * base)
|
||||||
sprintf(buffer, "%lu%s", val / base, suffixes[suffix]);
|
sprintf(buffer, "%lu.%lu%s", val / base,
|
||||||
break;
|
(val % base) * 10 / base, suffixes[suffix]);
|
||||||
|
else
|
||||||
|
sprintf(buffer, "%lu%s", val / base, suffixes[suffix]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ struct sysinfo {
|
|||||||
};
|
};
|
||||||
extern int sysinfo (struct sysinfo* info);
|
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 {
|
enum {
|
||||||
KILOBYTE = 1024,
|
KILOBYTE = 1024,
|
||||||
MEGABYTE = (KILOBYTE*1024),
|
MEGABYTE = (KILOBYTE*1024),
|
||||||
|
Loading…
Reference in New Issue
Block a user