diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-01-01 17:58:21 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-01-01 17:58:21 +0100 |
commit | 3496545358da0b95880615ead581c13f91b1b5f9 (patch) | |
tree | e321859ec1387ad54c481491980a357f7d798a20 /mflow.c | |
parent | a60147f633cdd13411bb4a1ecd4cbcb666c1d804 (diff) | |
download | mblaze-3496545358da0b95880615ead581c13f91b1b5f9.tar.gz mblaze-3496545358da0b95880615ead581c13f91b1b5f9.tar.xz mblaze-3496545358da0b95880615ead581c13f91b1b5f9.zip |
mflow: fixed lines were not wrapped, add test suite
Reported by ninewise.
Diffstat (limited to 'mflow.c')
-rw-r--r-- | mflow.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/mflow.c b/mflow.c index 1013da5..9bed19d 100644 --- a/mflow.c +++ b/mflow.c @@ -30,28 +30,6 @@ chgquote(int quotes) } void -fixed(int quotes, char *line, size_t linelen) -{ - chgquote(quotes); - - if (column && linelen > (size_t)(maxcolumn - column)) { - putchar('\n'); - column = 0; - } - - if (column == 0) { - for (; column < quotes; column++) - putchar('>'); - if (quotes && *line != ' ') - putchar(' '); - } - - fwrite(line, 1, linelen, stdout); - putchar('\n'); - column = 0; -} - -void flowed(int quotes, char *line, ssize_t linelen) { chgquote(quotes); @@ -96,6 +74,15 @@ flowed(int quotes, char *line, ssize_t linelen) } } +void +fixed(int quotes, char *line, size_t linelen) +{ + flowed(quotes, line, linelen); + + putchar('\n'); + column = 0; +} + int main(int argc, char *argv[]) { @@ -200,6 +187,11 @@ main(int argc, char *argv[]) if (delsp) line[--rd] = 0; flowed(quotes, line, rd); + } else if (rd == 0) { // empty line is fixed + if (column > 0) + putchar('\n'); + putchar('\n'); + column = 0; } else { if (force && rd > maxcolumn) { flowed(quotes, line, rd); |