diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-07-20 15:26:36 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-07-20 15:26:36 +0000 |
commit | 57e5cdc43baa5d1534522d1cd366b75bbe3e2d59 (patch) | |
tree | 3e03b4643ca1fa0cc9454097453f00b50e519cdb /usr.bin | |
parent | 1833c81f63ce8f2851008d6ec13988d0108a79f2 (diff) |
For -Tlint, put parser messages on stdout instead of stderr.
Originally, naddy@ requested this in 2011 (or maybe even earlier).
It was discussed with joerg@, kristaps@, naddy@, and espie@ in 2011,
and everybody agreed in principle, but it was postponed because
kristaps@ wanted to do some cleanup of the message system first.
Meanwhile, message infrastructure was improved about a dozen times...
This makes long, tedious commands like "mandoc -Tlint *.1 2>&1 | less"
unnecessary and allows simple ones like "man -l -Tlint *.1".
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/main.c | 17 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.1 | 8 |
2 files changed, 15 insertions, 10 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 7710854ed97..0153375ebbf 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.202 2017/07/04 14:40:30 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.203 2017/07/20 15:26:35 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -105,6 +105,7 @@ static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; static char help_arg[] = "help"; static char *help_argv[] = {help_arg, NULL}; static enum mandoclevel rc; +static FILE *mmsg_stream; int @@ -166,6 +167,7 @@ main(int argc, char *argv[]) curp.mmin = MANDOCERR_MAX; curp.outopts = &conf.output; options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1; + mmsg_stream = stderr; use_pager = 1; tag_files = NULL; @@ -964,6 +966,7 @@ toptions(struct curparse *curp, char *arg) else if (0 == strcmp(arg, "lint")) { curp->outtype = OUTT_LINT; curp->mmin = MANDOCERR_BASE; + mmsg_stream = stdout; } else if (0 == strcmp(arg, "tree")) curp->outtype = OUTT_TREE; else if (0 == strcmp(arg, "man")) @@ -1053,21 +1056,21 @@ mmsg(enum mandocerr t, enum mandoclevel lvl, { const char *mparse_msg; - fprintf(stderr, "%s: %s:", getprogname(), + fprintf(mmsg_stream, "%s: %s:", getprogname(), file == NULL ? "<stdin>" : file); if (line) - fprintf(stderr, "%d:%d:", line, col + 1); + fprintf(mmsg_stream, "%d:%d:", line, col + 1); - fprintf(stderr, " %s", mparse_strlevel(lvl)); + fprintf(mmsg_stream, " %s", mparse_strlevel(lvl)); if ((mparse_msg = mparse_strerror(t)) != NULL) - fprintf(stderr, ": %s", mparse_msg); + fprintf(mmsg_stream, ": %s", mparse_msg); if (msg) - fprintf(stderr, ": %s", msg); + fprintf(mmsg_stream, ": %s", msg); - fputc('\n', stderr); + fputc('\n', mmsg_stream); } static pid_t diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index 8d7a0d685a5..673df196ff8 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.140 2017/07/07 16:19:30 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.141 2017/07/20 15:26:35 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: July 7 2017 $ +.Dd $Mdocdate: July 20 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -238,7 +238,9 @@ See .It Fl T Cm lint Parse only: produce no output. Implies -.Fl W Cm all . +.Fl W Cm all +and redirects parser messages, which usually appear +on standard error output, to standard output. .It Fl T Cm locale Encode output using the current locale. This is the default. |