summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-04-05 23:04:22 +0000
committerschwarze <schwarze@openbsd.org>2015-04-05 23:04:22 +0000
commit417e9c8319621cf71d0b2593f4eb74b04fb86939 (patch)
treebab4c55e59e02bbbd190ccfaaa6a2d7c628fe951
parentReduce code duplication, no functional change: (diff)
downloadwireguard-openbsd-417e9c8319621cf71d0b2593f4eb74b04fb86939.tar.xz
wireguard-openbsd-417e9c8319621cf71d0b2593f4eb74b04fb86939.zip
If a partial explicit block extending to the next input line follows
the end macro of a broken block, put all of it into the breaking block. Needed for example by mutella(1).
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/tail.in20
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/tail.out_ascii11
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/tail.out_lint4
-rw-r--r--usr.bin/mandoc/mdoc_macro.c20
4 files changed, 46 insertions, 9 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/break/tail.in b/regress/usr.bin/mandoc/mdoc/break/tail.in
index 97b79a21a93..ff250591ccd 100644
--- a/regress/usr.bin/mandoc/mdoc/break/tail.in
+++ b/regress/usr.bin/mandoc/mdoc/break/tail.in
@@ -5,17 +5,33 @@
.Nm break-tail
.Nd tail arguments on broken blocks
.Sh DESCRIPTION
-Explicitly broken:
+Broken by a partial explicit block:
.Ao ao
.Bo bo ac
.Ac bc
.Bc tail
+.Ao ao
+.Bo bo ac
+.Ac bc
+.Bc Po po pc
+.Pc tail
.Pp
-Implicitly broken:
+Broken by a partial implicit block:
.Aq aq Bo bo eol
.Bc tail
+.Aq aq Bo bo eol
+.Bc Po po pc
+.Pc tail
+.Pp
+Broken by a full implicit block:
.Bl -tag -width Ds -offset indent
.It it Ao ao ac
.Ac tail
list body
.El
+.Bl -tag -width Ds -offset indent
+.It it Ao ao ac
+.Ac Po po pc
+.Pc tail
+list body
+.El
diff --git a/regress/usr.bin/mandoc/mdoc/break/tail.out_ascii b/regress/usr.bin/mandoc/mdoc/break/tail.out_ascii
index d50c4a11238..62675d29d84 100644
--- a/regress/usr.bin/mandoc/mdoc/break/tail.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/break/tail.out_ascii
@@ -4,11 +4,18 @@ NNAAMMEE
bbrreeaakk--ttaaiill - tail arguments on broken blocks
DDEESSCCRRIIPPTTIIOONN
- Explicitly broken: <ao [bo ac> bc] tail
+ Broken by a partial explicit block: <ao [bo ac> bc] tail <ao [bo ac> bc]
+ (po pc) tail
- Implicitly broken: <aq [bo eol>] tail
+ Broken by a partial implicit block: <aq [bo eol>] tail <aq [bo eol>] (po
+ pc) tail
+
+ Broken by a full implicit block:
it <ao ac> tail
list body
+ it <ao ac> (po pc) tail
+ list body
+
OpenBSD April 5, 2015 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/break/tail.out_lint b/regress/usr.bin/mandoc/mdoc/break/tail.out_lint
index 515d2728366..d6f1b900f4f 100644
--- a/regress/usr.bin/mandoc/mdoc/break/tail.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/break/tail.out_lint
@@ -1,2 +1,4 @@
mandoc: tail.in:11:2: WARNING: blocks badly nested: Ao breaks Bo
-mandoc: tail.in:15:2: WARNING: blocks badly nested: Aq breaks Bo
+mandoc: tail.in:15:2: WARNING: blocks badly nested: Ao breaks Bo
+mandoc: tail.in:20:2: WARNING: blocks badly nested: Aq breaks Bo
+mandoc: tail.in:22:2: WARNING: blocks badly nested: Aq breaks Bo
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 92a99a6de81..da67f34be1d 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.143 2015/04/05 22:43:40 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.144 2015/04/05 23:04:22 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -525,8 +525,9 @@ blk_exp_close(MACRO_PROT_ARGS)
struct roff_node *itblk; /* An It block starting later. */
struct roff_node *later; /* A sub-block starting later. */
struct roff_node *n; /* Search back to our block. */
+ struct roff_node *target; /* For find_pending(). */
- int j, lastarg, maxargs, nl;
+ int j, lastarg, maxargs, nl, pending;
enum margserr ac;
int atok, ntok;
char *p;
@@ -688,8 +689,19 @@ blk_exp_close(MACRO_PROT_ARGS)
break;
}
- if (n != NULL)
- rew_pending(mdoc, n);
+ if (n != NULL) {
+ if (n != mdoc->last && n->flags & MDOC_BROKEN) {
+ target = n;
+ do
+ target = target->parent;
+ while ( ! (target->flags & MDOC_ENDED));
+ pending = find_pending(mdoc, ntok, line, ppos,
+ target);
+ } else
+ pending = 0;
+ if ( ! pending)
+ rew_pending(mdoc, n);
+ }
if (nl)
append_delims(mdoc, line, pos, buf);
}