From e17764c8fb566f85020217dd8fd05fb6bc227e98 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 30 Jan 2010 23:16:21 +0100 Subject: further work on unicodization Signed-off-by: Denys Vlasenko --- modutils/lsmod.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'modutils') diff --git a/modutils/lsmod.c b/modutils/lsmod.c index cc6b6162f..50621c245 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c @@ -46,9 +46,6 @@ 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 init_unicode(); printf("%-24sSize Used by", "Module"); @@ -64,9 +61,13 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) } else token[3] = (char *) ""; # if ENABLE_FEATURE_ASSUME_UNICODE - name_len = unicode_strlen(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]); + { + uni_stat_t uni_stat; + char *uni_name = unicode_conv_to_printable(&uni_stat, token[0]); + unsigned pad_len = (uni_stat.unicode_width > 19) ? 0 : 19 - uni_stat.unicode_width; + printf("%s%*s %8s %2s %s\n", uni_name, pad_len, "", token[1], token[2], token[3]); + free(uni_name); + } # else printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]); # endif @@ -78,9 +79,13 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) // so trimming the trailing char is just what we need! token[3][strlen(token[3])-1] = '\0'; # if ENABLE_FEATURE_ASSUME_UNICODE - name_len = unicode_strlen(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]); + { + uni_stat_t uni_stat; + char *uni_name = unicode_conv_to_printable(&uni_stat, token[0]); + unsigned pad_len = (uni_stat.unicode_width > 19) ? 0 : 19 - uni_stat.unicode_width; + printf("%s%*s %8s %2s %s\n", uni_name, pad_len, "", token[1], token[2], token[3]); + free(uni_name); + } # else printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]); # endif -- cgit v1.2.3