expand: use printable_string instead of hard-coding implementation
authorMichael Tokarev <mjt@tls.msk.ru>
Mon, 9 Dec 2013 12:09:35 +0000 (16:09 +0400)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 16 Dec 2013 02:38:24 +0000 (03:38 +0100)
function                                             old     new   delta
expand_main                                          709     690     -19

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/expand.c

index 25bbffc66fc627dd83f6406e70cee1e7a8b859bf..8d376ff4e5260d50f6ed18aea260a3522f3efd5c 100644 (file)
@@ -78,11 +78,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
                                unsigned len;
                                *ptr = '\0';
 # if ENABLE_UNICODE_SUPPORT
-                               {
-                                       uni_stat_t uni_stat;
-                                       printable_string(&uni_stat, ptr_strbeg);
-                                       len = uni_stat.unicode_width;
-                               }
+                               len = unicode_strwidth(ptr_strbeg);
 # else
                                len = ptr - ptr_strbeg;
 # endif
@@ -138,12 +134,9 @@ static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
                        printf("%*s%.*s", len, "", n, ptr);
 # if ENABLE_UNICODE_SUPPORT
                        {
-                               char c;
-                               uni_stat_t uni_stat;
-                               c = ptr[n];
+                               char c = ptr[n];
                                ptr[n] = '\0';
-                               printable_string(&uni_stat, ptr);
-                               len = uni_stat.unicode_width;
+                               len = unicode_strwidth(ptr);
                                ptr[n] = c;
                        }
 # else