[hackers] [sbase] cols: simplify filling with spaces || Jakob Kramer

From: <git_AT_suckless.org>
Date: Thu, 05 Jun 2014 12:19:39 +0200

commit 7f7e7dcbb92151e8d0793e62599ffc4c63ec28df
Author: Jakob Kramer <jakob.kramer_AT_gmx.de>
Date: Wed Jun 4 17:46:22 2014 +0200

    cols: simplify filling with spaces
    
    Use printf("%*s", n, "") instead of allocating
    a string filled with spaces.

diff --git a/cols.c b/cols.c
index 411ce58..ca37414 100644
--- a/cols.c
+++ b/cols.c
_AT_@ -26,8 +26,8 @@ int
 main(int argc, char *argv[])
 {
         long i, l, col;
- size_t maxlen = 0;
- char *space;
+ size_t len;
+ int maxlen = 0;
         struct winsize w;
         FILE *fp;
 
_AT_@ -59,7 +59,7 @@ main(int argc, char *argv[])
         }
 
         for(l = 0; l < b.nlines; ++l) {
- size_t len = strlen(b.lines[l]);
+ len = strlen(b.lines[l]);
                 if(len > 0 && b.lines[l][len-1] == '
')
                         b.lines[l][--len] = '
Received on Thu Jun 05 2014 - 12:19:39 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 05 2014 - 12:24:08 CEST