summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-11-29 01:44:42 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-11-29 01:44:42 +0000
commite2523f4d7af46ff5de12f85ef537b275cbfb7f88 (patch)
treec959e5c91ade7647e62408ebd630694170d1411a /usr.bin/mandoc/man.c
parent02878e6742aa9d7d2bc5f7b505bb066cdf405f44 (diff)
Downgrade the easier of the two cases of MANDOCERR_SYNTLINESCOPE
to MANDOCERR_LINESCOPE, i.e. from FATAL to ERROR. That is, when an element next line scope is empty except for one or more NSCOPED macros (like in .B .br .br .B), throw away the empty element including its NSCOPED children such that the parser can prod on. While here, improve the error message and tell the user which element has been thrown away.
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r--usr.bin/mandoc/man.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 20b5bd8266d..7702d3adbae 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.45 2010/11/29 00:12:02 schwarze Exp $ */
+/* $Id: man.c,v 1.46 2010/11/29 01:44:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -509,37 +509,22 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
goto err;
/*
- * Remove prior ELINE macro, as it's being clobbering by a new
+ * Remove prior ELINE macro, as it's being clobbered by a new
* macro. Note that NSCOPED macros do not close out ELINE
* macros---they don't print text---so we let those slip by.
*/
if ( ! (MAN_NSCOPED & man_macros[tok].flags) &&
m->flags & MAN_ELINE) {
- assert(MAN_TEXT != m->last->type);
-
- /*
- * This occurs in the following construction:
- * .B
- * .br
- * .B
- * .br
- * I hate man macros.
- * Flat-out disallow this madness.
- */
- if (MAN_NSCOPED & man_macros[m->last->tok].flags) {
- man_pmsg(m, ln, ppos, MANDOCERR_SYNTLINESCOPE);
- return(0);
- }
-
n = m->last;
+ assert(MAN_TEXT != n->type);
- assert(n);
- assert(NULL == n->child);
- assert(0 == n->nchild);
+ /* .B .br .br .B: remove prior including children */
+ if (MAN_NSCOPED & man_macros[n->tok].flags)
+ n = n->parent;
- if ( ! man_nmsg(m, n, MANDOCERR_LINESCOPE))
- return(0);
+ man_vmsg(m, MANDOCERR_LINESCOPE, n->line, n->pos,
+ "%s", man_macronames[n->tok]);
man_node_delete(m, n);
m->flags &= ~MAN_ELINE;