aboutsummaryrefslogtreecommitdiff
path: root/coreutils/df.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-13 01:25:09 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-13 01:25:09 +0200
commit0bf44d00a42dec70514c2e51926f4ca37b4b2367 (patch)
treebe01fbf44da8040c5ef271e0d0bba147ce0c525e /coreutils/df.c
parent76ace254e171ee9ca7a13f36335ccad9cc6ae6e1 (diff)
downloadbusybox-w32-0bf44d00a42dec70514c2e51926f4ca37b4b2367.tar.gz
busybox-w32-0bf44d00a42dec70514c2e51926f4ca37b4b2367.tar.bz2
busybox-w32-0bf44d00a42dec70514c2e51926f4ca37b4b2367.zip
libbb/human_readable.c: shrink; and reduce bss usage
also, move smart_ulltoaN there and comment usage locations function old new delta static.unit_chars 7 9 +2 utoa_to_buf 110 108 -2 make_human_readable_str 262 258 -4 fallbackSort 1723 1719 -4 static.fmt 97 92 -5 static.fmt_tenths 10 - -10 static.str 21 4 -17 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/5 up/down: 2/-42) Total: -40 bytes text data bss dec hex filename 820981 453 6932 828366 ca3ce busybox_old 820968 453 6916 828337 ca3b1 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/df.c')
-rw-r--r--coreutils/df.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index c37b18893..624ad94ba 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -92,7 +92,10 @@ int df_main(int argc, char **argv)
92 if (disp_units_hdr == NULL) { 92 if (disp_units_hdr == NULL) {
93#if ENABLE_FEATURE_HUMAN_READABLE 93#if ENABLE_FEATURE_HUMAN_READABLE
94 disp_units_hdr = xasprintf("%s-blocks", 94 disp_units_hdr = xasprintf("%s-blocks",
95 make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX))); 95 /* print df_disp_hr, show no fractionals,
96 * use suffixes if OPT_POSIX is set in opt */
97 make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX))
98 );
96#else 99#else
97 disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr); 100 disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr);
98#endif 101#endif
@@ -189,21 +192,27 @@ int df_main(int argc, char **argv)
189 192
190#if ENABLE_FEATURE_HUMAN_READABLE 193#if ENABLE_FEATURE_HUMAN_READABLE
191 printf(" %9s ", 194 printf(" %9s ",
195 /* f_blocks x f_bsize / df_disp_hr, show one fractional,
196 * use suffixes if df_disp_hr == 0 */
192 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); 197 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
193 198
194 printf(" %9s " + 1, 199 printf(" %9s " + 1,
200 /* EXPR x f_bsize / df_disp_hr, show one fractional,
201 * use suffixes if df_disp_hr == 0 */
195 make_human_readable_str((s.f_blocks - s.f_bfree), 202 make_human_readable_str((s.f_blocks - s.f_bfree),
196 s.f_bsize, df_disp_hr)); 203 s.f_bsize, df_disp_hr));
197 204
198 printf("%9s %3u%% %s\n", 205 printf("%9s %3u%% %s\n",
199 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), 206 /* f_bavail x f_bsize / df_disp_hr, show one fractional,
200 blocks_percent_used, mount_point); 207 * use suffixes if df_disp_hr == 0 */
208 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
209 blocks_percent_used, mount_point);
201#else 210#else
202 printf(" %9lu %9lu %9lu %3u%% %s\n", 211 printf(" %9lu %9lu %9lu %3u%% %s\n",
203 kscale(s.f_blocks, s.f_bsize), 212 kscale(s.f_blocks, s.f_bsize),
204 kscale(s.f_blocks - s.f_bfree, s.f_bsize), 213 kscale(s.f_blocks - s.f_bfree, s.f_bsize),
205 kscale(s.f_bavail, s.f_bsize), 214 kscale(s.f_bavail, s.f_bsize),
206 blocks_percent_used, mount_point); 215 blocks_percent_used, mount_point);
207#endif 216#endif
208 } 217 }
209 } 218 }