mirror of
https://github.com/jarun/nnn.git
synced 2024-11-20 01:49:14 +00:00
Refactor coolsize
This commit is contained in:
parent
fb4728bc31
commit
e83f4ca62f
|
@ -2027,7 +2027,7 @@ static char *coolsize(off_t size)
|
||||||
|
|
||||||
rem = i = 0;
|
rem = i = 0;
|
||||||
|
|
||||||
while (size > 1024) {
|
while (size >= 1024) {
|
||||||
rem = size & (0x3FF); /* 1024 - 1 = 0x3FF */
|
rem = size & (0x3FF); /* 1024 - 1 = 0x3FF */
|
||||||
size >>= 10;
|
size >>= 10;
|
||||||
++i;
|
++i;
|
||||||
|
@ -2070,9 +2070,9 @@ static char *coolsize(off_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > 0 && i < 6)
|
if (i > 0 && i < 6)
|
||||||
snprintf(size_buf, 12, "%lu.%0*lu%c", (ulong)size, i, (ulong)rem, U[i]);
|
snprintf(size_buf, 12, "%u.%0*u%c", (uint)size, i & 0b11, (uint)rem, U[i]);
|
||||||
else
|
else
|
||||||
snprintf(size_buf, 12, "%lu%c", (ulong)size, U[i]);
|
snprintf(size_buf, 12, "%u%c", (uint)size, U[i]);
|
||||||
|
|
||||||
return size_buf;
|
return size_buf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue