diff options
author | G.P. Halkes <buscom@ghalkes.nl> | 2007-01-06 09:49:47 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-01-06 09:49:47 +0100 |
commit | 37bcc2770788d8fd9fd8cda3413a27dd131d9e22 (patch) | |
tree | bdf13bcd0a2e2038eb61ae220b76dda808ae49a2 /src/fmt.c | |
parent | ab58de37e6e01b22acc49f72b109b6e910f5190a (diff) | |
download | coreutils-37bcc2770788d8fd9fd8cda3413a27dd131d9e22.tar.xz |
* src/fmt.c (copy_rest): Correct prefix handling.
Don't elide a line with the prefix followed by only white space.
(get_line): Move EOF-check to loop-termination condition.
* tests/fmt/basic (pfx-1): Adjust test to expect desired result.
(pfx-2): Remove test; its premise was contrary to the documentation.
Diffstat (limited to 'src/fmt.c')
-rw-r--r-- | src/fmt.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -607,12 +607,15 @@ copy_rest (FILE *f, int c) const char *s; out_column = 0; - if (in_column > next_prefix_indent && c != '\n' && c != EOF) + if (in_column > next_prefix_indent || (c != '\n' && c != EOF)) { put_space (next_prefix_indent); for (s = prefix; out_column != in_column && *s; out_column++) putchar (*s++); - put_space (in_column - out_column); + if (c != EOF && c != '\n') + put_space (in_column - out_column); + if (c == EOF && in_column >= next_prefix_indent + prefix_length) + putchar ('\n'); } while (c != '\n' && c != EOF) { @@ -688,10 +691,8 @@ get_line (FILE *f, int c) flush_paragraph (); } word_limit++; - if (c == EOF) - return EOF; } - while (c != '\n'); + while (c != '\n' && c != EOF); return get_prefix (f); } |