From d761e22b60aa42e427c7b4f295016cabb64c0099 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 11 Aug 2003 14:35:52 +0000 Subject: 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). --- src/fold.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/fold.c b/src/fold.c index 8caed2f9e..538dcfdab 100644 --- a/src/fold.c +++ b/src/fold.c @@ -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; -- cgit v1.2.3-54-g00ecf