mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Ticket #3666: Improper use of IEC and SI prefixes for size in size_trunc().
size_trunc() has been aligned to properly use either IEC or SI prefixes with the unit B (byte). Additionally always put a space between number and unit which is required by the norms. Obsolete gettext message ids have been removed and some cleaned up for duplicate words or leading spaces. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
c2e1ec81f6
commit
b3867a6e15
12
lib/util.c
12
lib/util.c
@ -346,26 +346,26 @@ size_trunc (uintmax_t size, gboolean use_si)
|
||||
{
|
||||
static char x[BUF_TINY];
|
||||
uintmax_t divisor = 1;
|
||||
const char *xtra = "";
|
||||
const char *xtra = _("B");
|
||||
|
||||
if (size > 999999999UL)
|
||||
{
|
||||
divisor = use_si ? 1000 : 1024;
|
||||
xtra = use_si ? "k" : "K";
|
||||
xtra = use_si ? _("kB") : _("KiB");
|
||||
|
||||
if (size / divisor > 999999999UL)
|
||||
{
|
||||
divisor = use_si ? (1000 * 1000) : (1024 * 1024);
|
||||
xtra = use_si ? "m" : "M";
|
||||
xtra = use_si ? _("MB") : _("MiB");
|
||||
|
||||
if (size / divisor > 999999999UL)
|
||||
{
|
||||
divisor = use_si ? (1000 * 1000 * 1000) : (1024 * 1024 * 1024);
|
||||
xtra = use_si ? "g" : "G";
|
||||
xtra = use_si ? _("GB") : _("GiB");
|
||||
}
|
||||
}
|
||||
}
|
||||
g_snprintf (x, sizeof (x), "%.0f%s", 1.0 * size / divisor, xtra);
|
||||
g_snprintf (x, sizeof (x), "%.0f %s", 1.0 * size / divisor, xtra);
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ size_trunc_sep (uintmax_t size, gboolean use_si)
|
||||
p += strlen (p) - 1;
|
||||
d = x + sizeof (x) - 1;
|
||||
*d-- = '\0';
|
||||
while (p >= y && isalpha ((unsigned char) *p))
|
||||
while (p >= y && (isalpha ((unsigned char) *p) || (unsigned char) *p == ' '))
|
||||
*d-- = *p--;
|
||||
for (count = 0; p >= y; count++)
|
||||
{
|
||||
|
@ -1079,13 +1079,9 @@ display_total_marked_size (const WPanel * panel, int y, int x, gboolean size_onl
|
||||
buf = size_only ? b_bytes : buffer;
|
||||
cols = w->cols - 2;
|
||||
|
||||
/*
|
||||
* This is a trick to use two ngettext() calls in one sentence.
|
||||
* First make "N bytes", then insert it into "X in M files".
|
||||
*/
|
||||
g_snprintf (b_bytes, sizeof (b_bytes),
|
||||
ngettext ("%s byte", "%s bytes", panel->total),
|
||||
size_trunc_sep (panel->total, panels_options.kilobyte_si));
|
||||
g_strlcpy (b_bytes, size_trunc_sep (panel->total, panels_options.kilobyte_si),
|
||||
sizeof (b_bytes));
|
||||
|
||||
if (!size_only)
|
||||
g_snprintf (buffer, sizeof (buffer),
|
||||
ngettext ("%s in %d file", "%s in %d files", panel->marked),
|
||||
|
Loading…
Reference in New Issue
Block a user