summaryrefslogtreecommitdiff
path: root/src/fmt.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-04-29 01:28:06 +0000
committerJim Meyering <jim@meyering.net>1996-04-29 01:28:06 +0000
commit5a5938db828ab6059f7600692f5c5006873b9bcc (patch)
tree26b55b3a4384be7de67ce442e686b4d165cf9002 /src/fmt.c
parent3c57cea2ce769f8e0fdf2e65bb6ce484f60a7ae2 (diff)
downloadcoreutils-5a5938db828ab6059f7600692f5c5006873b9bcc.tar.xz
(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.
Diffstat (limited to 'src/fmt.c')
-rw-r--r--src/fmt.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/fmt.c b/src/fmt.c
index 534bdb13d..6c7b569ce 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)
{