discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Yuri Pankov <yuri.pankov@gmail.com>
Cc: discuss@mdocml.bsd.lv
Subject: Re: making all warnings fatal again?
Date: Mon, 9 Jan 2017 03:45:55 +0100	[thread overview]
Message-ID: <20170109024555.GF4271@athene.usta.de> (raw)
In-Reply-To: <4e555214-ac40-382d-5495-533423a35219@gmail.com>

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

  reply	other threads:[~2017-01-09  2:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-07  2:33 Yuri Pankov
2017-01-09  2:45 ` Ingo Schwarze [this message]
2017-01-09 22:10   ` Yuri Pankov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170109024555.GF4271@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=discuss@mdocml.bsd.lv \
    --cc=yuri.pankov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).