From 10049d33a55ba7de87b15f720dc2c9dcb32859d9 Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Fri, 10 Jun 2011 04:22:59 +0100 Subject: [PATCH] fold: fix empty lines --- fold.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fold.c b/fold.c index 649ea55..77e5820 100644 --- a/fold.c +++ b/fold.c @@ -62,9 +62,9 @@ void foldline(const char *str, long width) { bool space; - long col, i, j, n; + long col, j, i = 0, n = 0; - for(i = n = 0; str[i] && str[i] != '\n'; i = n) { + do { space = false; for(j = i, col = 0; str[j] && col <= width; j++) { if(!UTF8_POINT(str[j]) && !bflag) @@ -95,5 +95,5 @@ foldline(const char *str, long width) eprintf(": write error:"); if(str[n]) putchar('\n'); - } + } while(str[i = n] && str[i] != '\n'); }