summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mandoc/term.c28
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;
}