Skip to content

Commit

Permalink
expand: use printable_string instead of hard-coding implementation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Tokarev authored and Denys Vlasenko committed Dec 16, 2013
1 parent 0b3a38b commit 22bb81f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions coreutils/expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 22bb81f

Please sign in to comment.