summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-01-10 12:54:29 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-01-10 12:54:29 +0000
commitc53de85976eb23ce439737adc25a952aece3db20 (patch)
tree669698d57cd7d637acfd0a83d40fa96714799193 /usr.bin/mandoc/mdoc_term.c
parent0761931691e27db6d4e2cbd44442279635d029f3 (diff)
Introduce flags NODE_NOSRC and NODE_NOPRT for AST nodes.
Use them to mark generated nodes and nodes that shall not produce output. Let -Ttree output mode display these new flags. Use NODE_NOSRC for .Ar, .Mt, and .Pa default arguments. Use NODE_NOPRT for .Dd, .Dt, and .Os. These will help to make handling of text production macros more rigorous.
Diffstat (limited to 'usr.bin/mandoc/mdoc_term.c')
-rw-r--r--usr.bin/mandoc/mdoc_term.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 86c492efee6..2cadcb519d3 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.235 2016/11/08 16:37:42 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.236 2017/01/10 12:54:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -283,6 +283,8 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc)
p->defindent = 5;
term_begin(p, print_mdoc_head, print_mdoc_foot,
&mdoc->meta);
+ while (n != NULL && n->flags & NODE_NOPRT)
+ n = n->next;
if (n != NULL) {
if (n->tok != MDOC_Sh)
term_vspace(p);
@@ -309,6 +311,9 @@ print_mdoc_node(DECL_ARGS)
struct termpair npair;
size_t offset, rmargin;
+ if (n->flags & NODE_NOPRT)
+ return;
+
chld = 1;
offset = p->offset;
rmargin = p->rmargin;
@@ -562,6 +567,8 @@ print_bvspace(struct termp *p,
/* Do not vspace directly after Ss/Sh. */
nn = n;
+ while (nn->prev != NULL && nn->prev->flags & NODE_NOPRT)
+ nn = nn->prev;
while (nn->prev == NULL) {
do {
nn = nn->parent;
@@ -1716,11 +1723,15 @@ termp_pf_post(DECL_ARGS)
static int
termp_ss_pre(DECL_ARGS)
{
+ struct roff_node *nn;
switch (n->type) {
case ROFFT_BLOCK:
term_newln(p);
- if (n->prev)
+ for (nn = n->prev; nn != NULL; nn = nn->prev)
+ if ((nn->flags & NODE_NOPRT) == 0)
+ break;
+ if (nn != NULL)
term_vspace(p);
break;
case ROFFT_HEAD: