summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-12-04 01:33:24 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-12-04 01:33:24 +0000
commit810e159c720577d2d9b64bd56244b04447c2e8e7 (patch)
treeda82a6afc01c64cca7eb7b1ccebd9d6b1f0b6bb7 /usr.bin
parentcbd78416cb8bc357851a542c35ba8ae79f26e88a (diff)
Ignore macros that never produce any text when deciding whether
vertical whitespace is needed before a section or subsection. Cures groff-mandoc differences in more than 300 manuals, mostly Xenocara, some curses, a few GNU.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/man_term.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 8b7ea97cb1d..0852d2afbbc 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.110 2014/12/02 10:07:17 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.111 2014/12/04 01:33:23 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -121,7 +121,7 @@ static const struct termact termacts[MAN_MAX] = {
{ NULL, NULL, 0 }, /* RE */
{ pre_RS, post_RS, 0 }, /* RS */
{ pre_ign, NULL, 0 }, /* DT */
- { pre_ign, NULL, 0 }, /* UC */
+ { pre_ign, NULL, MAN_NOTEXT }, /* UC */
{ pre_PD, NULL, MAN_NOTEXT }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
@@ -776,12 +776,18 @@ pre_SS(DECL_ARGS)
mt->fl &= ~MANT_LITERAL;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
mt->offset = term_len(p, p->defindent);
- /* If following a prior empty `SS', no vspace. */
- if (n->prev && MAN_SS == n->prev->tok)
- if (NULL == n->prev->body->child)
- break;
- if (NULL == n->prev)
+
+ /*
+ * No vertical space before the first subsection
+ * and after an empty subsection.
+ */
+
+ do {
+ n = n->prev;
+ } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT);
+ if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL))
break;
+
for (i = 0; i < mt->pardist; i++)
term_vspace(p);
break;
@@ -825,13 +831,18 @@ pre_SH(DECL_ARGS)
mt->fl &= ~MANT_LITERAL;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
mt->offset = term_len(p, p->defindent);
- /* If following a prior empty `SH', no vspace. */
- if (n->prev && MAN_SH == n->prev->tok)
- if (NULL == n->prev->body->child)
- break;
- /* If the first macro, no vspae. */
- if (NULL == n->prev)
+
+ /*
+ * No vertical space before the first section
+ * and after an empty section.
+ */
+
+ do {
+ n = n->prev;
+ } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT);
+ if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL))
break;
+
for (i = 0; i < mt->pardist; i++)
term_vspace(p);
break;