diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-03-06 11:27:56 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-03-06 11:27:56 +0000 |
commit | 3984e51a20588cb7299fc1fc7ffb6030a6b54d2f (patch) | |
tree | 658ff7ed79e3069bce4bb150b31f5ac2e97b5d30 /usr.bin | |
parent | 9e5bcc4e72bbce2480f165e8e2033856cdbfeefa (diff) |
When the last field on an output line is empty, break the line
if and only if something was printed on that line.
This avoids double line breaks after nested lists
while still breaking lines after items with empty body.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/term.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index e84d09a2c8d..9e1a2cfaf63 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.22 2010/03/05 20:46:48 schwarze Exp $ */ +/* $Id: term.c,v 1.23 2010/03/06 11:27:55 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -133,6 +133,7 @@ term_flushln(struct termp *p) int j; /* temporary loop index */ int jhy; /* last hyphen before line overflow */ size_t maxvis, mmax; + static int line_started = 0; static int overstep = 0; /* @@ -158,17 +159,6 @@ term_flushln(struct termp *p) * breaking the line. */ - /* - * If in the standard case (left-justified), then begin with our - * indentation, otherwise (columns, etc.) just start spitting - * out text. - */ - - if ( ! (p->flags & TERMP_NOLPAD)) - /* LINTED */ - for (j = 0; j < (int)p->offset; j++) - putchar(' '); - vis = vend = i = 0; while (i < (int)p->col) { @@ -210,6 +200,15 @@ term_flushln(struct termp *p) break; /* + * Usually, indent the first line of each paragraph. + */ + if (0 == i && ! (p->flags & TERMP_NOLPAD)) + /* LINTED */ + for (j = 0; j < (int)p->offset; j++) + putchar(' '); + line_started = 1; + + /* * Find out whether we would exceed the right margin. * If so, break to the next line. (TODO: hyphenate) * Otherwise, write the chosen number of blanks now. @@ -256,7 +255,10 @@ term_flushln(struct termp *p) overstep = 0; if ( ! (TERMP_NOBREAK & p->flags)) { - putchar('\n'); + if (line_started) { + putchar('\n'); + line_started = 0; + } return; } |