fold: fix empty lines

This commit is contained in:
Connor Lane Smith 2011-06-10 04:22:59 +01:00
parent 6be3e82218
commit 10049d33a5

6
fold.c
View File

@ -62,9 +62,9 @@ void
foldline(const char *str, long width) foldline(const char *str, long width)
{ {
bool space; 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; space = false;
for(j = i, col = 0; str[j] && col <= width; j++) { for(j = i, col = 0; str[j] && col <= width; j++) {
if(!UTF8_POINT(str[j]) && !bflag) if(!UTF8_POINT(str[j]) && !bflag)
@ -95,5 +95,5 @@ foldline(const char *str, long width)
eprintf("<stdout>: write error:"); eprintf("<stdout>: write error:");
if(str[n]) if(str[n])
putchar('\n'); putchar('\n');
} } while(str[i = n] && str[i] != '\n');
} }