On Mon, Apr 05, 2021 at 06:47:58PM +0200, Ingo Schwarze wrote:
> Hi,
>
> Klemens Nanni wrote on Sun, Apr 04, 2021 at 03:54:43PM +0200:
> > On Sun, Apr 04, 2021 at 03:42:03PM +0200, Tim van der Molen wrote:
>
> >> Doesn't mandoc -Tlint -Wstyle do what you want?
>
> > I don't think so. Oddly enough, `-Wstyle' does not do what I would
> > expect: it omits STYLE messages instead of printing them.
>
> It does not. It only omits BASE messages, which is the lowest message
> level and the only one below STYLE. See `man -O tag=base mandoc`
> what the purpose of BASE is.
>
> When i inplemented the BASE level, i first printed these messages
> with a BASE tag. But other developers complained that "BASE" is
> unclear and confusing and requested that STYLE be printed instead.
> For that reason, both levels print STYLE. I don't like that, it
> is also confusing, just in a different way. But unless you come
> up with a name better than "BASE" that other developers will not
> complain about, i don't know how to improve it.
>
> You can still visually distinguish STYLE and BASE messages since the
> latter have an (OpenBSD) or (NetBSD) tag at the end:
>
> $ man -clT lint /co/NetBSD/src/usr.bin/true/true.1
> man: /co/NetBSD/src/usr.bin/true/true.1:34:4: STYLE: duplicate RCS id:
> $NetBSD: true.1,v 1.7 2003/08/07 11:16:48 agc Exp $
> man: /co/NetBSD/src/usr.bin/true/true.1:36:5: STYLE: Mdocdate missing:
> Dd June 27, 1991 (OpenBSD)
> man: /co/NetBSD/src/usr.bin/true/true.1: STYLE: RCS id missing: (OpenBSD)
>
> $ man -cT lint -W netbsd true
> man: /usr/share/man/man1/true.1:35:5: STYLE: Mdocdate found:
> Dd $Mdocdate: September 29 2010 $ (NetBSD)
> man: /usr/share/man/man1/true.1: STYLE: RCS id missing: (NetBSD)
>
>
> >> -Wstyle also suppresses other warnings that aren't interesting for
> >> manuals not part of OpenBSD:
>
> Indeed, that's exactly what it was designed for.
>
> > But it would also suppress legitimate messages, e.g. `.Xr' macros with
> > misspelled manuals in the base MANPATH:
>
> Yes, so far, checking of .Xr targets is only done on the BASE level,
> not on the STYLE level because i regarded the requirement that .Xr targets
> exist as a requirement of the OpenBSD base system. For portable software
> outside the OpenBSD base system, in the past, i didn't think checking .Xr
> targets would be helpful. It appears you now found a use case for that.
A use case, but not really a requirement, at least not for people
developing portable software on OpenBSD -- that's where I'm coming from:
messages telling me installed manuals cannot be found are annoying.
But I guess that turns into a valid use case as soon as mandoc is used
on and for another system with different manual paths.
> Your patch is not OK as it stands because mandoc would no longer help
> developers working on the base system to find .Xr links pointing
> outside the base system, and we have a policy that we don't want those.
Agreed.
> I guess the right thing to do is to leave "-W all" unchanged (including
> looking in the base system only) but change "-W style" to also do the .Xr
> target check, but along the user's manpath.
That makes sense and the diff below enables check_xr() to pick the right
manual paths.
HOWEVER it currently won't print anything because when `-Wstyle' is used
mandoc_msg(MANDOCERR_XR_BAD, ...) in check_xr() won't print anything as
MANDOC_XR_BAD is lower than MANDOCERR_STYLE.
I played swapping those two levels in the `enum mandocerr' but that
won't quite work (e.g. mandoc_msg() printing the wrong message)...
Ingo, perhaps you have an idea on how to fix that?
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.256
diff -u -p -r1.256 main.c
--- main.c 19 Feb 2021 19:49:49 -0000 1.256
+++ main.c 5 Apr 2021 19:20:22 -0000
@@ -949,7 +949,7 @@ parse(struct mparse *mp, int fd, const c
if (outconf->tag != NULL && outconf->tag_found == 0 &&
tag_exists(outconf->tag))
outconf->tag_found = 1;
- if (mandoc_msg_getmin() < MANDOCERR_STYLE)
+ if (mandoc_msg_getmin() <= MANDOCERR_STYLE)
check_xr();
}
@@ -957,12 +957,22 @@ static void
check_xr(void)
{
static struct manpaths paths;
+ static struct manconf conf;
struct mansearch search;
struct mandoc_xr *xr;
size_t sz;
- if (paths.sz == 0)
- manpath_base(&paths);
+ if (paths.sz == 0) {
+ if (mandoc_msg_getmin() == MANDOCERR_BASE)
+ manpath_base(&paths);
+ else {
+ manconf_parse(&conf, NULL, NULL, NULL);
+ if (conf.manpath.sz != 0)
+ paths = conf.manpath;
+ else
+ manpath_base(&paths);
+ }
+ }
for (xr = mandoc_xr_get(); xr != NULL; xr = xr->next) {
if (xr->line == -1)