summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-04-05 14:43:10 +0000
committerschwarze <schwarze@openbsd.org>2015-04-05 14:43:10 +0000
commit0edd4a98a98d8d6c5638bf023fa5caf54390cdb4 (patch)
treec6ea9d068d288d2cfaf7baedbc0f8fb79ed06ab4
parentseems unlikely that a new release will be made available for us to import (diff)
downloadwireguard-openbsd-0edd4a98a98d8d6c5638bf023fa5caf54390cdb4.tar.xz
wireguard-openbsd-0edd4a98a98d8d6c5638bf023fa5caf54390cdb4.zip
Arguments to end macros of broken partial explicit blocks
must go inside the breaking block. For example, in .It Ic cmd Oo .Ar optional_arg Oc Ar mandatory_arg the mandatory_arg is still inside the .It block. Used for example by mutella(1).
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/Makefile10
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/tail.in21
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/tail.out_ascii14
-rw-r--r--regress/usr.bin/mandoc/mdoc/break/tail.out_lint2
-rw-r--r--usr.bin/mandoc/mdoc_macro.c18
5 files changed, 52 insertions, 13 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/break/Makefile b/regress/usr.bin/mandoc/mdoc/break/Makefile
index 1642b209fec..e91e20f80fd 100644
--- a/regress/usr.bin/mandoc/mdoc/break/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/break/Makefile
@@ -1,7 +1,11 @@
-# $OpenBSD: Makefile,v 1.2 2015/02/12 13:52:12 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2015/04/05 14:43:10 schwarze Exp $
-REGRESS_TARGETS = brokenbreaker twice two
-LINT_TARGETS = brokenbreaker twice two
+REGRESS_TARGETS = brokenbreaker twice tail two
+LINT_TARGETS = brokenbreaker twice tail two
+
+# It's hard to keep stuff together in next-line scope.
+
+SKIP_TMAN = tail
# groff-1.22.3 defect:
# - non-matching enclosure end macro prints a closing delimiter
diff --git a/regress/usr.bin/mandoc/mdoc/break/tail.in b/regress/usr.bin/mandoc/mdoc/break/tail.in
new file mode 100644
index 00000000000..97b79a21a93
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/break/tail.in
@@ -0,0 +1,21 @@
+.Dd April 5, 2015
+.Dt BREAK-TAIL 1
+.Os OpenBSD
+.Sh NAME
+.Nm break-tail
+.Nd tail arguments on broken blocks
+.Sh DESCRIPTION
+Explicitly broken:
+.Ao ao
+.Bo bo ac
+.Ac bc
+.Bc tail
+.Pp
+Implicitly broken:
+.Aq aq Bo bo eol
+.Bc tail
+.Bl -tag -width Ds -offset indent
+.It it Ao ao ac
+.Ac 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
new file mode 100644
index 00000000000..d50c4a11238
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/break/tail.out_ascii
@@ -0,0 +1,14 @@
+BREAK-TAIL(1) General Commands Manual BREAK-TAIL(1)
+
+NNAAMMEE
+ bbrreeaakk--ttaaiill - tail arguments on broken blocks
+
+DDEESSCCRRIIPPTTIIOONN
+ Explicitly broken: <ao [bo ac> bc] tail
+
+ Implicitly broken: <aq [bo eol>] tail
+
+ it <ao ac> 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
new file mode 100644
index 00000000000..515d2728366
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/break/tail.out_lint
@@ -0,0 +1,2 @@
+mandoc: tail.in:11:2: WARNING: blocks badly nested: Ao breaks Bo
+mandoc: tail.in:15: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 81cea4bedc6..b53950878d0 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.141 2015/04/02 22:06:17 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.142 2015/04/05 14:43:10 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -254,7 +254,9 @@ rew_last(struct mdoc *mdoc, const struct roff_node *to)
{
struct roff_node *n, *np;
- assert(to);
+ if (to->flags & MDOC_VALID)
+ return;
+
mdoc->next = MDOC_NEXT_SIBLING;
while (mdoc->last != to) {
/*
@@ -623,10 +625,8 @@ blk_exp_close(MACRO_PROT_ARGS)
for (j = 0; ; j++) {
lastarg = *pos;
- if (j == maxargs && n != NULL) {
- rew_pending(mdoc, n);
- n = NULL;
- }
+ if (j == maxargs && n != NULL)
+ rew_last(mdoc, n);
ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
if (ac == ARGS_PUNCT || ac == ARGS_EOLN)
@@ -641,10 +641,8 @@ blk_exp_close(MACRO_PROT_ARGS)
continue;
}
- if (n != NULL) {
- rew_pending(mdoc, n);
- n = NULL;
- }
+ if (n != NULL)
+ rew_last(mdoc, n);
mdoc->flags &= ~MDOC_NEWLINE;
mdoc_macro(mdoc, ntok, line, lastarg, pos, buf);
break;