aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-12-06 13:49:02 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-12-06 13:49:02 +0000
commita6ed0b54354d334972a41e2e39ad37127a52de2d (patch)
tree65de92301bd25ce0bd0ca8e2e711e31f2e6b02f4 /man.c
parentf6c44d31238af86efa12150be15d92373bfbac59 (diff)
downloadmandoc-a6ed0b54354d334972a41e2e39ad37127a52de2d.tar.gz
mandoc-a6ed0b54354d334972a41e2e39ad37127a52de2d.tar.zst
mandoc-a6ed0b54354d334972a41e2e39ad37127a52de2d.zip
Allow multiple ELINE macros without raising a fatal error. From a field-
tested patch by schwarze@.
Diffstat (limited to 'man.c')
-rw-r--r--man.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/man.c b/man.c
index 589b0633..293ab6fe 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.89 2010/12/05 16:14:16 kristaps Exp $ */
+/* $Id: man.c,v 1.90 2010/12/06 13:49:02 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -473,9 +473,7 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX;
if (MAN_MAX == tok) {
- man_vmsg(m, MANDOCERR_MACRO, ln, ppos,
- "unknown macro: %s%s",
- buf, strlen(buf) > 3 ? "..." : "");
+ man_vmsg(m, MANDOCERR_MACRO, ln, ppos, "%s", buf + ppos - 1);
return(1);
}
@@ -494,37 +492,23 @@ 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);
+ /* Remove repeated NSCOPED macros causing ELINE. */
- if ( ! man_nmsg(m, n, MANDOCERR_LINESCOPE))
- return(0);
+ if (MAN_NSCOPED & man_macros[n->tok].flags)
+ n = n->parent;
+
+ man_vmsg(m, MANDOCERR_LINESCOPE, n->line, n->pos,
+ "%s", man_macronames[n->tok]);
man_node_delete(m, n);
m->flags &= ~MAN_ELINE;