summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2013-12-23 02:19:58 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2013-12-23 02:19:58 +0000
commitecd1d85f01c96067c5b9631832e7634f3cfe65f3 (patch)
treefa0736265d6973fe385d96287147a0167f5b1416 /usr.bin/mandoc/term.c
parenta0d366022a41c3565d5ec25a22bd0cf2603b016a (diff)
Implement a long-standing desideratum,
hanging indentation for .Fn in SYNOPSIS mode, exploiting the new trailspace feature by deliberately *NOT* using it.
Diffstat (limited to 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index bca3dedb110..7f9340661a7 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.72 2013/12/22 23:33:52 schwarze Exp $ */
+/* $Id: term.c,v 1.73 2013/12/23 02:19:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -116,7 +116,12 @@ term_flushln(struct termp *p)
* First, establish the maximum columns of "visible" content.
* This is usually the difference between the right-margin and
* an indentation, but can be, for tagged lists or columns, a
- * small set of values.
+ * small set of values.
+ *
+ * The following unsigned-signed subtractions look strange,
+ * but they are actually correct. If the int p->overstep
+ * is negative, it gets sign extended. Subtracting that
+ * very large size_t effectively adds a small number to dv.
*/
assert (p->rmargin >= p->offset);
dv = p->rmargin - p->offset;
@@ -195,7 +200,11 @@ term_flushln(struct termp *p)
if (0 < ntab)
vbl += ntab * p->tabwidth;
- /* Remove the p->overstep width. */
+ /*
+ * Remove the p->overstep width.
+ * Again, if p->overstep is negative,
+ * sign extension does the right thing.
+ */
bp += (size_t)p->overstep;
p->overstep = 0;
@@ -271,8 +280,10 @@ term_flushln(struct termp *p)
* If we have overstepped the margin, temporarily move
* it to the right and flag the rest of the line to be
* shorter.
+ * If there is a request to keep the columns together,
+ * allow negative overstep when the column is not full.
*/
- if (p->overstep < 0)
+ if (p->trailspace && p->overstep < 0)
p->overstep = 0;
return;