discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* making all warnings fatal again?
@ 2017-01-07  2:33 Yuri Pankov
  2017-01-09  2:45 ` Ingo Schwarze
  0 siblings, 1 reply; 3+ messages in thread
From: Yuri Pankov @ 2017-01-07  2:33 UTC (permalink / raw)
  To: discuss

Hi,

Switching from 1.13.3 to 1.13.4 made mandoc -Tlint exit 0 instead of 2 
for *some* of the warnings it reports. Is there a way to make all 
warnings "fatal" again?

For example (not limited to this one, of course):

1.13.3:

$ mandoc -Tlint foo.1; echo $?
mandoc: foo.1:2:5: WARNING: lower case character in document title: Dt foo
2

1.13.4:

$ mandoc -Tlint foo.1; echo $?
mandoc: foo.1:2:5: WARNING: lower case character in document title: Dt foo
0


P.S.: are the list archives available somewhere?
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

* Re: making all warnings fatal again?
  2017-01-07  2:33 making all warnings fatal again? Yuri Pankov
@ 2017-01-09  2:45 ` Ingo Schwarze
  2017-01-09 22:10   ` Yuri Pankov
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Schwarze @ 2017-01-09  2:45 UTC (permalink / raw)
  To: Yuri Pankov; +Cc: discuss

Hi,

Yuri Pankov wrote on Sat, Jan 07, 2017 at 05:33:26AM +0300:

> Switching from 1.13.3 to 1.13.4 made mandoc -Tlint exit 0
> instead of 2 for *some* of the warnings it reports.
> Is there a way to make all warnings "fatal" again?

Ouch.  That is an evil regression that i missed.
Thank you very much for reporting it!

> For example (not limited to this one, of course):
> 
> 1.13.3:
> 
> $ mandoc -Tlint foo.1; echo $?
> mandoc: foo.1:2:5: WARNING: lower case character in document title: Dt foo
> 2
> 
> 1.13.4:
> 
> $ mandoc -Tlint foo.1; echo $?
> mandoc: foo.1:2:5: WARNING: lower case character in document title: Dt foo
> 0

True, it got broken.  Failures in the checks that were moved
to mdoc_validate() and man_validate() got ignored in the mandoc(1)
EXIT STATUS, which was wrong.

I just fixed it in bsd.lv -current and in OpenBSD with the commit
below.

I hope that it applies to the illumos tree.  It does apply to the
vanilla 1.13.4 release version for me, and it seems to work there,
too, and not just in HEAD.

When 1.13.5 and 1.14 get released, this fix wil be contained,
but there is no release schedule yet.

> P.S.: are the list archives available somewhere?

Unfortunately, no.  The list server does retain copies of the
messages gone through, but the work of making them public was
never done.

Yours,
  Ingo


Log Message:
-----------
Warnings and errors that occur during mdoc_validate() 
or during man_validate() have to affect the mandoc(1) EXIT STATUS.
Many thanks to <Yuri dot Pankov at gmail dot com> (illumos developer)
for reporting this regression.

Modified Files:
--------------
    mdocml:
        main.c
        mandoc.3
        mandoc.h
        read.c

Revision Data
-------------
Index: mandoc.3
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.3,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lmandoc.3 -Lmandoc.3 -u -p -r1.37 -r1.38
--- mandoc.3
+++ mandoc.3
@@ -1,7 +1,7 @@
 .\"	$Id$
 .\"
 .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
-.\" Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
 .\" purpose with or without fee is hereby granted, provided that the above
@@ -34,7 +34,8 @@
 .Nm mparse_reset ,
 .Nm mparse_result ,
 .Nm mparse_strerror ,
-.Nm mparse_strlevel
+.Nm mparse_strlevel ,
+.Nm mparse_updaterc 
 .Nd mandoc macro compiler library
 .Sh SYNOPSIS
 .In sys/types.h
@@ -100,6 +101,11 @@
 .Fo mparse_strlevel
 .Fa "enum mandoclevel"
 .Fc
+.Ft void
+.Fo mparse_updaterc
+.Fa "struct mparse *parse"
+.Fa "enum mandoclevel *rc"
+.Fc
 .In roff.h
 .Ft void
 .Fo deroff
@@ -181,6 +187,9 @@ or
 .Fn man_validate ,
 respectively;
 .It
+if information about the validity of the input is needed, fetch it with
+.Fn mparse_updaterc ;
+.It
 iterate over parse nodes with starting from the
 .Fa first
 member of the returned
@@ -412,6 +421,22 @@ implemented in
 .Pa read.c .
 .It Fn mparse_strlevel
 Return a statically-allocated string representation of a level code.
+Declared in
+.In mandoc.h ,
+implemented in
+.Pa read.c .
+.It Fn mparse_updaterc
+If the highest warning or error level that occurred during the current
+.Fa parse
+is higher than
+.Pf * Fa rc ,
+update
+.Pf * Fa rc
+accordingly.
+This is useful after calling
+.Fn mdoc_validate
+or
+.Fn man_validate .
 Declared in
 .In mandoc.h ,
 implemented in
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -Lread.c -Lread.c -u -p -r1.156 -r1.157
--- read.c
+++ read.c
@@ -867,6 +867,13 @@ mparse_result(struct mparse *curp, struc
 }
 
 void
+mparse_updaterc(struct mparse *curp, enum mandoclevel *rc)
+{
+	if (curp->file_status > *rc)
+		*rc = curp->file_status;
+}
+
+void
 mandoc_vmsg(enum mandocerr t, struct mparse *m,
 		int ln, int pos, const char *fmt, ...)
 {
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.212
retrieving revision 1.213
diff -Lmandoc.h -Lmandoc.h -u -p -r1.212 -r1.213
--- mandoc.h
+++ mandoc.h
@@ -435,3 +435,4 @@ void		  mparse_result(struct mparse *,
 const char	 *mparse_getkeep(const struct mparse *);
 const char	 *mparse_strerror(enum mandocerr);
 const char	 *mparse_strlevel(enum mandoclevel);
+void		  mparse_updaterc(struct mparse *, enum mandoclevel *);
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.277
retrieving revision 1.278
diff -Lmain.c -Lmain.c -u -p -r1.277 -r1.278
--- main.c
+++ main.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -781,6 +781,7 @@ parse(struct curparse *curp, int fd, con
 			break;
 		}
 	}
+	mparse_updaterc(curp->mp, &rc);
 }
 
 static void
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

* Re: making all warnings fatal again?
  2017-01-09  2:45 ` Ingo Schwarze
