aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Heinrich <heinrich.tomas@gmail.com>2009-10-19 23:58:31 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-26 12:35:30 +0100
commitd31a8793ebedb53b686c9ea01be33d3d564760b9 (patch)
treede10dbc47e66c78aeb8e962106c82347d220a805
parent0f91b3d0dc85af558306f65666779c9deae5fe4a (diff)
downloadbusybox-w32-d31a8793ebedb53b686c9ea01be33d3d564760b9.tar.gz
busybox-w32-d31a8793ebedb53b686c9ea01be33d3d564760b9.tar.bz2
busybox-w32-d31a8793ebedb53b686c9ea01be33d3d564760b9.zip
lsmod: unicode-aware column formatting
Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--modutils/lsmod.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index 87dd1fcba..50a7897ce 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include "libbb.h" 11#include "libbb.h"
12#include "unicode.h"
12 13
13#if ENABLE_FEATURE_CHECK_TAINTED_MODULE 14#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
14enum { 15enum {
@@ -46,6 +47,11 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
46#if ENABLE_FEATURE_LSMOD_PRETTY_2_6_OUTPUT 47#if ENABLE_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
47 char *token[4]; 48 char *token[4];
48 parser_t *parser = config_open("/proc/modules"); 49 parser_t *parser = config_open("/proc/modules");
50#if ENABLE_FEATURE_ASSUME_UNICODE
51 size_t name_len;
52#endif
53 check_unicode_in_env();
54
49 printf("%-24sSize Used by", "Module"); 55 printf("%-24sSize Used by", "Module");
50 check_tainted(); 56 check_tainted();
51 57
@@ -58,7 +64,13 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
58 token[3][strlen(token[3])-1] = '\0'; 64 token[3][strlen(token[3])-1] = '\0';
59 } else 65 } else
60 token[3] = (char *) ""; 66 token[3] = (char *) "";
67#if ENABLE_FEATURE_ASSUME_UNICODE
68 name_len = bb_mbstrlen(token[0]);
69 name_len = (name_len > 19) ? 0 : 19 - name_len;
70 printf("%s%*s %8s %2s %s\n", token[0], name_len, "", token[1], token[2], token[3]);
71#else
61 printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]); 72 printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]);
73#endif
62 } 74 }
63 } else { 75 } else {
64 while (config_read(parser, token, 4, 4, "# \t", PARSE_NORMAL & ~PARSE_GREEDY)) { 76 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)
66 // or comma-separated list ended by comma 78 // or comma-separated list ended by comma
67 // so trimming the trailing char is just what we need! 79 // so trimming the trailing char is just what we need!
68 token[3][strlen(token[3])-1] = '\0'; 80 token[3][strlen(token[3])-1] = '\0';
81#if ENABLE_FEATURE_ASSUME_UNICODE
82 name_len = bb_mbstrlen(token[0]);
83 name_len = (name_len > 19) ? 0 : 19 - name_len;
84 printf("%s%*s %8s %2s %s\n", token[0], name_len, "", token[1], token[2], token[3]);
85#else
69 printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]); 86 printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]);
87#endif
70 } 88 }
71 } 89 }
72 if (ENABLE_FEATURE_CLEAN_UP) 90 if (ENABLE_FEATURE_CLEAN_UP)