]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(human_readable): Support human_space_before_unit.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 16 Nov 2004 07:53:08 +0000 (07:53 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 16 Nov 2004 07:53:08 +0000 (07:53 +0000)
lib/human.c

index f024c73ea079f93b7f8b9a3a1362e8db91454607..4960876dd470abd338787ce8f496cb4433adf653 100644 (file)
@@ -158,6 +158,9 @@ group_number (char *number, size_t numberlen,
    so on.  Numbers smaller than the power aren't modified.
    human_autoscale is normally used together with human_SI.
 
+   If (OPTS & human_space_before_unit), use a space to separate the
+   number from any suffix that is appended as described below.
+
    If (OPTS & human_SI), append an SI prefix indicating which power is
    being used.  If in addition (OPTS & human_B), append "B" (if base
    1000) or "iB" (if base 1024) to the SI prefix.  When ((OPTS &
@@ -384,6 +387,9 @@ human_readable (uintmax_t n, char *buf, int opts,
              break;
        }
 
+      if ((exponent | (opts & human_B)) && (opts & human_space_before_unit))
+       *psuffix++ = ' ';
+
       if (exponent)
        *psuffix++ = (! (opts & human_base_1024) && exponent == 1
                      ? 'k'