@ 2017-01-09 22:10   ` Yuri Pankov
  0 siblings, 0 replies; 3+ messages in thread
From: Yuri Pankov @ 2017-01-09 22:10 UTC (permalink / raw)
  To: Ingo Schwarze; +Cc: discuss

On Mon, 9 Jan 2017 03:45:55 +0100, Ingo Schwarze wrote:
> Hi,
>
> Yuri Pankov wrote on Sat, Jan 07, 2017 at 05:33:26AM +0300:
>
>> Switching from 1.13.3 to 1.13.4 made mandoc -Tlint exit 0
>> instead of 2 for *some* of the warnings it reports.
>> Is there a way to make all warnings "fatal" again?
>
> Ouch.  That is an evil regression that i missed.
> Thank you very much for reporting it!
>
>> For example (not limited to this one, of course):
>>
>> 1.13.3:
>>
>> $ mandoc -Tlint foo.1; echo $?
>> mandoc: foo.1:2:5: WARNING: lower case character in document title: Dt foo
>> 2
>>
>> 1.13.4:
>>
>> $ mandoc -Tlint foo.1; echo $?
>> mandoc: foo.1:2:5: WARNING: lower case character in document title: Dt foo
>> 0
>
> True, it got broken.  Failures in the checks that were moved
> to mdoc_validate() and man_validate() got ignored in the mandoc(1)
> EXIT STATUS, which was wrong.
>
> I just fixed it in bsd.lv -current and in OpenBSD with the commit
> below.
>
> I hope that it applies to the illumos tree.  It does apply to the
> vanilla 1.13.4 release version for me, and it seems to work there,
> too, and not just in HEAD.

Yes, I've picked up the changes from VERSION_1_13, everything seems to 
be correct now. Thanks for fixing it!

> When 1.13.5 and 1.14 get released, this fix wil be contained,
> but there is no release schedule yet.
>
>> P.S.: are the list archives available somewhere?
>
> Unfortunately, no.  The list server does retain copies of the
> messages gone through, but the work of making them public was
> never done.
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

end of thread, other threads:[~2017-01-09 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-07  2:33 making all warnings fatal again? Yuri Pankov
2017-01-09  2:45 ` Ingo Schwarze
2017-01-09 22:10   ` Yuri Pankov

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).