From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout.scc.kit.edu (scc-mailout.scc.kit.edu [129.13.185.202]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p8S9LnZC025220 for ; Wed, 28 Sep 2011 05:21:50 -0400 (EDT) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1R8qKo-0003ax-Nd; Wed, 28 Sep 2011 11:21:46 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1R8qKo-0008Az-UJ; Wed, 28 Sep 2011 11:21:46 +0200 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1R8qKo-00072A-S1; Wed, 28 Sep 2011 11:21:46 +0200 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1R8qKo-0004gY-M5; Wed, 28 Sep 2011 11:21:46 +0200 Date: Wed, 28 Sep 2011 11:21:46 +0200 From: Ingo Schwarze To: tech@mdocml.bsd.lv Cc: naddy@openbsd.org Subject: -Tlint parser errors and warnings to stdout Message-ID: <20110928092146.GA5320@iris.usta.de> References: <20110925101243.GC4867@iris.usta.de> <20110925111746.GA14018@lain.home> <20110925180227.GJ4867@iris.usta.de> <20110925182641.GA26028@britannica.bec.de> <4E810578.7040008@bsd.lv> <20110927051427.GA16670@britannica.bec.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110927051427.GA16670@britannica.bec.de> User-Agent: Mutt/1.5.21 (2010-09-15) Hi, Joerg Sonnenberger wrote on Tue, Sep 27, 2011 at 07:14:27AM +0200: > On Tue, Sep 27, 2011 at 01:06:32AM +0200, Kristaps Dzonsons wrote: >> The -Tlint thing is a different story. At first I thought (Ingo >> will recognise this behaviour) No Way In Hell. But (1) mdoclint in >> regress pushes to stdout; (2) lint itself pushes to stdout; and (3) >> there's no real notion of portability/compat so we can do what works >> best for us. So basically I'm fine with sticking a dup2 in there if >> people think it will save time and effort. > ...or do some refactoring and replace stderr with errout and just > reassign the variable? Here is a patch doing it in about that way, only slightly different. Restore the half-removed curparse argument to mandocmsg(), than use that to either select stderr or stdout for parser diagnostic output. OK? Ingo Index: main.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/main.c,v retrieving revision 1.78 diff -u -p -r1.78 main.c --- main.c 17 Sep 2011 14:45:22 -0000 1.78 +++ main.c 28 Sep 2011 09:08:05 -0000 @@ -59,7 +59,8 @@ struct curparse { static int moptions(enum mparset *, char *); static void mmsg(enum mandocerr, enum mandoclevel, - const char *, int, int, const char *); + const char *, int, int, const char *, + void *); static void parse(struct curparse *, int, const char *, enum mandoclevel *); static int toptions(struct curparse *, char *); @@ -370,16 +371,22 @@ woptions(struct curparse *curp, char *ar static void mmsg(enum mandocerr t, enum mandoclevel lvl, - const char *file, int line, int col, const char *msg) + const char *file, int line, int col, const char *msg, + void *arg) { + struct curparse *curp; + FILE *stream; - fprintf(stderr, "%s:%d:%d: %s: %s", + curp = (struct curparse *)arg; + stream = OUTT_LINT == curp->outtype ? stdout : stderr; + + fprintf(stream, "%s:%d:%d: %s: %s", file, line, col + 1, mparse_strlevel(lvl), mparse_strerror(t)); if (msg) - fprintf(stderr, ": %s", msg); + fprintf(stream, ": %s", msg); - fputc('\n', stderr); + fputc('\n', stream); } Index: mandoc.h =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v retrieving revision 1.40 diff -u -p -r1.40 mandoc.h --- mandoc.h 18 Sep 2011 10:25:28 -0000 1.40 +++ mandoc.h 28 Sep 2011 09:08:05 -0000 @@ -391,7 +391,7 @@ enum mandoc_esc { }; typedef void (*mandocmsg)(enum mandocerr, enum mandoclevel, - const char *, int, int, const char *); + const char *, int, int, const char *, void *); struct mparse; struct mchars; Index: read.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/read.c,v retrieving revision 1.3 diff -u -p -r1.3 read.c --- read.c 18 Sep 2011 10:25:28 -0000 1.3 +++ read.c 28 Sep 2011 09:08:06 -0000 @@ -748,7 +748,7 @@ mandoc_msg(enum mandocerr er, struct mpa return; if (m->mmsg) - (*m->mmsg)(er, level, m->file, ln, col, msg); + (*m->mmsg)(er, level, m->file, ln, col, msg, m->arg); if (m->file_status < level) m->file_status = level; -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv