diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-22 15:34:28 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-22 15:34:28 +0200 |
commit | 200d522fb85c24dd1ed36e5fcc29c1140b8b428b (patch) | |
tree | ae1fdb4e3700af96dfc63451e7c52f87fea5fb4b /coreutils | |
parent | 4ff1ce063979a0d9df7ec42823eee4624723ab58 (diff) | |
download | busybox-w32-200d522fb85c24dd1ed36e5fcc29c1140b8b428b.tar.gz busybox-w32-200d522fb85c24dd1ed36e5fcc29c1140b8b428b.tar.bz2 busybox-w32-200d522fb85c24dd1ed36e5fcc29c1140b8b428b.zip |
df: unicode-aware column formatting. By Tomas Heinrich (theinric AT redhat.com)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/df.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/coreutils/df.c b/coreutils/df.c index 4bbfe943b..c37b18893 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <mntent.h> | 25 | #include <mntent.h> |
26 | #include <sys/vfs.h> | 26 | #include <sys/vfs.h> |
27 | #include "libbb.h" | 27 | #include "libbb.h" |
28 | #include "unicode.h" | ||
28 | 29 | ||
29 | #if !ENABLE_FEATURE_HUMAN_READABLE | 30 | #if !ENABLE_FEATURE_HUMAN_READABLE |
30 | static unsigned long kscale(unsigned long b, unsigned long bs) | 31 | static unsigned long kscale(unsigned long b, unsigned long bs) |
@@ -57,6 +58,8 @@ int df_main(int argc, char **argv) | |||
57 | const char *disp_units_hdr = NULL; | 58 | const char *disp_units_hdr = NULL; |
58 | char *chp; | 59 | char *chp; |
59 | 60 | ||
61 | check_unicode_in_env(); | ||
62 | |||
60 | #if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY | 63 | #if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY |
61 | opt_complementary = "k-mB:m-Bk:B-km"; | 64 | opt_complementary = "k-mB:m-Bk:B-km"; |
62 | #elif ENABLE_FEATURE_HUMAN_READABLE | 65 | #elif ENABLE_FEATURE_HUMAN_READABLE |
@@ -108,6 +111,9 @@ int df_main(int argc, char **argv) | |||
108 | while (1) { | 111 | while (1) { |
109 | const char *device; | 112 | const char *device; |
110 | const char *mount_point; | 113 | const char *mount_point; |
114 | #if ENABLE_FEATURE_ASSUME_UNICODE | ||
115 | size_t dev_len; | ||
116 | #endif | ||
111 | 117 | ||
112 | if (mount_table) { | 118 | if (mount_table) { |
113 | mount_entry = getmntent(mount_table); | 119 | mount_entry = getmntent(mount_table); |
@@ -169,8 +175,18 @@ int df_main(int argc, char **argv) | |||
169 | } | 175 | } |
170 | #endif | 176 | #endif |
171 | 177 | ||
178 | #if ENABLE_FEATURE_ASSUME_UNICODE | ||
179 | dev_len = bb_mbstrlen(device); | ||
180 | if (dev_len > 20) { | ||
181 | printf("%s\n%20s", device, ""); | ||
182 | } else { | ||
183 | printf("%s%*s", device, 20 - dev_len, ""); | ||
184 | } | ||
185 | #else | ||
172 | if (printf("\n%-20s" + 1, device) > 20) | 186 | if (printf("\n%-20s" + 1, device) > 20) |
173 | printf("\n%-20s", ""); | 187 | printf("\n%-20s", ""); |
188 | #endif | ||
189 | |||
174 | #if ENABLE_FEATURE_HUMAN_READABLE | 190 | #if ENABLE_FEATURE_HUMAN_READABLE |
175 | printf(" %9s ", | 191 | printf(" %9s ", |
176 | make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); | 192 | make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); |