diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-02-10 15:44:32 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-02-10 15:44:32 +0000 |
commit | 7f969bf19ad8ff56e129dbd4b3e03d227c24a547 (patch) | |
tree | 6e9abbbb11714dbdf3f43cb085b38bd1806f64e2 /usr.bin | |
parent | 37cfc122d8f82dee764b443a9f148b88077efa80 (diff) |
In -Ttree output mode, show the BROKEN node flag and
provide a -Onoval output option to show the unvalidated tree.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/main.c | 8 | ||||
-rw-r--r-- | usr.bin/mandoc/manconf.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.1 | 17 | ||||
-rw-r--r-- | usr.bin/mandoc/manpath.c | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 22 | ||||
-rw-r--r-- | usr.bin/mandoc/tree.c | 4 |
6 files changed, 45 insertions, 16 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index caa4b2d26f1..d46edf42a0c 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.184 2017/02/09 17:19:07 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.185 2017/02/10 15:44:31 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -712,7 +712,8 @@ parse(struct curparse *curp, int fd, const char *file) if (man == NULL) return; if (man->macroset == MACROSET_MDOC) { - mdoc_validate(man); + if (curp->outtype != OUTT_TREE || !curp->outopts->noval) + mdoc_validate(man); switch (curp->outtype) { case OUTT_HTML: html_mdoc(curp->outdata, man); @@ -735,7 +736,8 @@ parse(struct curparse *curp, int fd, const char *file) } } if (man->macroset == MACROSET_MAN) { - man_validate(man); + if (curp->outtype != OUTT_TREE || !curp->outopts->noval) + man_validate(man); switch (curp->outtype) { case OUTT_HTML: html_man(curp->outdata, man); diff --git a/usr.bin/mandoc/manconf.h b/usr.bin/mandoc/manconf.h index 64f04b3b55d..239e222a4fb 100644 --- a/usr.bin/mandoc/manconf.h +++ b/usr.bin/mandoc/manconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: manconf.h,v 1.3 2017/01/27 13:47:17 schwarze Exp $ */ +/* $OpenBSD: manconf.h,v 1.4 2017/02/10 15:44:31 schwarze Exp $ */ /* * Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> @@ -35,6 +35,7 @@ struct manoutput { int fragment; int mdoc; int synopsisonly; + int noval; }; struct manconf { diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index 300fee88c45..e4d7f6a2de2 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.97 2017/01/31 19:43:23 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.98 2017/02/10 15:44:31 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 31 2017 $ +.Dd $Mdocdate: February 10 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -538,6 +538,8 @@ A closing parenthesis if the node is a closing delimiter. .It A full stop if the node ends a sentence. .It +BROKEN if the node is a block broken by another block. +.It NOSRC if the node is not in the input file, but automatically generated from macros. .It @@ -545,6 +547,17 @@ NOPRT if the node is not supposed to generate output for any output format. .El .El +.Pp +The following +.Fl O +argument is accepted: +.Bl -tag -width Ds +.It Cm noval +Skip validation and show the unvalidated syntax tree. +This can help to find out whether a given behaviour is caused by +the parser or by the validator. +Meta data is not available in this case. +.El .Sh ENVIRONMENT .Bl -tag -width MANPAGER .It Ev MANPAGER diff --git a/usr.bin/mandoc/manpath.c b/usr.bin/mandoc/manpath.c index 718f8d945b9..aae0b75e30b 100644 --- a/usr.bin/mandoc/manpath.c +++ b/usr.bin/mandoc/manpath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: manpath.c,v 1.19 2017/01/27 13:47:17 schwarze Exp $ */ +/* $OpenBSD: manpath.c,v 1.20 2017/02/10 15:44:31 schwarze Exp $ */ /* * Copyright (c) 2011, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> @@ -225,7 +225,7 @@ manconf_output(struct manoutput *conf, const char *cp, int fromfile) { const char *const toks[] = { "includes", "man", "paper", "style", - "indent", "width", "fragment", "mdoc" + "indent", "width", "fragment", "mdoc", "noval" }; const char *errstr; @@ -309,6 +309,9 @@ manconf_output(struct manoutput *conf, const char *cp, int fromfile) case 7: conf->mdoc = 1; return 0; + case 8: + conf->noval = 1; + return 0; default: if (fromfile) warnx("-O %s: Bad argument", cp); diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index fe8cfa3422e..da944a8a615 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.166 2017/01/10 13:46:53 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.167 2017/02/10 15:44:31 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org> @@ -573,16 +573,24 @@ blk_exp_close(MACRO_PROT_ARGS) } /* - * Mismatching end macros can never break anything, - * SYNOPSIS name blocks can never be broken, + * Mismatching end macros can never break anything * and we only care about the breaking of BLOCKs. */ - if (body == NULL || - n->tok == MDOC_Nm || - n->type != ROFFT_BLOCK) + if (body == NULL || n->type != ROFFT_BLOCK) continue; + /* + * SYNOPSIS name blocks can not be broken themselves, + * but they do get broken together with a broken child. + */ + + if (n->tok == MDOC_Nm) { + if (later != NULL) + n->flags |= NODE_BROKEN | NODE_ENDED; + continue; + } + if (n->tok == MDOC_It) { itblk = n; continue; @@ -985,7 +993,7 @@ blk_full(MACRO_PROT_ARGS) /* Close out prior implicit scopes. */ - rew_last(mdoc, n); + rew_pending(mdoc, n); } /* Skip items outside lists. */ diff --git a/usr.bin/mandoc/tree.c b/usr.bin/mandoc/tree.c index c8d1b6eda55..d5070fe75ed 100644 --- a/usr.bin/mandoc/tree.c +++ b/usr.bin/mandoc/tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tree.c,v 1.39 2017/01/12 17:29:34 schwarze Exp $ */ +/* $OpenBSD: tree.c,v 1.40 2017/02/10 15:44:31 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -190,6 +190,8 @@ print_mdoc(const struct roff_node *n, int indent) putchar(')'); if (NODE_EOS & n->flags) putchar('.'); + if (NODE_BROKEN & n->flags) + printf(" BROKEN"); if (NODE_NOSRC & n->flags) printf(" NOSRC"); if (NODE_NOPRT & n->flags) |