aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-07-20 15:26:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-07-20 15:26:41 +0000
commitc257c8a3f34243f4c544a843c2ec61577f07aabe (patch)
treeade03e4176844a2393bdd330d50b88b375366c64 /main.c
parent0d1c0a686376f865341ab91184438f959f98dc68 (diff)
downloadmandoc-c257c8a3f34243f4c544a843c2ec61577f07aabe.tar.gz
mandoc-c257c8a3f34243f4c544a843c2ec61577f07aabe.tar.zst
mandoc-c257c8a3f34243f4c544a843c2ec61577f07aabe.zip
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 'main.c')
-rw-r--r--main.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/main.c b/main.c
index ef051e53..8b600bbc 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.299 2017/07/04 14:40:38 schwarze Exp $ */
+/* $Id: main.c,v 1.300 2017/07/20 15:26:41 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -111,6 +111,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
@@ -190,6 +191,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;
@@ -994,6 +996,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"))
@@ -1083,21 +1086,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