]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: use variable lenght printf field width to wprint blanks
authorSami Kerola <kerolasa@iki.fi>
Sat, 3 Aug 2013 23:15:19 +0000 (00:15 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 5 Aug 2013 08:47:42 +0000 (10:47 +0200)
This makes program to run a little faster.  My test input show about 20%
speed improvement.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/column.c

index 2084ba6d12129e588e840a2f87eb03f3dead25d5..2430ede9ec2773e733d1fb0f6b12ec5a54d38e4e 100644 (file)
@@ -308,7 +308,7 @@ wchar_t *local_wcstok(wchar_t * p, const wchar_t * separator, int greedy,
 static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy, wchar_t *colsep)
 {
        TBL *t;
-       int cnt, i;
+       int cnt;
        wchar_t *p, **lp;
        ssize_t *lens;
        ssize_t maxcols = DEFCOLS, coloff;
@@ -347,8 +347,7 @@ static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy,
        for (t = tbl, cnt = 0; cnt < entries; ++cnt, ++t) {
                for (coloff = 0; coloff < t->cols - 1; ++coloff) {
                        fputws(t->list[coloff], stdout);
-                       for (i = lens[coloff] - t->len[coloff]; i > 0; i--)
-                               putwchar(' ');
+                       wprintf(L"%*s", lens[coloff] - t->len[coloff], "");
                        fputws(colsep, stdout);
                }
                if (coloff < t->cols) {