]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(copy_rest): Don't copy past end of prefix. Output
authorJim Meyering <jim@meyering.net>
Mon, 29 Apr 1996 01:28:06 +0000 (01:28 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 29 Apr 1996 01:28:06 +0000 (01:28 +0000)
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.

src/fmt.c

index 534bdb13dd3f1cb7d79ae67dbc1a57e66cc3b955..6c7b569ce9d1142ee7d97d374f6bbd1d2c3aee03 100644 (file)
--- 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)
     {