summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2019-12-26 19:51:48 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2019-12-26 19:51:48 +0000
commite03efbaa3d86b2a662fc728caae44db2903537ed (patch)
tree6d25ea9a631756286c6a4cb63484a18b060941c3 /usr.bin/mandoc
parentd3762c937259a95e7e00d1c9c7aaee5b1e976afe (diff)
Do not fail an assertion when a high level macro occurs in the body
of a conditional inside a .ce request block. Instead, abort the .ce block just like when there is no conditional in between. Bug found by espie@ working on the textproc/fstrcmp port.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/roff.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index a4fe4f06df2..625d155fbce 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.239 2019/11/09 14:39:42 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.240 2019/12/26 19:51:47 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -2292,12 +2292,24 @@ roff_cond_sub(ROFF_ARGS)
}
}
+ t = roff_parse(r, buf->buf, &pos, ln, ppos);
+
+ /* For now, let high level macros abort .ce mode. */
+
+ if (roffce_node != NULL &&
+ (t == TOKEN_NONE || t == ROFF_Dd || t == ROFF_EQ ||
+ t == ROFF_TH || t == ROFF_TS)) {
+ r->man->last = roffce_node;
+ r->man->next = ROFF_NEXT_SIBLING;
+ roffce_lines = 0;
+ roffce_node = NULL;
+ }
+
/*
* Fully handle known macros when they are structurally
* required or when the conditional evaluated to true.
*/
- t = roff_parse(r, buf->buf, &pos, ln, ppos);
if (t == ROFF_break) {
if (irc & ROFF_LOOPMASK)
irc = ROFF_IGN | ROFF_LOOPEXIT;