tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* -Tlint parser errors and warnings to stdout
       [not found]                 ` <20110927051427.GA16670@britannica.bec.de>
@ 2011-09-28  9:21                   ` Ingo Schwarze
  2011-10-02 15:12                     ` Kristaps Dzonsons
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Schwarze @ 2011-09-28  9:21 UTC (permalink / raw)
  To: tech; +Cc: naddy

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: -Tlint parser errors and warnings to stdout
  2011-09-28  9:21                   ` -Tlint parser errors and warnings to stdout Ingo Schwarze
@ 2011-10-02 15:12                     ` Kristaps Dzonsons
  2011-10-03 22:26                       ` Ingo Schwarze
  0 siblings, 1 reply; 3+ messages in thread
From: Kristaps Dzonsons @ 2011-10-02 15:12 UTC (permalink / raw)
  To: tech; +Cc: Ingo Schwarze, naddy

On 09/28/2011 11:21 AM, Ingo Schwarze wrote:
> 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.

Let's hold off on this for a little bit, as there are some elements that 
need thought before going down this road (which I'm ok with, I should 
clarify).  Foremost, since mandoc.3 is built to be a library upstream, 
system errors should be reporting by the same (or parallel) interface as 
mandoc parse errors---NOT using perror or whatnot.  This has bugged me 
for a while, but I've not had the motivation to fix it---let me do so 
before we continue along this road.

Thanks,

Kristaps
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: -Tlint parser errors and warnings to stdout
  2011-10-02 15:12                     ` Kristaps Dzonsons
@ 2011-10-03 22:26                       ` Ingo Schwarze
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Schwarze @ 2011-10-03 22:26 UTC (permalink / raw)
  To: tech; +Cc: naddy

Hi Kristaps,

Kristaps Dzonsons wrote on Sun, Oct 02, 2011 at 05:12:52PM +0200:
> On 09/28/2011 11:21 AM, Ingo Schwarze wrote:
>> 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.

> Let's hold off on this for a little bit, as there are some elements
> that need thought before going down this road (which I'm ok with, I
> should clarify).  Foremost, since mandoc.3 is built to be a library
> upstream, system errors should be reporting by the same (or
> parallel) interface as mandoc parse errors---NOT using perror or
> whatnot.  This has bugged me for a while, but I've not had the
> motivation to fix it---let me do so before we continue along this
> road.

No problem, so i'm postponing my patch until you have done the
cleanup.  No particular hurry, but if we want to do it, i think
we should get it off the table until about the end of the year,
to not get too close to the 5.1 release phase.

Yours,
  Ingo
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-03 22:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAOS-L3iOOY_2nBA5tdv-xVo92rKK7=spNBBz4Qo__6op+CJdJg@mail.gmail.com>
     [not found] ` <CALi5TckNuUDm8+yb967XpeT7rgAbA9YFO=KOgm0HFx6Dghkp+A@mail.gmail.com>
     [not found]   ` <slrnj7pdak.r8j.stu@naiad.spacehopper.org>
     [not found]     ` <CALi5Tcn4M7kYmcx8tpPnC=TVO3tZ14yayOVhf+jrUXxEKZWVKw@mail.gmail.com>
     [not found]       ` <20110925101243.GC4867@iris.usta.de>
     [not found]         ` <20110925111746.GA14018@lain.home>
     [not found]           ` <20110925180227.GJ4867@iris.usta.de>
     [not found]             ` <20110925182641.GA26028@britannica.bec.de>
     [not found]               ` <4E810578.7040008@bsd.lv>
     [not found]                 ` <20110927051427.GA16670@britannica.bec.de>
2011-09-28  9:21                   ` -Tlint parser errors and warnings to stdout Ingo Schwarze
2011-10-02 15:12                     ` Kristaps Dzonsons
2011-10-03 22:26                       ` Ingo Schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).