mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
size_trunc_len() generates incorrect result in some cases.
Revert "(size_trunc_len): support automatic maximum unit for specified size."
This reverts commit ef94b84eaf
.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
7b5b41147d
commit
ceff7c5922
11
lib/util.c
11
lib/util.c
@ -407,7 +407,6 @@ size_trunc_sep (uintmax_t size, gboolean use_si)
|
|||||||
*
|
*
|
||||||
* Units: size units (filesystem sizes are 1K blocks)
|
* Units: size units (filesystem sizes are 1K blocks)
|
||||||
* 0=bytes, 1=Kbytes, 2=Mbytes, etc.
|
* 0=bytes, 1=Kbytes, 2=Mbytes, etc.
|
||||||
* -1 means maximum possible unit for specified size
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -464,16 +463,6 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
|
|||||||
len = 9;
|
len = 9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* find maximum unit */
|
|
||||||
if (units < 0)
|
|
||||||
{
|
|
||||||
const unsigned int divider = use_si ? 1000 : 1024;
|
|
||||||
uintmax_t size_remain = size;
|
|
||||||
|
|
||||||
for (units = 0; size_remain >= divider; units++)
|
|
||||||
size_remain /= divider;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* recalculate from 1024 base to 1000 base if units>0
|
* recalculate from 1024 base to 1000 base if units>0
|
||||||
* We can't just multiply by 1024 - that might cause overflow
|
* We can't just multiply by 1024 - that might cause overflow
|
||||||
|
Loading…
Reference in New Issue
Block a user