From: Jim Meyering Date: Mon, 29 Apr 1996 01:28:06 +0000 (+0000) Subject: (copy_rest): Don't copy past end of prefix. Output X-Git-Tag: TEXTUTILS-1_14d~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a5938db828ab6059f7600692f5c5006873b9bcc;p=thirdparty%2Fcoreutils.git (copy_rest): Don't copy past end of prefix. Output trailing spaces if the prefix had any. Before, the command perl -e 'print "| S";' |fmt -p' | '|tr '\0' @ output `|@S'. Reported by François Pinard. --- diff --git a/src/fmt.c b/src/fmt.c index 534bdb13dd..6c7b569ce9 100644 --- a/src/fmt.c +++ b/src/fmt.c @@ -575,8 +575,9 @@ copy_rest (FILE *f, register int c) if (in_column > next_prefix_indent && c != '\n' && c != EOF) { put_space (next_prefix_indent); - for (s = prefix; out_column != in_column; out_column++) + for (s = prefix; out_column != in_column && *s; out_column++) putchar (*s++); + put_space (in_column - out_column); } while (c != '\n' && c != EOF) {