summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-11-05 16:02:18 +0000
committerschwarze <schwarze@openbsd.org>2011-11-05 16:02:18 +0000
commit055116b585f363b61767b3a773f7157a4348c4c3 (patch)
tree9dd61832ac39ec8008681730c8fab480b81bbfa1 /usr.bin/mandoc/man.c
parentttys can't seek, so make pread/pwrite/preadv/pwritev fail with ESPIPE (diff)
downloadwireguard-openbsd-055116b585f363b61767b3a773f7157a4348c4c3.tar.xz
wireguard-openbsd-055116b585f363b61767b3a773f7157a4348c4c3.zip
When the HEAD scope of .TP is broken by another block macro,
do not abort with a FATAL error, but report a regular ERROR, remove the broken .TP from the syntax tree, and prod on. Reported repeatedly by ports people, at least by brad@ and jeremy@. Also fixes rendition(4) in Xenocara.
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r--usr.bin/mandoc/man.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 3ce1b5d0b79..01f233add1d 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.62 2011/10/09 17:59:56 schwarze Exp $ */
+/* $Id: man.c,v 1.63 2011/11/05 16:02:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -539,13 +539,40 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
n = n->parent;
mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line,
- n->pos, "%s", man_macronames[n->tok]);
+ n->pos, "%s breaks %s", man_macronames[tok],
+ man_macronames[n->tok]);
man_node_delete(m, n);
m->flags &= ~MAN_ELINE;
}
/*
+ * Remove prior BLINE macro that is being clobbered.
+ */
+ if ((m->flags & MAN_BLINE) &&
+ (MAN_BSCOPE & man_macros[tok].flags)) {
+ n = m->last;
+ assert(MAN_TEXT != n->type);
+
+ /* Remove element that didn't end BLINE, if any. */
+
+ if ( ! (MAN_BSCOPE & man_macros[n->tok].flags))
+ n = n->parent;
+
+ assert(MAN_HEAD == n->type);
+ n = n->parent;
+ assert(MAN_BLOCK == n->type);
+ assert(MAN_SCOPED & man_macros[n->tok].flags);
+
+ mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line,
+ n->pos, "%s breaks %s", man_macronames[tok],
+ man_macronames[n->tok]);
+
+ man_node_delete(m, n);
+ m->flags &= ~MAN_BLINE;
+ }
+
+ /*
* Save the fact that we're in the next-line for a block. In
* this way, embedded roff instructions can "remember" state
* when they exit.