summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/mdoc/Eo/Makefile7
-rw-r--r--regress/usr.bin/mandoc/mdoc/Eo/break.in17
-rw-r--r--regress/usr.bin/mandoc/mdoc/Eo/break.out_ascii9
-rw-r--r--regress/usr.bin/mandoc/mdoc/Eo/break.out_lint1
-rw-r--r--regress/usr.bin/mandoc/mdoc/Eo/empty.in3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Eo/empty.out_ascii3
-rw-r--r--usr.bin/mandoc/mdoc_html.c23
-rw-r--r--usr.bin/mandoc/mdoc_macro.c36
-rw-r--r--usr.bin/mandoc/mdoc_man.c19
-rw-r--r--usr.bin/mandoc/mdoc_term.c10
10 files changed, 97 insertions, 31 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Eo/Makefile b/regress/usr.bin/mandoc/mdoc/Eo/Makefile
index caa50a0c9e1..73a8f5f41ba 100644
--- a/regress/usr.bin/mandoc/mdoc/Eo/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Eo/Makefile
@@ -1,7 +1,6 @@
-# $OpenBSD: Makefile,v 1.2 2014/07/02 03:47:07 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2014/11/27 22:27:40 schwarze Exp $
-REGRESS_TARGETS = empty obsolete
-
-LINT_TARGETS = obsolete
+REGRESS_TARGETS = break empty obsolete
+LINT_TARGETS = break obsolete
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/Eo/break.in b/regress/usr.bin/mandoc/mdoc/Eo/break.in
new file mode 100644
index 00000000000..6dd3ee3da7a
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Eo/break.in
@@ -0,0 +1,17 @@
+.Dd November 27, 2014
+.Dt EO-BREAK 1
+.Os OpenBSD
+.Sh NAME
+.Nm Eo-break
+.Nd breaking a custom enclosure block
+.Sh DESCRIPTION
+initial text
+.Eo <<
+eo
+.Bo
+bo
+ec
+.Ec >>
+bc
+.Bc
+final text
diff --git a/regress/usr.bin/mandoc/mdoc/Eo/break.out_ascii b/regress/usr.bin/mandoc/mdoc/Eo/break.out_ascii
new file mode 100644
index 00000000000..1088828fa33
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Eo/break.out_ascii
@@ -0,0 +1,9 @@
+EO-BREAK(1) General Commands Manual EO-BREAK(1)
+
+NNAAMMEE
+ EEoo--bbrreeaakk - breaking a custom enclosure block
+
+DDEESSCCRRIIPPTTIIOONN
+ initial text <<eo [bo ec>> bc] final text
+
+OpenBSD November 27, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Eo/break.out_lint b/regress/usr.bin/mandoc/mdoc/Eo/break.out_lint
new file mode 100644
index 00000000000..11dc16308bc
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Eo/break.out_lint
@@ -0,0 +1 @@
+mandoc: break.in:14:2: WARNING: blocks badly nested: Ec breaks Bo
diff --git a/regress/usr.bin/mandoc/mdoc/Eo/empty.in b/regress/usr.bin/mandoc/mdoc/Eo/empty.in
index 76a3ed03809..c4b65c0aaa9 100644
--- a/regress/usr.bin/mandoc/mdoc/Eo/empty.in
+++ b/regress/usr.bin/mandoc/mdoc/Eo/empty.in
@@ -13,3 +13,6 @@ and a full
user@host
.Ec >>
quotation.
+And a stray
+.Ec ignore this
+end macro.
diff --git a/regress/usr.bin/mandoc/mdoc/Eo/empty.out_ascii b/regress/usr.bin/mandoc/mdoc/Eo/empty.out_ascii
index 090ac390def..a8e9376a82a 100644
--- a/regress/usr.bin/mandoc/mdoc/Eo/empty.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Eo/empty.out_ascii
@@ -4,6 +4,7 @@ NNAAMMEE
EEoo--eemmppttyy - empty implicit enclosure macros
DDEESSCCRRIIPPTTIIOONN
- An empty <<>> and a full <<user@host>> quotation.
+ An empty <<>> and a full <<user@host>> quotation. And a stray
+ ignore this end macro.
OpenBSD October 21, 2010 OpenBSD
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index c0f6e29c53a..e4b9389d29a 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.87 2014/11/27 16:20:27 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.88 2014/11/27 22:27:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -421,13 +421,12 @@ print_mdoc_node(MDOC_ARGS)
* the "meta" table state. This will be reopened on the
* next table element.
*/
- if (h->tblt) {
+ if (h->tblt != NULL) {
print_tblclose(h);
t = h->tags.head;
}
-
- assert(NULL == h->tblt);
- if (mdocs[n->tok].pre && ENDBODY_NOT == n->end)
+ assert(h->tblt == NULL);
+ if (mdocs[n->tok].pre && (n->end == ENDBODY_NOT || n->child))
child = (*mdocs[n->tok].pre)(meta, n, h);
break;
}
@@ -452,8 +451,13 @@ print_mdoc_node(MDOC_ARGS)
case MDOC_EQN:
break;
default:
- if (mdocs[n->tok].post && ENDBODY_NOT == n->end)
- (*mdocs[n->tok].post)(meta, n, h);
+ if ( ! mdocs[n->tok].post || n->flags & MDOC_ENDED)
+ break;
+ (*mdocs[n->tok].post)(meta, n, h);
+ if (n->end != ENDBODY_NOT)
+ n->pending->flags |= MDOC_ENDED;
+ if (n->end == ENDBODY_NOSPACE)
+ h->flags |= HTML_NOSPACE;
break;
}
}
@@ -2140,10 +2144,11 @@ static void
mdoc_quote_post(MDOC_ARGS)
{
- if (MDOC_BODY != n->type)
+ if (n->type != MDOC_BODY && n->type != MDOC_ELEM)
return;
- if (MDOC_En != n->tok)
+ if ( ! (n->tok == MDOC_En ||
+ (n->tok == MDOC_Eo && n->end == ENDBODY_SPACE)))
h->flags |= HTML_NOSPACE;
switch (n->tok) {
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 8c3523febce..fd758782a98 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_macro.c,v 1.103 2014/11/26 19:22:44 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.104 2014/11/27 22:27:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -691,6 +691,7 @@ static int
blk_exp_close(MACRO_PROT_ARGS)
{
struct mdoc_node *body; /* Our own body. */
+ struct mdoc_node *endbody; /* Our own end marker. */
struct mdoc_node *later; /* A sub-block starting later. */
struct mdoc_node *n; /* For searching backwards. */
@@ -717,7 +718,7 @@ blk_exp_close(MACRO_PROT_ARGS)
* both of our own and of pending sub-blocks.
*/
atok = rew_alt(tok);
- body = later = NULL;
+ body = endbody = later = NULL;
for (n = mdoc->last; n; n = n->parent) {
if (MDOC_VALID & n->flags)
continue;
@@ -756,6 +757,10 @@ blk_exp_close(MACRO_PROT_ARGS)
if ( ! mdoc_endbody_alloc(mdoc, line, ppos,
atok, body, ENDBODY_SPACE))
return(0);
+ if (maxargs) {
+ endbody = mdoc->last;
+ mdoc->next = MDOC_NEXT_CHILD;
+ }
break;
}
@@ -785,15 +790,28 @@ blk_exp_close(MACRO_PROT_ARGS)
if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos))
return(0);
- if (NULL == later && maxargs > 0)
- if ( ! mdoc_tail_alloc(mdoc, line, ppos, rew_alt(tok)))
+ if (maxargs && endbody == NULL) {
+ if (n == NULL) {
+ /*
+ * Stray .Ec without previous .Eo:
+ * Break the output line, ignore any arguments.
+ */
+ if ( ! mdoc_elem_alloc(mdoc, line, ppos,
+ MDOC_br, NULL))
+ return(0);
+ if ( ! rew_elem(mdoc, MDOC_br))
+ return(0);
+ } else if ( ! mdoc_tail_alloc(mdoc, line, ppos, atok))
return(0);
+ }
- for (flushed = j = 0; ; j++) {
+ flushed = n == NULL;
+ for (j = 0; ; j++) {
lastarg = *pos;
if (j == maxargs && ! flushed) {
- if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))
+ if ( ! (endbody != NULL ? rew_last(mdoc, endbody) :
+ rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)))
return(0);
flushed = 1;
}
@@ -817,7 +835,8 @@ blk_exp_close(MACRO_PROT_ARGS)
}
if ( ! flushed) {
- if ( ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))
+ if ( ! (endbody != NULL ? rew_last(mdoc, endbody) :
+ rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)))
return(0);
flushed = 1;
}
@@ -829,7 +848,8 @@ blk_exp_close(MACRO_PROT_ARGS)
break;
}
- if ( ! flushed && ! rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos))
+ if ( ! flushed && ! (endbody != NULL ? rew_last(mdoc, endbody) :
+ rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)))
return(0);
if ( ! nl)
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 84acd1e461e..256ea37f390 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.73 2014/11/27 16:20:27 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.74 2014/11/27 22:27:40 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -83,6 +83,7 @@ static int pre_en(DECL_ARGS);
static int pre_enc(DECL_ARGS);
static int pre_em(DECL_ARGS);
static int pre_skip(DECL_ARGS);
+static int pre_eo(DECL_ARGS);
static int pre_ex(DECL_ARGS);
static int pre_fa(DECL_ARGS);
static int pre_fd(DECL_ARGS);
@@ -188,7 +189,7 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ NULL, NULL, NULL, NULL, NULL }, /* Ec */
{ NULL, NULL, NULL, NULL, NULL }, /* Ef */
{ NULL, pre_em, post_font, NULL, NULL }, /* Em */
- { NULL, NULL, post_eo, NULL, NULL }, /* Eo */
+ { cond_body, pre_eo, post_eo, NULL, NULL }, /* Eo */
{ NULL, pre_ux, NULL, "FreeBSD", NULL }, /* Fx */
{ NULL, pre_sy, post_font, NULL, NULL }, /* Ms */
{ NULL, pre_no, NULL, NULL, NULL }, /* No */
@@ -605,8 +606,8 @@ print_node(DECL_ARGS)
* node.
*/
act = manacts + n->tok;
- cond = NULL == act->cond || (*act->cond)(meta, n);
- if (cond && act->pre && ENDBODY_NOT == n->end)
+ cond = act->cond == NULL || (*act->cond)(meta, n);
+ if (cond && act->pre && (n->end == ENDBODY_NOT || n->nchild))
do_sub = (*act->pre)(meta, n);
}
@@ -1121,11 +1122,19 @@ post_en(DECL_ARGS)
return;
}
+static int
+pre_eo(DECL_ARGS)
+{
+
+ outflags &= ~(MMAN_spc | MMAN_nl);
+ return(1);
+}
+
static void
post_eo(DECL_ARGS)
{
- if (MDOC_HEAD == n->type || MDOC_BODY == n->type)
+ if (n->end != ENDBODY_SPACE)
outflags &= ~MMAN_spc;
}
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 7ced72e6741..0ad712c8637 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.193 2014/11/27 16:20:27 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.194 2014/11/27 22:27:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -348,7 +348,8 @@ print_mdoc_node(DECL_ARGS)
term_tbl(p, n->span);
break;
default:
- if (termacts[n->tok].pre && ENDBODY_NOT == n->end)
+ if (termacts[n->tok].pre &&
+ (n->end == ENDBODY_NOT || n->nchild))
chld = (*termacts[n->tok].pre)
(p, &npair, meta, n);
break;
@@ -1915,10 +1916,11 @@ static void
termp_quote_post(DECL_ARGS)
{
- if (MDOC_BODY != n->type && MDOC_ELEM != n->type)
+ if (n->type != MDOC_BODY && n->type != MDOC_ELEM)
return;
- if (MDOC_En != n->tok)
+ if ( ! (n->tok == MDOC_En ||
+ (n->tok == MDOC_Eo && n->end == ENDBODY_SPACE)))
p->flags |= TERMP_NOSPACE;
switch (n->tok) {