summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorTomas Heinrich2009-10-19 23:58:31 +0200
committerDenys Vlasenko2009-10-26 12:35:30 +0100
commitd31a8793ebedb53b686c9ea01be33d3d564760b9 (patch)
treede10dbc47e66c78aeb8e962106c82347d220a805 /modutils
parent0f91b3d0dc85af558306f65666779c9deae5fe4a (diff)
downloadbusybox-d31a8793ebedb53b686c9ea01be33d3d564760b9.zip
busybox-d31a8793ebedb53b686c9ea01be33d3d564760b9.tar.gz
lsmod: unicode-aware column formatting
Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils')
-rw-r--r--modutils/lsmod.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index 87dd1fc..50a7897 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -9,6 +9,7 @@
*/
#include "libbb.h"
+#include "unicode.h"
#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
enum {
@@ -46,6 +47,11 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
#if ENABLE_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
char *token[4];
parser_t *parser = config_open("/proc/modules");
+#if ENABLE_FEATURE_ASSUME_UNICODE
+ size_t name_len;
+#endif
+ check_unicode_in_env();
+
printf("%-24sSize Used by", "Module");
check_tainted();
@@ -58,7 +64,13 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
token[3][strlen(token[3])-1] = '\0';
} else
token[3] = (char *) "";
+#if ENABLE_FEATURE_ASSUME_UNICODE
+ name_len = bb_mbstrlen(token[0]);
+ name_len = (name_len > 19) ? 0 : 19 - name_len;
+ printf("%s%*s %8s %2s %s\n", token[0], name_len, "", token[1], token[2], token[3]);
+#else
printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]);
+#endif
}
} else {
while (config_read(parser, token, 4, 4, "# \t", PARSE_NORMAL & ~PARSE_GREEDY)) {
@@ -66,7 +78,13 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
// or comma-separated list ended by comma
// so trimming the trailing char is just what we need!
token[3][strlen(token[3])-1] = '\0';
+#if ENABLE_FEATURE_ASSUME_UNICODE
+ name_len = bb_mbstrlen(token[0]);
+ name_len = (name_len > 19) ? 0 : 19 - name_len;
+ printf("%s%*s %8s %2s %s\n", token[0], name_len, "", token[1], token[2], token[3]);
+#else
printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]);
+#endif
}
}
if (ENABLE_FEATURE_CLEAN_UP)