summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-11-05 16:02:19 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-11-05 16:02:19 +0000
commit1510037a570f6f9f36441934ce9ed183ae1d9e7f (patch)
tree89d8fcd9545d9098bce89490a7486488d2ff5d60
parent5633fe7bead0008d9d2e696526ab301c70f20ca0 (diff)
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.
-rw-r--r--usr.bin/mandoc/libman.h3
-rw-r--r--usr.bin/mandoc/man.c31
-rw-r--r--usr.bin/mandoc/man_macro.c24
-rw-r--r--usr.bin/mandoc/man_validate.c37
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/read.c3
6 files changed, 56 insertions, 45 deletions
diff --git a/usr.bin/mandoc/libman.h b/usr.bin/mandoc/libman.h
index e9ecec7da65..d62540b4edc 100644
--- a/usr.bin/mandoc/libman.h
+++ b/usr.bin/mandoc/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.30 2011/09/18 10:25:28 schwarze Exp $ */
+/* $Id: libman.h,v 1.31 2011/11/05 16:02:18 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -54,6 +54,7 @@ struct man_macro {
#define MAN_FSCOPED (1 << 2) /* See blk_imp(). */
#define MAN_NSCOPED (1 << 3) /* See in_line_eoln(). */
#define MAN_NOCLOSE (1 << 4) /* See blk_exp(). */
+#define MAN_BSCOPE (1 << 5) /* Break BLINE scope. */
};
extern const struct man_macro *const man_macros;
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.
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c
index 58ea930a6dc..05c59a90a1b 100644
--- a/usr.bin/mandoc/man_macro.c
+++ b/usr.bin/mandoc/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.31 2011/07/07 04:08:01 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.32 2011/11/05 16:02:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -48,15 +48,15 @@ static void rew_warn(struct man *,
const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, MAN_NSCOPED }, /* br */
- { in_line_eoln, 0 }, /* TH */
- { blk_imp, MAN_SCOPED }, /* SH */
- { blk_imp, MAN_SCOPED }, /* SS */
- { blk_imp, MAN_SCOPED | MAN_FSCOPED }, /* TP */
- { blk_imp, 0 }, /* LP */
- { blk_imp, 0 }, /* PP */
- { blk_imp, 0 }, /* P */
- { blk_imp, 0 }, /* IP */
- { blk_imp, 0 }, /* HP */
+ { in_line_eoln, MAN_BSCOPE }, /* TH */
+ { blk_imp, MAN_BSCOPE | MAN_SCOPED }, /* SH */
+ { blk_imp, MAN_BSCOPE | MAN_SCOPED }, /* SS */
+ { blk_imp, MAN_BSCOPE | MAN_SCOPED | MAN_FSCOPED }, /* TP */
+ { blk_imp, MAN_BSCOPE }, /* LP */
+ { blk_imp, MAN_BSCOPE }, /* PP */
+ { blk_imp, MAN_BSCOPE }, /* P */
+ { blk_imp, MAN_BSCOPE }, /* IP */
+ { blk_imp, MAN_BSCOPE }, /* HP */
{ in_line_eoln, MAN_SCOPED }, /* SM */
{ in_line_eoln, MAN_SCOPED }, /* SB */
{ in_line_eoln, 0 }, /* BI */
@@ -70,8 +70,8 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* RI */
{ in_line_eoln, MAN_NSCOPED }, /* na */
{ in_line_eoln, MAN_NSCOPED }, /* sp */
- { in_line_eoln, 0 }, /* nf */
- { in_line_eoln, 0 }, /* fi */
+ { in_line_eoln, MAN_BSCOPE }, /* nf */
+ { in_line_eoln, MAN_BSCOPE }, /* fi */
{ blk_close, 0 }, /* RE */
{ blk_exp, MAN_EXPLICIT }, /* RS */
{ in_line_eoln, 0 }, /* DT */
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index 19ce4aa6784..dcdb5e8cc8a 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.49 2011/11/03 20:46:40 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.50 2011/11/05 16:02:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -40,7 +40,6 @@ struct man_valid {
v_check *posts;
};
-static int check_bline(CHKARGS);
static int check_eq0(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
@@ -72,20 +71,19 @@ static v_check posts_sec[] = { post_sec, NULL };
static v_check posts_sp[] = { post_vs, check_le1, NULL };
static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL };
static v_check posts_uc[] = { post_UC, NULL };
-static v_check pres_bline[] = { check_bline, NULL };
-static v_check pres_sec[] = { check_bline, pre_sec, NULL};
+static v_check pres_sec[] = { pre_sec, NULL };
static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_br }, /* br */
- { pres_bline, posts_th }, /* TH */
+ { NULL, posts_th }, /* TH */
{ pres_sec, posts_sec }, /* SH */
{ pres_sec, posts_sec }, /* SS */
- { pres_bline, NULL }, /* TP */
- { pres_bline, posts_par }, /* LP */
- { pres_bline, posts_par }, /* PP */
- { pres_bline, posts_par }, /* P */
- { pres_bline, NULL }, /* IP */
- { pres_bline, NULL }, /* HP */
+ { NULL, NULL }, /* TP */
+ { NULL, posts_par }, /* LP */
+ { NULL, posts_par }, /* PP */
+ { NULL, posts_par }, /* P */
+ { NULL, NULL }, /* IP */
+ { NULL, NULL }, /* HP */
{ NULL, NULL }, /* SM */
{ NULL, NULL }, /* SB */
{ NULL, NULL }, /* BI */
@@ -99,8 +97,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* RI */
{ NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
{ NULL, posts_sp }, /* sp */ /* FIXME: should warn only. */
- { pres_bline, posts_nf }, /* nf */
- { pres_bline, posts_fi }, /* fi */
+ { NULL, posts_nf }, /* nf */
+ { NULL, posts_fi }, /* fi */
{ NULL, NULL }, /* RE */
{ NULL, posts_part }, /* RS */
{ NULL, NULL }, /* DT */
@@ -348,19 +346,6 @@ check_par(CHKARGS)
static int
-check_bline(CHKARGS)
-{
-
- assert( ! (MAN_ELINE & m->flags));
- if (MAN_BLINE & m->flags) {
- man_nmsg(m, n, MANDOCERR_SYNTLINESCOPE);
- return(0);
- }
-
- return(1);
-}
-
-static int
post_TH(CHKARGS)
{
const char *p;
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index cef90417ad9..f0f6fd10cb3 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.41 2011/10/09 17:59:56 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.42 2011/11/05 16:02:18 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -150,7 +150,6 @@ enum mandocerr {
MANDOCERR_NOTMANUAL, /* manual isn't really a manual */
MANDOCERR_COLUMNS, /* column syntax is inconsistent */
MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */
- MANDOCERR_SYNTLINESCOPE, /* line scope broken, syntax violated */
MANDOCERR_SYNTARGVCOUNT, /* argument count wrong, violates syntax */
MANDOCERR_SYNTCHILD, /* child violates parent syntax */
MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index aa31338153d..11862ac6120 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.4 2011/10/09 17:59:56 schwarze Exp $ */
+/* $Id: read.c,v 1.5 2011/11/05 16:02:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -182,7 +182,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"not a manual",
"column syntax is inconsistent",
"NOT IMPLEMENTED: .Bd -file",
- "line scope broken, syntax violated",
"argument count wrong, violates syntax",
"child violates parent syntax",
"argument count wrong, violates syntax",