fold -s -wN would infloop for N < 8 with TABs in the input.

E.g., this would not terminate: printf 'a\tb' | fold -w2 -s

(fold_file): Move contents of `else'-block
out of conditional so it's used also for --spaces (-s).
This commit is contained in:
Jim Meyering committed 2003-08-11 14:35:52 +00:00
1 parent 7f502e489c
commit d761e22b60
1 file changed
+6 -7
+6 -7
View File
@@ -1,5 +1,5 @@
/* fold -- wrap each input line to fit in specified width.
Copyright (C) 91, 1995-2002 Free Software Foundation, Inc.
Copyright (C) 91, 1995-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -193,14 +193,13 @@ fold_file (char *filename, int width)
goto rescan;
}
}
else
if (offset_out == 0)
{
if (offset_out == 0)
{
line_out[offset_out++] = c;
continue;
}
line_out[offset_out++] = c;
continue;
}
line_out[offset_out++] = '\n';
fwrite (line_out, sizeof (char), (size_t) offset_out, stdout);
column = offset_out = 0;