aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-23 02:20:09 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-23 02:20:09 +0000
commit34224dec94613f2de8682103514f13b796cbb181 (patch)
tree91136f003da814dc56e7c47018f372a9f5e6378f /term.c
parent7763823a09119fdfe1ca1e3baef83ca1b5a39713 (diff)
downloadmandoc-34224dec94613f2de8682103514f13b796cbb181.tar.gz
mandoc-34224dec94613f2de8682103514f13b796cbb181.tar.zst
mandoc-34224dec94613f2de8682103514f13b796cbb181.zip
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 'term.c')
-rw-r--r--term.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/term.c b/term.c
index db53c211..3420c70c 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.211 2013/12/22 23:34:13 schwarze Exp $ */
+/* $Id: term.c,v 1.212 2013/12/23 02:20:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -120,7 +120,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;
@@ -199,7 +204,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;
@@ -275,8 +284,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;