summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-24 20:45:27 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-24 20:45:27 +0000
commit472637a00de4c03052114688d7473918eb455561 (patch)
treee3ad1192f26e0fec58145953e745e833430faacd
parent8d226e7d9f28fbbca5bd6969e8fe3e6ee69ec94e (diff)
downloadmandoc-472637a00de4c03052114688d7473918eb455561.tar.gz
It turns out SYNOPSIS mode does not imply .Bk in general,
but only within .Nm blocks. Simplify the code accordingly. Triggered by research done by Franco Fichtner.
-rw-r--r--mdoc_html.c2
-rw-r--r--mdoc_macro.c3
-rw-r--r--mdoc_man.c35
-rw-r--r--mdoc_term.c25
4 files changed, 27 insertions, 38 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index c25b009c..02390c42 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -459,7 +459,7 @@ print_mdoc_node(MDOC_ARGS)
break;
}
- if (HTML_KEEP & h->flags || MDOC_SYNPRETTY & n->flags) {
+ if (HTML_KEEP & h->flags) {
if (n->prev ? (n->prev->lastline != n->line) :
(n->parent && n->parent->line != n->line)) {
h->flags &= ~HTML_KEEP;
diff --git a/mdoc_macro.c b/mdoc_macro.c
index fd3f8764..cc75b7e7 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -713,8 +713,7 @@ blk_exp_close(MACRO_PROT_ARGS)
maxargs = 1;
break;
case (MDOC_Ek):
- if ( ! (MDOC_SYNOPSIS & mdoc->flags))
- mdoc->flags &= ~MDOC_KEEP;
+ mdoc->flags &= ~MDOC_KEEP;
default:
maxargs = 0;
break;
diff --git a/mdoc_man.c b/mdoc_man.c
index 7c342bd7..a94d521e 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -705,24 +705,12 @@ static int
pre_sect(DECL_ARGS)
{
- switch (n->type) {
- case (MDOC_HEAD):
+ if (MDOC_HEAD == n->type) {
outflags |= MMAN_sp;
print_block(manacts[n->tok].prefix, 0);
print_word("");
putchar('\"');
outflags &= ~MMAN_spc;
- break;
- case (MDOC_BODY):
- if (MDOC_Sh == n->tok) {
- if (MDOC_SYNPRETTY & n->flags)
- outflags |= MMAN_Bk;
- else
- outflags &= ~MMAN_Bk;
- }
- break;
- default:
- break;
}
return(1);
}
@@ -900,7 +888,7 @@ static void
post_bk(DECL_ARGS)
{
- if (MDOC_BODY == n->type && ! (MDOC_SYNPRETTY & n->flags))
+ if (MDOC_BODY == n->type)
outflags &= ~MMAN_Bk;
}
@@ -1408,8 +1396,10 @@ pre_nm(DECL_ARGS)
{
char *name;
- if (MDOC_BLOCK == n->type)
+ if (MDOC_BLOCK == n->type) {
+ outflags |= MMAN_Bk;
pre_syn(n);
+ }
if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
return(1);
name = n->child ? n->child->string : meta->name;
@@ -1432,9 +1422,18 @@ static void
post_nm(DECL_ARGS)
{
- if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
- return;
- font_pop();
+ switch (n->type) {
+ case (MDOC_BLOCK):
+ outflags &= ~MMAN_Bk;
+ break;
+ case (MDOC_HEAD):
+ /* FALLTHROUGH */
+ case (MDOC_ELEM):
+ font_pop();
+ break;
+ default:
+ break;
+ }
}
static int
diff --git a/mdoc_term.c b/mdoc_term.c
index 1eaa47db..e2adafd2 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -307,12 +307,9 @@ print_mdoc_node(DECL_ARGS)
/*
* Keeps only work until the end of a line. If a keep was
* invoked in a prior line, revert it to PREKEEP.
- *
- * Also let SYNPRETTY sections behave as if they were wrapped
- * in a `Bk' block.
*/
- if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) {
+ if (TERMP_KEEP & p->flags) {
if (n->prev ? (n->prev->lastline != n->line) :
(n->parent && n->parent->line != n->line)) {
p->flags &= ~TERMP_KEEP;
@@ -321,16 +318,6 @@ print_mdoc_node(DECL_ARGS)
}
/*
- * Since SYNPRETTY sections aren't "turned off" with `Ek',
- * we have to intuit whether we should disable formatting.
- */
-
- if ( ! (MDOC_SYNPRETTY & n->flags) &&
- ((n->prev && MDOC_SYNPRETTY & n->prev->flags) ||
- (n->parent && MDOC_SYNPRETTY & n->parent->flags)))
- p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
-
- /*
* After the keep flags have been set up, we may now
* produce output. Note that some pre-handlers do so.
*/
@@ -1010,8 +997,10 @@ static int
termp_nm_pre(DECL_ARGS)
{
- if (MDOC_BLOCK == n->type)
+ if (MDOC_BLOCK == n->type) {
+ p->flags |= TERMP_PREKEEP;
return(1);
+ }
if (MDOC_BODY == n->type) {
if (NULL == n->child)
@@ -1060,7 +1049,9 @@ static void
termp_nm_post(DECL_ARGS)
{
- if (MDOC_HEAD == n->type && n->next->child) {
+ if (MDOC_BLOCK == n->type) {
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+ } else if (MDOC_HEAD == n->type && n->next->child) {
term_flushln(p);
p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
p->trailspace = 0;
@@ -2240,7 +2231,7 @@ static void
termp_bk_post(DECL_ARGS)
{
- if (MDOC_BODY == n->type && ! (MDOC_SYNPRETTY & n->flags))
+ if (MDOC_BODY == n->type)
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
}