summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-04-11 17:11:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-04-11 17:11:13 +0000
commit0609782211f70e20c352ca9e580e328fc5817302 (patch)
tree9361b81eef562a0a60f08897828d866c60a1b5e4 /mdoc_term.c
parent37f94bbdf74663ed1f212a4a0aa87e4faf4ca885 (diff)
downloadmandoc-0609782211f70e20c352ca9e580e328fc5817302.tar.gz
preserve comments before .Dd when converting mdoc(7) to man(7)
with mandoc -Tman; suggested by Thomas Klausner <wiz at NetBSD>
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 056c5069..f61bbb1e 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -283,7 +283,9 @@ 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)
+ while (n != NULL &&
+ (n->type == ROFFT_COMMENT ||
+ n->flags & NODE_NOPRT))
n = n->next;
if (n != NULL) {
if (n->tok != MDOC_Sh)
@@ -312,7 +314,7 @@ print_mdoc_node(DECL_ARGS)
struct termpair npair;
size_t offset, rmargin;
- if (n->flags & NODE_NOPRT)
+ if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
return;
chld = 1;
@@ -567,7 +569,9 @@ print_bvspace(struct termp *p,
/* Do not vspace directly after Ss/Sh. */
nn = n;
- while (nn->prev != NULL && nn->prev->flags & NODE_NOPRT)
+ while (nn->prev != NULL &&
+ (nn->prev->type == ROFFT_COMMENT ||
+ nn->prev->flags & NODE_NOPRT))
nn = nn->prev;
while (nn->prev == NULL) {
do {
@@ -1550,7 +1554,8 @@ termp_ss_pre(DECL_ARGS)
case ROFFT_BLOCK:
term_newln(p);
for (nn = n->prev; nn != NULL; nn = nn->prev)
- if ((nn->flags & NODE_NOPRT) == 0)
+ if (nn->type != ROFFT_COMMENT &&
+ (nn->flags & NODE_NOPRT) == 0)
break;
if (nn != NULL)
term_vspace(p);