Similarly, avoid having the same block break two other blocks.
In some situations, this could lead to an endless loop in rew_sub()
found by jsg@ with afl.
Minimal example: .Po Ao Pc Bo Pc Ac Bc
-# $OpenBSD: Makefile,v 1.30 2014/11/27 16:20:27 schwarze Exp $
+# $OpenBSD: Makefile,v 1.31 2014/12/22 23:26:20 schwarze Exp $
SUBDIR = Ad An Ap Aq Ar At Bd Bf Bk Bl Brq Bx Cd Cm
SUBDIR += D1 Db Dd Dl Dq Dt Dv Em Eo Er Ev Ex Fd Fl Fo Ft Ic In Lb Li Lk
SUBDIR += Ms Mt Nd Nm No Ns Oo Op Os Ox Pa Pf Pp Qq Rs Rv
-SUBDIR += Sh Sm Sq St Sx Sy Tn Ux Va Vt Xr blank
+SUBDIR += Sh Sm Sq St Sx Sy Tn Ux Va Vt Xr blank break
.include "../Makefile.sub"
.include <bsd.subdir.mk>
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2014/12/22 23:26:20 schwarze Exp $
+
+REGRESS_TARGETS = twice
+LINT_TARGETS = twice
+
+# groff-1.22.3 defect:
+# - non-matching enclosure end macro prints a closing delimiter
+
+SKIP_GROFF = twice
+
+.include <bsd.regress.mk>
--- /dev/null
+.Dd December 23, 2014
+.Dt BREAK-TWICE 1
+.Os OpenBSD
+.Sh NAME
+.Nm break-twice
+.Nd the same block breaking two other blocks
+.Sh DESCRIPTION
+.Po po
+.Ao ao pc
+.Pc
+.Bo bo pc
+.Pc ac
+.Ac bc
+.Bc
--- /dev/null
+BREAK-TWICE(1) General Commands Manual BREAK-TWICE(1)
+
+N\bNA\bAM\bME\bE
+ b\bbr\bre\bea\bak\bk-\b-t\btw\bwi\bic\bce\be - the same block breaking two other blocks
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ (po <ao pc) [bo pc ac> bc]
+
+OpenBSD December 23, 2014 OpenBSD
--- /dev/null
+mandoc: twice.in:10:2: WARNING: blocks badly nested: Pc breaks Ao
+mandoc: twice.in:13:2: WARNING: blocks badly nested: Ac breaks Bo
-/* $OpenBSD: mdoc_macro.c,v 1.116 2014/12/20 02:26:42 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.117 2014/12/22 23:26:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
* When starting to rewind, skip plain text
* and nodes that have already been rewound.
*/
- if (MDOC_TEXT == p->type || MDOC_VALID & p->flags)
+ if (p->type == MDOC_TEXT || p->flags & (MDOC_VALID | MDOC_BREAK))
return(REWIND_MORE);
/*
atok = rew_alt(tok);
body = endbody = later = NULL;
for (n = mdoc->last; n; n = n->parent) {
- if (n->flags & MDOC_VALID)
+ if (n->flags & (MDOC_VALID | MDOC_BREAK))
continue;
/* Remember the start of our own body. */