Discussion:
mandoc -Tlint and Mdocdate
Sebastien Marie
2017-06-21 07:04:19 UTC
Permalink
Hi,

With latest commits on mandoc (particulary mdoc_validate.c r1.252), I
have a problem with mandoc -Tlint regarding Dd macro.

Some days ago, I started to validate the man page of sysclean using
mandoc -Tlint.

sysclean is a tool designed for OpenBSD, and maintained externally in a
git repository.

The current preambule for sysclean.8 (in master) is :

.Dd June 18, 2017
.Dt SYSCLEAN 8
.Os

According to mdoc(7), there are valids:

Document preamble and NAME section macros
Dd document date: $Mdocdate$ | month day, year
Dt document title: TITLE section [arch]
Os operating system version: [system [version]]

But mandoc -Tlint complains about missing Mdocdate.

$ mandoc -Tlint sysclean.8
mandoc: sysclean.8:17:5: STYLE: Mdocdate missing: Dd June

The current check requires Dd to be in "Mdocdate" format if the Os is
OpenBSD. It seems to me it doesn't respect the specification, which
allow Dd to be a plain date (month day, year).

Due to the fact I am not using CVS for this project, I couldn't use
$Mdocdate$ keyword (and have the date isn't automatically filled).

Alternatively, I could maintain manually Dd as "$Mdocdate: month day year $",
but it seems a limitation for me, so I prefer reported it.

Thanks.
--
Sebastien Marie
Jason McIntyre
2017-06-21 07:27:57 UTC
Permalink
Post by Sebastien Marie
Hi,
With latest commits on mandoc (particulary mdoc_validate.c r1.252), I
have a problem with mandoc -Tlint regarding Dd macro.
Some days ago, I started to validate the man page of sysclean using
mandoc -Tlint.
sysclean is a tool designed for OpenBSD, and maintained externally in a
git repository.
.Dd June 18, 2017
.Dt SYSCLEAN 8
.Os
morning.

presumably because you have a blank Os field, mandoc will look
elesewhere and is concluding that this is openbsd. maybe you can use a
dummy value, but wait for ingo's reply, as he will better know the
criteria for Os matching, and what a good way to do this is.

note that this is just flagging this as "STYLE": the old style Dd does
work (hence just ignoring the message may be the best choice). but it's
not "not respecting the specification".

jmc
Post by Sebastien Marie
Document preamble and NAME section macros
Dd document date: $Mdocdate$ | month day, year
Dt document title: TITLE section [arch]
Os operating system version: [system [version]]
But mandoc -Tlint complains about missing Mdocdate.
$ mandoc -Tlint sysclean.8
mandoc: sysclean.8:17:5: STYLE: Mdocdate missing: Dd June
The current check requires Dd to be in "Mdocdate" format if the Os is
OpenBSD. It seems to me it doesn't respect the specification, which
allow Dd to be a plain date (month day, year).
Due to the fact I am not using CVS for this project, I couldn't use
$Mdocdate$ keyword (and have the date isn't automatically filled).
Alternatively, I could maintain manually Dd as "$Mdocdate: month day year $",
but it seems a limitation for me, so I prefer reported it.
Thanks.
--
Sebastien Marie
Jeremie Courreges-Anglas
2017-06-21 09:39:53 UTC
Permalink
This post might be inappropriate. Click to display it.
Sebastien Marie
2017-06-21 10:26:14 UTC
Permalink
Post by Jeremie Courreges-Anglas
Post by Sebastien Marie
But mandoc -Tlint complains about missing Mdocdate.
$ mandoc -Tlint sysclean.8
mandoc: sysclean.8:17:5: STYLE: Mdocdate missing: Dd June
With another project, I get this warning about Dd, plus a message about
a missing RCS Id.
ah, I don't have this one. But after checking, my man page has a
$OpenBSD$ tag inside it... it should come from the mdoc.template I used
to start writing the file. :)

If I remove it, I have the same STYLE warning.
Post by Jeremie Courreges-Anglas
Post by Sebastien Marie
Alternatively, I could maintain manually Dd as "$Mdocdate: month day year $",
but it seems a limitation for me, so I prefer reported it.
I can just ignore those STYLE warnings. Using -Wwarning to get rid of
STYLE warnings would lose quite a useful tips, right?
According to mandoc man page, -Wwarning will avoid all styles warning.
Here the complete list (taken from mandoc.h):

MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_MISSING, /* RCS id missing */
MANDOCERR_RCS_REP, /* duplicate RCS id: ... */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
MANDOCERR_ER_ORDER, /* errnos out of order: Er ... */
MANDOCERR_ER_REP, /* duplicate errno: Er ... */
MANDOCERR_ND_DOT, /* description line ends with a full stop */
MANDOCERR_DELIM, /* no blank before trailing delimiter: macro ... */
MANDOCERR_FUNC, /* function name without markup: name() */
--
Sebastien Marie
Ingo Schwarze
2017-06-21 15:22:12 UTC
Permalink
Hi Sebastien and Jeremie,
Post by Sebastien Marie
Post by Jeremie Courreges-Anglas
Post by Sebastien Marie
But mandoc -Tlint complains about missing Mdocdate.
$ mandoc -Tlint sysclean.8
mandoc: sysclean.8:17:5: STYLE: Mdocdate missing: Dd June
With another project, I get this warning about Dd, plus a message
about a missing RCS Id.
ah, I don't have this one. But after checking, my man page has a
$OpenBSD$ tag inside it... it should come from the mdoc.template I
used to start writing the file. :)
If I remove it, I have the same STYLE warning.
You currently have the following options:

1. Ignore the two style messages.
As jmc@ rightly observed, and as the mandoc(1) manual says
below DIAGNOSTICS, a style recommendation is not an error,
and style messages are occasionally false positives.
Both of these messages occur at most once per page.

Of course, having to ignore a message is not fully satisfactory,
and keeping false positives down to a minimum *is* among my
goals, even for style recommendations.

2. Put a dummy .\" $OpenBSD$ line and a manually maintained
.Dd $Mdocdate Month day year$ line into the file even though
your VCS won't expand it.

That is icky, working around an issue in a non-intuitive way
instead of solving the root cause, so i can't really recommend it.

3. Use "mandoc -Ios= -Tlint" for checking pages that are supposed
to be portable.

That is not fully satisfactory because it disables *all* operating
system specific style messages. It is likely that you do want to
follow OpenBSD style in general, just not those parts that apply
to the base system only.

4. Put something like ".Os ratpoison" into the manual page.

I clearly recommend against that. It not only suppers from
the same problem as option 3 of disabling more than intended;
it also results in an inconsistent user experience with the
bottom line of manual pages (admittedly a minor point, though).

5. Use "mandoc -Tlint -Wwarning" for these projects.

I clearly recommend against that. It disables even more than
option 3, namely, all style recommendations, most of which are
just as useful for portable projects as for base system manuals.

As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.

In general, i don't like adding knobs. But when the choice is
between having innocent people harassed with false positives and
between providing a knob for saying which checks you want, in a way
that is actually needed in practice, then i prefer the knob to the
harassment.

OK for the patch below?
Post by Sebastien Marie
According to mandoc man page, -Wwarning will avoid all styles warning.
The list of messages is also in the mandoc(1) manual, with an
explanation of each message.

Yours,
Ingo


Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.195
diff -u -p -r1.195 main.c
--- main.c 3 Jun 2017 12:16:19 -0000 1.195
+++ main.c 21 Jun 2017 15:09:46 -0000
@@ -68,8 +68,8 @@ enum outt {

struct curparse {
struct mparse *mp;
- enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
+ enum mandocerr mmin; /* ignore messages below this */
enum outt outtype; /* which output to use */
void *outdata; /* data for output */
struct manoutput *outopts; /* output options */
@@ -159,7 +159,7 @@ main(int argc, char *argv[])

memset(&curp, 0, sizeof(struct curparse));
curp.outtype = OUTT_LOCALE;
- curp.wlevel = MANDOCLEVEL_BADARG;
+ curp.mmin = MANDOCERR_MAX;
curp.outopts = &conf.output;
options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
defos = NULL;
@@ -416,7 +416,7 @@ main(int argc, char *argv[])
moptions(&options, auxpaths);

mchars_alloc();
- curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos);
+ curp.mp = mparse_alloc(options, curp.mmin, mmsg, defos);

/*
* Conditionally start up the lookaside buffer before parsing.
@@ -907,7 +907,7 @@ toptions(struct curparse *curp, char *ar
curp->outtype = OUTT_ASCII;
else if (0 == strcmp(arg, "lint")) {
curp->outtype = OUTT_LINT;
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_STYLE;
} else if (0 == strcmp(arg, "tree"))
curp->outtype = OUTT_TREE;
else if (0 == strcmp(arg, "man"))
@@ -936,16 +936,17 @@ static int
woptions(struct curparse *curp, char *arg)
{
char *v, *o;
- const char *toks[8];
+ const char *toks[9];

toks[0] = "stop";
toks[1] = "all";
toks[2] = "style";
- toks[3] = "warning";
- toks[4] = "error";
- toks[5] = "unsupp";
- toks[6] = "fatal";
- toks[7] = NULL;
+ toks[3] = "portable";
+ toks[4] = "warning";
+ toks[5] = "error";
+ toks[6] = "unsupp";
+ toks[7] = "fatal";
+ toks[8] = NULL;

while (*arg) {
o = arg;
@@ -955,19 +956,22 @@ woptions(struct curparse *curp, char *ar
break;
case 1:
case 2:
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_STYLE;
break;
case 3:
- curp->wlevel = MANDOCLEVEL_WARNING;
+ curp->mmin = MANDOCERR_PORTABLE;
break;
case 4:
- curp->wlevel = MANDOCLEVEL_ERROR;
+ curp->mmin = MANDOCERR_WARNING;
break;
case 5:
- curp->wlevel = MANDOCLEVEL_UNSUPP;
+ curp->mmin = MANDOCERR_ERROR;
break;
case 6:
- curp->wlevel = MANDOCLEVEL_BADARG;
+ curp->mmin = MANDOCERR_UNSUPP;
+ break;
+ case 7:
+ curp->mmin = MANDOCERR_MAX;
break;
default:
warnx("-W %s: Bad argument", o);
Index: mandoc.1
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
retrieving revision 1.125
diff -u -p -r1.125 mandoc.1
--- mandoc.1 17 Jun 2017 23:06:43 -0000 1.125
+++ mandoc.1 21 Jun 2017 15:09:46 -0000
@@ -158,7 +158,12 @@ or
.Cm unsupp ;
.Cm all
is an alias for
-.Cm style .
+.Cm style ,
+and
+.Cm portable
+is a variant of
+.Cm style
+hiding style recommendations that only apply to base system manuals.
By default,
.Nm
is silent.
@@ -746,7 +751,7 @@ are hidden unless their level, or a lowe
option or
.Fl T Cm lint
output mode.
-.Ss Style messages
+.Pp
As indicated below, some style checks are only performed if a
specific operating system name occurs in the arguments of the
.Ic \&Os
@@ -756,6 +761,10 @@ command line option, or, if neither are
of the
.Xr uname 3
function.
+.Ss Style messages for base system manuals
+These are not shown if
+.Fl W Cm portable
+is specified.
.Bl -ohang
.It Sy "Mdocdate found"
.Pq mdoc , Nx
@@ -778,6 +787,17 @@ macro does not use CVS
keyword substitution, but using it is conventionally expected in the
.Ox
base system.
+.It Sy "RCS id missing"
+.Pq Ox , Nx
+The manual page lacks the comment line with the RCS identifier
+generated by CVS
+.Ic OpenBSD
+or
+.Ic NetBSD
+keyword substitution as conventionally used in these operating systems.
+.El
+.Ss Style messages for all manual pages
+.Bl -ohang
.It Sy "legacy man(7) date format"
.Pq mdoc
The
@@ -791,14 +811,6 @@ Consider using the conventional
date format
.Dq "Month dd, yyyy"
instead.
-.It Sy "RCS id missing"
-.Pq Ox , Nx
-The manual page lacks the comment line with the RCS identifier
-generated by CVS
-.Ic OpenBSD
-or
-.Ic NetBSD
-keyword substitution as conventionally used in these operating systems.
.It Sy "duplicate RCS id"
A single manual page contains two copies of the RCS identifier for
the same operating system.
Index: mandoc.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v
retrieving revision 1.174
diff -u -p -r1.174 mandoc.h
--- mandoc.h 17 Jun 2017 23:06:43 -0000 1.174
+++ mandoc.h 21 Jun 2017 15:09:46 -0000
@@ -48,8 +48,11 @@ enum mandocerr {

MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
- MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_MISSING, /* RCS id missing */
+
+ MANDOCERR_PORTABLE, /* ===== style hints for portable ===== */
+
+ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_REP, /* duplicate RCS id: ... */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
@@ -448,7 +451,7 @@ const char *mchars_uc2str(int);
int mchars_num2uc(const char *, size_t);
int mchars_spec2cp(const char *, size_t);
const char *mchars_spec2str(const char *, size_t, size_t *);
-struct mparse *mparse_alloc(int, enum mandoclevel, mandocmsg, const char *);
+struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg, const char *);
void mparse_free(struct mparse *);
void mparse_keep(struct mparse *);
int mparse_open(struct mparse *, const char *);
Index: read.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/read.c,v
retrieving revision 1.150
diff -u -p -r1.150 read.c
--- read.c 17 Jun 2017 23:06:43 -0000 1.150
+++ read.c 21 Jun 2017 15:09:46 -0000
@@ -52,7 +52,7 @@ struct mparse {
const char *defos; /* default operating system */
mandocmsg mmsg; /* warning/error message handler */
enum mandoclevel file_status; /* status of current parse */
- enum mandoclevel wlevel; /* ignore messages below this */
+ enum mandocerr mmin; /* ignore messages below this */
int options; /* parser options */
int gzip; /* current input file is gzipped */
int filenc; /* encoding of the current file */
@@ -82,12 +82,15 @@ static const enum mandocerr mandoclimits
static const char * const mandocerrs[MANDOCERR_MAX] = {
"ok",

- "generic style suggestion",
+ "base system convention",

"Mdocdate found",
"Mdocdate missing",
- "legacy man(7) date format",
"RCS id missing",
+
+ "generic style suggestion",
+
+ "legacy man(7) date format",
"duplicate RCS id",
"useless macro",
"consider using OS macro",
@@ -738,7 +741,7 @@ mparse_open(struct mparse *curp, const c
}

struct mparse *
-mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg,
+mparse_alloc(int options, enum mandocerr mmin, mandocmsg mmsg,
const char *defos)
{
struct mparse *curp;
@@ -746,7 +749,7 @@ mparse_alloc(int options, enum mandoclev
curp = mandoc_calloc(1, sizeof(struct mparse));

curp->options = options;
- curp->wlevel = wlevel;
+ curp->mmin = mmin;
curp->mmsg = mmsg;
curp->defos = defos;

@@ -838,12 +841,12 @@ mandoc_msg(enum mandocerr er, struct mpa
{
enum mandoclevel level;

+ if (er < m->mmin && er != MANDOCERR_FILE)
+ return;
+
level = MANDOCLEVEL_UNSUPP;
while (er < mandoclimits[level])
level--;
-
- if (level < m->wlevel && er != MANDOCERR_FILE)
- return;

if (m->mmsg)
(*m->mmsg)(er, level, m->file, ln, col, msg);
Jason McIntyre
2017-06-21 22:10:55 UTC
Permalink
Post by Ingo Schwarze
Hi Sebastien and Jeremie,
Post by Sebastien Marie
Post by Jeremie Courreges-Anglas
Post by Sebastien Marie
But mandoc -Tlint complains about missing Mdocdate.
$ mandoc -Tlint sysclean.8
mandoc: sysclean.8:17:5: STYLE: Mdocdate missing: Dd June
With another project, I get this warning about Dd, plus a message
about a missing RCS Id.
ah, I don't have this one. But after checking, my man page has a
$OpenBSD$ tag inside it... it should come from the mdoc.template I
used to start writing the file. :)
If I remove it, I have the same STYLE warning.
1. Ignore the two style messages.
below DIAGNOSTICS, a style recommendation is not an error,
and style messages are occasionally false positives.
Both of these messages occur at most once per page.
Of course, having to ignore a message is not fully satisfactory,
and keeping false positives down to a minimum *is* among my
goals, even for style recommendations.
2. Put a dummy .\" $OpenBSD$ line and a manually maintained
.Dd $Mdocdate Month day year$ line into the file even though
your VCS won't expand it.
That is icky, working around an issue in a non-intuitive way
instead of solving the root cause, so i can't really recommend it.
3. Use "mandoc -Ios= -Tlint" for checking pages that are supposed
to be portable.
That is not fully satisfactory because it disables *all* operating
system specific style messages. It is likely that you do want to
follow OpenBSD style in general, just not those parts that apply
to the base system only.
4. Put something like ".Os ratpoison" into the manual page.
I clearly recommend against that. It not only suppers from
the same problem as option 3 of disabling more than intended;
it also results in an inconsistent user experience with the
bottom line of manual pages (admittedly a minor point, though).
5. Use "mandoc -Tlint -Wwarning" for these projects.
I clearly recommend against that. It disables even more than
option 3, namely, all style recommendations, most of which are
just as useful for portable projects as for base system manuals.
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
evening.

i'm not entirely convinced... are there likely to be other style
warnings that apply to our base manuals but not "portable"? if there's a
list of things then maybe it makes sense.

otherwise i wonder if we can;t try and make things clearer (style
warning is not a mistake) and leave things for a bit longer to see
whether STYLE by default is too much.

jmc
Post by Ingo Schwarze
In general, i don't like adding knobs. But when the choice is
between having innocent people harassed with false positives and
between providing a knob for saying which checks you want, in a way
that is actually needed in practice, then i prefer the knob to the
harassment.
OK for the patch below?
Post by Sebastien Marie
According to mandoc man page, -Wwarning will avoid all styles warning.
The list of messages is also in the mandoc(1) manual, with an
explanation of each message.
Yours,
Ingo
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.195
diff -u -p -r1.195 main.c
--- main.c 3 Jun 2017 12:16:19 -0000 1.195
+++ main.c 21 Jun 2017 15:09:46 -0000
@@ -68,8 +68,8 @@ enum outt {
struct curparse {
struct mparse *mp;
- enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
+ enum mandocerr mmin; /* ignore messages below this */
enum outt outtype; /* which output to use */
void *outdata; /* data for output */
struct manoutput *outopts; /* output options */
@@ -159,7 +159,7 @@ main(int argc, char *argv[])
memset(&curp, 0, sizeof(struct curparse));
curp.outtype = OUTT_LOCALE;
- curp.wlevel = MANDOCLEVEL_BADARG;
+ curp.mmin = MANDOCERR_MAX;
curp.outopts = &conf.output;
options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
defos = NULL;
@@ -416,7 +416,7 @@ main(int argc, char *argv[])
moptions(&options, auxpaths);
mchars_alloc();
- curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos);
+ curp.mp = mparse_alloc(options, curp.mmin, mmsg, defos);
/*
* Conditionally start up the lookaside buffer before parsing.
@@ -907,7 +907,7 @@ toptions(struct curparse *curp, char *ar
curp->outtype = OUTT_ASCII;
else if (0 == strcmp(arg, "lint")) {
curp->outtype = OUTT_LINT;
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_STYLE;
} else if (0 == strcmp(arg, "tree"))
curp->outtype = OUTT_TREE;
else if (0 == strcmp(arg, "man"))
@@ -936,16 +936,17 @@ static int
woptions(struct curparse *curp, char *arg)
{
char *v, *o;
- const char *toks[8];
+ const char *toks[9];
toks[0] = "stop";
toks[1] = "all";
toks[2] = "style";
- toks[3] = "warning";
- toks[4] = "error";
- toks[5] = "unsupp";
- toks[6] = "fatal";
- toks[7] = NULL;
+ toks[3] = "portable";
+ toks[4] = "warning";
+ toks[5] = "error";
+ toks[6] = "unsupp";
+ toks[7] = "fatal";
+ toks[8] = NULL;
while (*arg) {
o = arg;
@@ -955,19 +956,22 @@ woptions(struct curparse *curp, char *ar
break;
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_STYLE;
break;
- curp->wlevel = MANDOCLEVEL_WARNING;
+ curp->mmin = MANDOCERR_PORTABLE;
break;
- curp->wlevel = MANDOCLEVEL_ERROR;
+ curp->mmin = MANDOCERR_WARNING;
break;
- curp->wlevel = MANDOCLEVEL_UNSUPP;
+ curp->mmin = MANDOCERR_ERROR;
break;
- curp->wlevel = MANDOCLEVEL_BADARG;
+ curp->mmin = MANDOCERR_UNSUPP;
+ break;
+ curp->mmin = MANDOCERR_MAX;
break;
warnx("-W %s: Bad argument", o);
Index: mandoc.1
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
retrieving revision 1.125
diff -u -p -r1.125 mandoc.1
--- mandoc.1 17 Jun 2017 23:06:43 -0000 1.125
+++ mandoc.1 21 Jun 2017 15:09:46 -0000
@@ -158,7 +158,12 @@ or
.Cm unsupp ;
.Cm all
is an alias for
-.Cm style .
+.Cm style ,
+and
+.Cm portable
+is a variant of
+.Cm style
+hiding style recommendations that only apply to base system manuals.
By default,
.Nm
is silent.
@@ -746,7 +751,7 @@ are hidden unless their level, or a lowe
option or
.Fl T Cm lint
output mode.
-.Ss Style messages
+.Pp
As indicated below, some style checks are only performed if a
specific operating system name occurs in the arguments of the
.Ic \&Os
@@ -756,6 +761,10 @@ command line option, or, if neither are
of the
.Xr uname 3
function.
+.Ss Style messages for base system manuals
+These are not shown if
+.Fl W Cm portable
+is specified.
.Bl -ohang
.It Sy "Mdocdate found"
.Pq mdoc , Nx
@@ -778,6 +787,17 @@ macro does not use CVS
keyword substitution, but using it is conventionally expected in the
.Ox
base system.
+.It Sy "RCS id missing"
+.Pq Ox , Nx
+The manual page lacks the comment line with the RCS identifier
+generated by CVS
+.Ic OpenBSD
+or
+.Ic NetBSD
+keyword substitution as conventionally used in these operating systems.
+.El
+.Ss Style messages for all manual pages
+.Bl -ohang
.It Sy "legacy man(7) date format"
.Pq mdoc
The
@@ -791,14 +811,6 @@ Consider using the conventional
date format
.Dq "Month dd, yyyy"
instead.
-.It Sy "RCS id missing"
-.Pq Ox , Nx
-The manual page lacks the comment line with the RCS identifier
-generated by CVS
-.Ic OpenBSD
-or
-.Ic NetBSD
-keyword substitution as conventionally used in these operating systems.
.It Sy "duplicate RCS id"
A single manual page contains two copies of the RCS identifier for
the same operating system.
Index: mandoc.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v
retrieving revision 1.174
diff -u -p -r1.174 mandoc.h
--- mandoc.h 17 Jun 2017 23:06:43 -0000 1.174
+++ mandoc.h 21 Jun 2017 15:09:46 -0000
@@ -48,8 +48,11 @@ enum mandocerr {
MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
- MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_MISSING, /* RCS id missing */
+
+ MANDOCERR_PORTABLE, /* ===== style hints for portable ===== */
+
+ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_REP, /* duplicate RCS id: ... */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
@@ -448,7 +451,7 @@ const char *mchars_uc2str(int);
int mchars_num2uc(const char *, size_t);
int mchars_spec2cp(const char *, size_t);
const char *mchars_spec2str(const char *, size_t, size_t *);
-struct mparse *mparse_alloc(int, enum mandoclevel, mandocmsg, const char *);
+struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg, const char *);
void mparse_free(struct mparse *);
void mparse_keep(struct mparse *);
int mparse_open(struct mparse *, const char *);
Index: read.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/read.c,v
retrieving revision 1.150
diff -u -p -r1.150 read.c
--- read.c 17 Jun 2017 23:06:43 -0000 1.150
+++ read.c 21 Jun 2017 15:09:46 -0000
@@ -52,7 +52,7 @@ struct mparse {
const char *defos; /* default operating system */
mandocmsg mmsg; /* warning/error message handler */
enum mandoclevel file_status; /* status of current parse */
- enum mandoclevel wlevel; /* ignore messages below this */
+ enum mandocerr mmin; /* ignore messages below this */
int options; /* parser options */
int gzip; /* current input file is gzipped */
int filenc; /* encoding of the current file */
@@ -82,12 +82,15 @@ static const enum mandocerr mandoclimits
static const char * const mandocerrs[MANDOCERR_MAX] = {
"ok",
- "generic style suggestion",
+ "base system convention",
"Mdocdate found",
"Mdocdate missing",
- "legacy man(7) date format",
"RCS id missing",
+
+ "generic style suggestion",
+
+ "legacy man(7) date format",
"duplicate RCS id",
"useless macro",
"consider using OS macro",
@@ -738,7 +741,7 @@ mparse_open(struct mparse *curp, const c
}
struct mparse *
-mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg,
+mparse_alloc(int options, enum mandocerr mmin, mandocmsg mmsg,
const char *defos)
{
struct mparse *curp;
@@ -746,7 +749,7 @@ mparse_alloc(int options, enum mandoclev
curp = mandoc_calloc(1, sizeof(struct mparse));
curp->options = options;
- curp->wlevel = wlevel;
+ curp->mmin = mmin;
curp->mmsg = mmsg;
curp->defos = defos;
@@ -838,12 +841,12 @@ mandoc_msg(enum mandocerr er, struct mpa
{
enum mandoclevel level;
+ if (er < m->mmin && er != MANDOCERR_FILE)
+ return;
+
level = MANDOCLEVEL_UNSUPP;
while (er < mandoclimits[level])
level--;
-
- if (level < m->wlevel && er != MANDOCERR_FILE)
- return;
if (m->mmsg)
(*m->mmsg)(er, level, m->file, ln, col, msg);
Ingo Schwarze
2017-06-21 23:18:05 UTC
Permalink
Hi Jason,
Post by Jason McIntyre
Post by Ingo Schwarze
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
i'm not entirely convinced... are there likely to be other style
warnings that apply to our base manuals but not "portable"?
if there's a list of things then maybe it makes sense.
Quite likely in the future:

- In base, we only want sections 1-9 and 3p.
In third-party software, sections like "n" (for TCL)
or "3f" (for Fortran) may be legitimate.

- In base, we have a fixed list of architectures that we want
to check the third .Dt argument against.
In portable software, architectures that do not exist in OpenBSD
may be legitimate.

- In base, we probably want to warn about standard .Sh sections
that we don't use in OpenBSD (like LIBRARY).
In portable software, a LIBRARY section may be legitimate, if
the software is also targetting systems like FreeBSD, NetBSD,
or Linux where that section is in widespread use (and actually
somewhat useful because they either have such a vast swamp of
libraries in base, or no clear distinction between base and
ports at all).

- In base, we always want to warn in case the .Os macro has any
argument whatsoever.
In portable software, an .Os argument may be deliberate.
Post by Jason McIntyre
otherwise i wonder if we can;t try and make things clearer (style
warning is not a mistake) and leave things for a bit longer to see
whether STYLE by default is too much.
I think we may have a better chance to show that STYLE by default
is not too much if we prevent the above false positives from slowly
piling up in the first place.

Also, i don't quite understand what you mean that could be made
clearer, the mandoc(1) manual is already quite explicit:

style An input file uses dubious or discouraged style. This is not a
complaint about the syntax, and probably neither formatting nor
portability are in danger. While great care is taken to avoid
false positives on the higher message levels, the style level
tries to reduce the probability that issues go unnoticed, so it
may occasionally issue bogus suggestions. Please use your good
judgement to decide whether any particular style suggestion
really justifies a change to the input file.

Yours,
Ingo
Jason McIntyre
2017-06-22 06:31:49 UTC
Permalink
Post by Ingo Schwarze
Hi Jason,
Post by Jason McIntyre
Post by Ingo Schwarze
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
i'm not entirely convinced... are there likely to be other style
warnings that apply to our base manuals but not "portable"?
if there's a list of things then maybe it makes sense.
- In base, we only want sections 1-9 and 3p.
In third-party software, sections like "n" (for TCL)
or "3f" (for Fortran) may be legitimate.
- In base, we have a fixed list of architectures that we want
to check the third .Dt argument against.
In portable software, architectures that do not exist in OpenBSD
may be legitimate.
- In base, we probably want to warn about standard .Sh sections
that we don't use in OpenBSD (like LIBRARY).
In portable software, a LIBRARY section may be legitimate, if
the software is also targetting systems like FreeBSD, NetBSD,
or Linux where that section is in widespread use (and actually
somewhat useful because they either have such a vast swamp of
libraries in base, or no clear distinction between base and
ports at all).
- In base, we always want to warn in case the .Os macro has any
argument whatsoever.
In portable software, an .Os argument may be deliberate.
fair enough then, if you think it's worth doing. but aren't you worried that
you're gonna end up with all operating systems/interested parties wanting
their own flags?

jmc
Ingo Schwarze
2017-06-23 17:24:31 UTC
Permalink
Hi Jason,
Post by Jason McIntyre
Post by Jason McIntyre
i'm not entirely convinced... are there likely to be other style
warnings that apply to our base manuals but not "portable"?
if there's a list of things then maybe it makes sense.
[ ... 4 examples deleted ... ]
fair enough then, if you think it's worth doing.
but aren't you worried that you're gonna end up with all
operating systems/interested parties wanting their own flags?
Not worried, no. I'm not expecting that many, a handful at most,
and even a dozen would be less of a maintenance burden than many
of the switch/case features contained in the mdoc(7) language itself.

- illumos, definitely.
- FreeBSD, maybe. I have no indication yet that they may want
to use the feature, but it would fit their culture.
- Debian, possibly. If there is something that they can tweak,
they usually tweak it. If there is not, they tweak it anyway.
But i guess it will take several years before they find out.
They don't move all that fast, you know.

- Alpine, Void, Arch, Slackware, Crux Linux:
Very unlikely. They tend to refrain from customization, and
from creatung unnecessary maintenance workload for themselves,
whenever they can.

- DragonFly, Minix, MacOS X:
Very unlikely. These projects look like abandonware to me.

No other project is actively using mandoc at this point.
It also runs on IBM AIX and Oracle Solaris, and there are many
unofficial, outdated ports for major Linux distros, but none of
these will request their own -Tlint customizations.

Yours,
Ingo
Jason McIntyre
2017-06-23 19:30:44 UTC
Permalink
Post by Ingo Schwarze
Hi Jason,
Post by Jason McIntyre
Post by Jason McIntyre
i'm not entirely convinced... are there likely to be other style
warnings that apply to our base manuals but not "portable"?
if there's a list of things then maybe it makes sense.
[ ... 4 examples deleted ... ]
fair enough then, if you think it's worth doing.
but aren't you worried that you're gonna end up with all
operating systems/interested parties wanting their own flags?
Not worried, no. I'm not expecting that many, a handful at most,
and even a dozen would be less of a maintenance burden than many
of the switch/case features contained in the mdoc(7) language itself.
- illumos, definitely.
- FreeBSD, maybe. I have no indication yet that they may want
to use the feature, but it would fit their culture.
- Debian, possibly. If there is something that they can tweak,
they usually tweak it. If there is not, they tweak it anyway.
But i guess it will take several years before they find out.
They don't move all that fast, you know.
Very unlikely. They tend to refrain from customization, and
from creatung unnecessary maintenance workload for themselves,
whenever they can.
Very unlikely. These projects look like abandonware to me.
No other project is actively using mandoc at this point.
It also runs on IBM AIX and Oracle Solaris, and there are many
unofficial, outdated ports for major Linux distros, but none of
these will request their own -Tlint customizations.
Yours,
Ingo
evening.

thanks for answering my questions. so i have no objections.

jmc

Jeremie Courreges-Anglas
2017-06-21 23:24:00 UTC
Permalink
Post by Jason McIntyre
Post by Ingo Schwarze
Hi Sebastien and Jeremie,
Post by Sebastien Marie
Post by Jeremie Courreges-Anglas
Post by Sebastien Marie
But mandoc -Tlint complains about missing Mdocdate.
$ mandoc -Tlint sysclean.8
mandoc: sysclean.8:17:5: STYLE: Mdocdate missing: Dd June
With another project, I get this warning about Dd, plus a message
about a missing RCS Id.
ah, I don't have this one. But after checking, my man page has a
$OpenBSD$ tag inside it... it should come from the mdoc.template I
used to start writing the file. :)
If I remove it, I have the same STYLE warning.
1. Ignore the two style messages.
below DIAGNOSTICS, a style recommendation is not an error,
and style messages are occasionally false positives.
Both of these messages occur at most once per page.
Of course, having to ignore a message is not fully satisfactory,
and keeping false positives down to a minimum *is* among my
goals, even for style recommendations.
2. Put a dummy .\" $OpenBSD$ line and a manually maintained
.Dd $Mdocdate Month day year$ line into the file even though
your VCS won't expand it.
That is icky, working around an issue in a non-intuitive way
instead of solving the root cause, so i can't really recommend it.
3. Use "mandoc -Ios= -Tlint" for checking pages that are supposed
to be portable.
That is not fully satisfactory because it disables *all* operating
system specific style messages. It is likely that you do want to
follow OpenBSD style in general, just not those parts that apply
to the base system only.
4. Put something like ".Os ratpoison" into the manual page.
I clearly recommend against that. It not only suppers from
the same problem as option 3 of disabling more than intended;
it also results in an inconsistent user experience with the
bottom line of manual pages (admittedly a minor point, though).
5. Use "mandoc -Tlint -Wwarning" for these projects.
I clearly recommend against that. It disables even more than
option 3, namely, all style recommendations, most of which are
just as useful for portable projects as for base system manuals.
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
Even if I was fine with option 1, I was going to ok Ingo's diff, since
it helps people who use mandoc but don't care about RCS keywords.

However I think Jason may have a point.
Post by Jason McIntyre
evening.
i'm not entirely convinced... are there likely to be other style
warnings that apply to our base manuals but not "portable"? if there's a
list of things then maybe it makes sense.
otherwise i wonder if we can;t try and make things clearer (style
warning is not a mistake)
Well, if a style warning is not a mistake, then should the exit status
be 1?

~/src/ratpoison/doc$ mandoc -Tlint ratpoison.mdoc.1 ; echo $?
mandoc: ratpoison.mdoc.1:25:5: STYLE: Mdocdate missing: Dd May
mandoc: ratpoison.mdoc.1: STYLE: RCS id missing
1
Post by Jason McIntyre
and leave things for a bit longer to see
whether STYLE by default is too much.
But are those actually style warnings, or errors? "STYLE" alone is a bit of
a misnomer, the warnings above talk about cvs because OpenBSD and NetBSD
use certain RCS keywords. Maybe this kind of error should only trigger
when checking OpenBSD/NetBSD manpages, and the error message should
mention "OS" or OPENBSD" (or whatever is needed for people to decide
whether they care). Wouldn't this kind of check be more suitable for
the "manlint" target in bsd.man.mk?

Also, what would be the default behavior for portable mandoc?

Sorry for bringing more questions than answers. :)
Post by Jason McIntyre
jmc
Post by Ingo Schwarze
In general, i don't like adding knobs. But when the choice is
between having innocent people harassed with false positives and
between providing a knob for saying which checks you want, in a way
that is actually needed in practice, then i prefer the knob to the
harassment.
OK for the patch below?
Post by Sebastien Marie
According to mandoc man page, -Wwarning will avoid all styles warning.
The list of messages is also in the mandoc(1) manual, with an
explanation of each message.
Yours,
Ingo
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.195
diff -u -p -r1.195 main.c
--- main.c 3 Jun 2017 12:16:19 -0000 1.195
+++ main.c 21 Jun 2017 15:09:46 -0000
@@ -68,8 +68,8 @@ enum outt {
struct curparse {
struct mparse *mp;
- enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
+ enum mandocerr mmin; /* ignore messages below this */
enum outt outtype; /* which output to use */
void *outdata; /* data for output */
struct manoutput *outopts; /* output options */
@@ -159,7 +159,7 @@ main(int argc, char *argv[])
memset(&curp, 0, sizeof(struct curparse));
curp.outtype = OUTT_LOCALE;
- curp.wlevel = MANDOCLEVEL_BADARG;
+ curp.mmin = MANDOCERR_MAX;
curp.outopts = &conf.output;
options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
defos = NULL;
@@ -416,7 +416,7 @@ main(int argc, char *argv[])
moptions(&options, auxpaths);
mchars_alloc();
- curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos);
+ curp.mp = mparse_alloc(options, curp.mmin, mmsg, defos);
/*
* Conditionally start up the lookaside buffer before parsing.
@@ -907,7 +907,7 @@ toptions(struct curparse *curp, char *ar
curp->outtype = OUTT_ASCII;
else if (0 == strcmp(arg, "lint")) {
curp->outtype = OUTT_LINT;
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_STYLE;
} else if (0 == strcmp(arg, "tree"))
curp->outtype = OUTT_TREE;
else if (0 == strcmp(arg, "man"))
@@ -936,16 +936,17 @@ static int
woptions(struct curparse *curp, char *arg)
{
char *v, *o;
- const char *toks[8];
+ const char *toks[9];
toks[0] = "stop";
toks[1] = "all";
toks[2] = "style";
- toks[3] = "warning";
- toks[4] = "error";
- toks[5] = "unsupp";
- toks[6] = "fatal";
- toks[7] = NULL;
+ toks[3] = "portable";
+ toks[4] = "warning";
+ toks[5] = "error";
+ toks[6] = "unsupp";
+ toks[7] = "fatal";
+ toks[8] = NULL;
while (*arg) {
o = arg;
@@ -955,19 +956,22 @@ woptions(struct curparse *curp, char *ar
break;
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_STYLE;
break;
- curp->wlevel = MANDOCLEVEL_WARNING;
+ curp->mmin = MANDOCERR_PORTABLE;
break;
- curp->wlevel = MANDOCLEVEL_ERROR;
+ curp->mmin = MANDOCERR_WARNING;
break;
- curp->wlevel = MANDOCLEVEL_UNSUPP;
+ curp->mmin = MANDOCERR_ERROR;
break;
- curp->wlevel = MANDOCLEVEL_BADARG;
+ curp->mmin = MANDOCERR_UNSUPP;
+ break;
+ curp->mmin = MANDOCERR_MAX;
break;
warnx("-W %s: Bad argument", o);
Index: mandoc.1
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
retrieving revision 1.125
diff -u -p -r1.125 mandoc.1
--- mandoc.1 17 Jun 2017 23:06:43 -0000 1.125
+++ mandoc.1 21 Jun 2017 15:09:46 -0000
@@ -158,7 +158,12 @@ or
.Cm unsupp ;
.Cm all
is an alias for
-.Cm style .
+.Cm style ,
+and
+.Cm portable
+is a variant of
+.Cm style
+hiding style recommendations that only apply to base system manuals.
By default,
.Nm
is silent.
@@ -746,7 +751,7 @@ are hidden unless their level, or a lowe
option or
.Fl T Cm lint
output mode.
-.Ss Style messages
+.Pp
As indicated below, some style checks are only performed if a
specific operating system name occurs in the arguments of the
.Ic \&Os
@@ -756,6 +761,10 @@ command line option, or, if neither are
of the
.Xr uname 3
function.
+.Ss Style messages for base system manuals
+These are not shown if
+.Fl W Cm portable
+is specified.
.Bl -ohang
.It Sy "Mdocdate found"
.Pq mdoc , Nx
@@ -778,6 +787,17 @@ macro does not use CVS
keyword substitution, but using it is conventionally expected in the
.Ox
base system.
+.It Sy "RCS id missing"
+.Pq Ox , Nx
+The manual page lacks the comment line with the RCS identifier
+generated by CVS
+.Ic OpenBSD
+or
+.Ic NetBSD
+keyword substitution as conventionally used in these operating systems.
+.El
+.Ss Style messages for all manual pages
+.Bl -ohang
.It Sy "legacy man(7) date format"
.Pq mdoc
The
@@ -791,14 +811,6 @@ Consider using the conventional
date format
.Dq "Month dd, yyyy"
instead.
-.It Sy "RCS id missing"
-.Pq Ox , Nx
-The manual page lacks the comment line with the RCS identifier
-generated by CVS
-.Ic OpenBSD
-or
-.Ic NetBSD
-keyword substitution as conventionally used in these operating systems.
.It Sy "duplicate RCS id"
A single manual page contains two copies of the RCS identifier for
the same operating system.
Index: mandoc.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v
retrieving revision 1.174
diff -u -p -r1.174 mandoc.h
--- mandoc.h 17 Jun 2017 23:06:43 -0000 1.174
+++ mandoc.h 21 Jun 2017 15:09:46 -0000
@@ -48,8 +48,11 @@ enum mandocerr {
MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
- MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_MISSING, /* RCS id missing */
+
+ MANDOCERR_PORTABLE, /* ===== style hints for portable ===== */
+
+ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_REP, /* duplicate RCS id: ... */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
@@ -448,7 +451,7 @@ const char *mchars_uc2str(int);
int mchars_num2uc(const char *, size_t);
int mchars_spec2cp(const char *, size_t);
const char *mchars_spec2str(const char *, size_t, size_t *);
-struct mparse *mparse_alloc(int, enum mandoclevel, mandocmsg, const char *);
+struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg, const char *);
void mparse_free(struct mparse *);
void mparse_keep(struct mparse *);
int mparse_open(struct mparse *, const char *);
Index: read.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/read.c,v
retrieving revision 1.150
diff -u -p -r1.150 read.c
--- read.c 17 Jun 2017 23:06:43 -0000 1.150
+++ read.c 21 Jun 2017 15:09:46 -0000
@@ -52,7 +52,7 @@ struct mparse {
const char *defos; /* default operating system */
mandocmsg mmsg; /* warning/error message handler */
enum mandoclevel file_status; /* status of current parse */
- enum mandoclevel wlevel; /* ignore messages below this */
+ enum mandocerr mmin; /* ignore messages below this */
int options; /* parser options */
int gzip; /* current input file is gzipped */
int filenc; /* encoding of the current file */
@@ -82,12 +82,15 @@ static const enum mandocerr mandoclimits
static const char * const mandocerrs[MANDOCERR_MAX] = {
"ok",
- "generic style suggestion",
+ "base system convention",
"Mdocdate found",
"Mdocdate missing",
- "legacy man(7) date format",
"RCS id missing",
+
+ "generic style suggestion",
+
+ "legacy man(7) date format",
"duplicate RCS id",
"useless macro",
"consider using OS macro",
@@ -738,7 +741,7 @@ mparse_open(struct mparse *curp, const c
}
struct mparse *
-mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg,
+mparse_alloc(int options, enum mandocerr mmin, mandocmsg mmsg,
const char *defos)
{
struct mparse *curp;
@@ -746,7 +749,7 @@ mparse_alloc(int options, enum mandoclev
curp = mandoc_calloc(1, sizeof(struct mparse));
curp->options = options;
- curp->wlevel = wlevel;
+ curp->mmin = mmin;
curp->mmsg = mmsg;
curp->defos = defos;
@@ -838,12 +841,12 @@ mandoc_msg(enum mandocerr er, struct mpa
{
enum mandoclevel level;
+ if (er < m->mmin && er != MANDOCERR_FILE)
+ return;
+
level = MANDOCLEVEL_UNSUPP;
while (er < mandoclimits[level])
level--;
-
- if (level < m->wlevel && er != MANDOCERR_FILE)
- return;
if (m->mmsg)
(*m->mmsg)(er, level, m->file, ln, col, msg);
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Ingo Schwarze
2017-06-22 00:16:29 UTC
Permalink
Hi Jeremie,
Post by Jeremie Courreges-Anglas
Well, if a style warning is not a mistake, then should the exit status
be 1?
~/src/ratpoison/doc$ mandoc -Tlint ratpoison.mdoc.1 ; echo $?
mandoc: ratpoison.mdoc.1:25:5: STYLE: Mdocdate missing: Dd May
mandoc: ratpoison.mdoc.1: STYLE: RCS id missing
1
I think so, yes. For mandoc, non-zero exit status means: "You
told me that you care about messages of LEVEL or more, and there
was at least one of these." You said -Tlint, and that implies
-Wall. The numeric value encodes the severity of the message, and
STYLE (1) is the lowest severity.

When you don't care about STYLE messages, you can use -Wwarning,
and then it will exit 0 as you maybe expected.
Post by Jeremie Courreges-Anglas
But are those actually style warnings, or errors? "STYLE" alone is a
bit of a misnomer, the warnings above talk about cvs because OpenBSD
and NetBSD use certain RCS keywords. Maybe this kind of error should
only trigger when checking OpenBSD/NetBSD manpages,
It does as far as that can be detected. These checks are only done
when "OpenBSD" appears in .Os or -Ios= or uname(3).

That detection cannot be perfect because OpenBSD base manuals do
not contain any data explicitly saying that they are OpenBSD pages.
So if we want them to be run on our base system pages by default,
we must use uname(3) and ask people who want to check non-OpenBSD
pages on OpenBSD to use -Wportable or -Ios= or .Os to make their
intent clear.
Post by Jeremie Courreges-Anglas
and the error message should mention "OS" or OPENBSD" (or whatever
is needed for people to decide whether they care).
I could easily include "OpenBSD" or "NetBSD" into these messages,
but i don't see the usefulness and would rather keep them concise.
I'm sure people almost always know for which system they are
checking and don't need to be told. If they really get confused,
they can easily check .Os, -Ios=, and uname(1) to understand
what is going on. Also, the DIAGNOSTICS section in the mandoc(1)
manual already explains which messages are OS-specific and which
systems they apply to.
Post by Jeremie Courreges-Anglas
Wouldn't this kind of check be more suitable for
the "manlint" target in bsd.man.mk?
I don't think so. For one thing, we are trying to reduce the number
of tools needed to properly check manual pages. In the past,
there have been mandoc -Tlint, mdoclint, and the manlint target.
I am working towards full integration of all mdoclint functionality
into mandoc, such that jmc@ (and others) get all the information
from one call and don't have to waste time running multiple tools.
Besides, the manlint target in bsd.man.mk is practically obsolete
nowadays, i haven't used it in years. It was quite handy when we
installed *formatted* manuals many years ago. Today, you can simply
run mandoc -Tlint in /usr/share/man/.
And even if we want to keep the manlint target, all it does is call
mandoc -Tlint. Trying to implement additional checks that are not
in mandoc -Tlint, in particular intelligent semantic ones that
require parsing the manual, directly in the Makefile without running
the mandoc parser, seems like a very bad idea to me, if it is
feasible at all.
Post by Jeremie Courreges-Anglas
Also, what would be the default behavior for portable mandoc?
No difference from base-system OpenBSD or NetBSD mandoc:
Get the operating system from .Os, -Ios=, or uname(3).
If it is OpenBSD, then run the OpenBSD style checks;
if it is NetBSD, run the NetBSD style checks;
if it is anything else, run no OS-specific style checks,
but only the OS-independent style checks.
Post by Jeremie Courreges-Anglas
Sorry for bringing more questions than answers. :)
No problem, they can all be answered!

Yours,
Ingo
Ted Unangst
2017-06-22 00:48:48 UTC
Permalink
Post by Ingo Schwarze
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
I'm not fond of the name portable. To me, this suggests it will check for
things which impede portability, but that's not really what it does. It may
have that effect in some cases, but more as an incidental effect.

Instead, I suggest shifting the names by one. Leave -W style as the portable
option, but introduce -W openbsd which performs the additional checks. Or
better, name it -W system, so as to be useful on netbsd, etc.

I think this matches the actual hierarchy in practice. There's errors and
warnings at the top. Then there's general style warnings. Then below that
there's the local system specific style guidelines. It's a matter of
perspective, but the portable warnings aren't subset of style, rather the
system warnings are a superset of style.
Jeremie Courreges-Anglas
2017-06-22 01:05:41 UTC
Permalink
Post by Ted Unangst
Post by Ingo Schwarze
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
I'm not fond of the name portable. To me, this suggests it will check for
things which impede portability, but that's not really what it does. It may
have that effect in some cases, but more as an incidental effect.
Instead, I suggest shifting the names by one. Leave -W style as the portable
option, but introduce -W openbsd which performs the additional checks. Or
better, name it -W system, so as to be useful on netbsd, etc.
That sounds reasonable too...
Post by Ted Unangst
I think this matches the actual hierarchy in practice. There's errors and
warnings at the top. Then there's general style warnings. Then below that
there's the local system specific style guidelines. It's a matter of
perspective, but the portable warnings aren't subset of style, rather the
system warnings are a superset of style.
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Ingo Schwarze
2017-06-22 01:13:36 UTC
Permalink
Hi Ted,
Post by Ingo Schwarze
As there is no fully satisfactory option, i propose the patch below.
It add the "-W portable" command line option, which is a variant of
"-W style" hiding messages that only apply to base system manuals.
I'm not fond of the name portable. To me, this suggests it will check
for things which impede portability, but that's not really what it does.
True. That might indeed cause misunderstandings.
Instead, I suggest shifting the names by one. Leave -W style as the
portable option, but introduce -W openbsd which performs the additional
checks. Or better, name it -W system, so as to be useful on netbsd, etc.
That's a fine idea! I'll send a revised patch tomorrow.

Actually, i prefer calling the option -W openbsd.

In cases where you have to specify the option, -W openbsd is not
harder to type than -W system, and clearer. It also saves you
the additional work of having to type -Ios=OpenBSD in cases where
that would be needed. And it has the additional benefit of allowing
to explicitly request OpenBSD-specific checks even on manuals that
contain bogus .Os arguments.

In cases where you don't specify -W but only -Tlint, the system
can be picked from .Os, -Ios=, or uname(3) just like it is now.

And developers maintaining portable software can simply use
mandoc -Tlint -Wstyle to check their own manuals. That's a nice
and clear name.
I think this matches the actual hierarchy in practice. There's errors
and warnings at the top. Then there's general style warnings.
Then below that there's the local system specific style guidelines.
It's a matter of perspective, but the portable warnings aren't subset
of style, rather the system warnings are a superset of style.
Makes sense.

Thanks,
Ingo
Ingo Schwarze
2017-06-22 15:16:23 UTC
Permalink
Hi,
Post by Ingo Schwarze
Instead, I suggest shifting the names by one. Leave -W style
as the portable option, but introduce -W openbsd which performs
the additional checks.
That's a fine idea! I'll send a revised patch tomorrow.
So here it is.

It provides

-W openbsd Perform all checks, including those that are only
relevant for OpenBSD base system pages.
-W netbsd Perform all checks, including those that are only
relevant for NetBSD base system pages.
-W base Autodetect the operating system from .Os, -Ios, uname(3)
and perform all checks. This option will rarely need
to be typed manually, but it is important as the default
for -Tlint.
-W all As usual, an alias for the lowest level. Consequently,
it now becomes an alias for -W base.

-W style Perform all checks that make sense for manual pages
in portable software projects.

-W warning unchanged
-W error unchanged
-W unsupp unchanged

Sorry for the minor churn required because one enum must move from
roff.h to the more fundamental mandoc.h such that the main program
can get access to it, and for the minor churn required to keep the
naming consistent.

OK?
Ingo


Index: att.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/att.c,v
retrieving revision 1.11
diff -u -p -r1.11 att.c
--- att.c 6 Oct 2015 18:30:43 -0000 1.11
+++ att.c 22 Jun 2017 14:54:56 -0000
@@ -17,6 +17,7 @@
#include <sys/types.h>
#include <string.h>

+#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "libmdoc.h"
Index: cgi.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/cgi.c,v
retrieving revision 1.93
diff -u -p -r1.93 cgi.c
--- cgi.c 20 Jun 2017 17:24:09 -0000 1.93
+++ cgi.c 22 Jun 2017 14:54:56 -0000
@@ -828,7 +828,7 @@ resp_format(const struct req *req, const

mchars_alloc();
mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1,
- MANDOCLEVEL_BADARG, NULL, req->q.manpath);
+ MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, req->q.manpath);
mparse_readfd(mp, fd, file);
close(fd);

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.195
diff -u -p -r1.195 main.c
--- main.c 3 Jun 2017 12:16:19 -0000 1.195
+++ main.c 22 Jun 2017 14:54:56 -0000
@@ -68,11 +68,13 @@ enum outt {

struct curparse {
struct mparse *mp;
- enum mandoclevel wlevel; /* ignore messages below this */
+ struct manoutput *outopts; /* output options */
+ void *outdata; /* data for output */
+ char *os_s; /* operating system for display */
int wstop; /* stop after a file with a warning */
+ enum mandocerr mmin; /* ignore messages below this */
+ enum mandoc_os os_e; /* check base system conventions */
enum outt outtype; /* which output to use */
- void *outdata; /* data for output */
- struct manoutput *outopts; /* output options */
};


@@ -113,7 +115,7 @@ main(int argc, char *argv[])
struct manpage *res, *resp;
const char *progname, *sec, *thisarg;
char *conf_file, *defpaths, *auxpaths;
- char *defos, *oarg;
+ char *oarg;
unsigned char *uc;
size_t i, sz;
int prio, best_prio;
@@ -159,10 +161,9 @@ main(int argc, char *argv[])

memset(&curp, 0, sizeof(struct curparse));
curp.outtype = OUTT_LOCALE;
- curp.wlevel = MANDOCLEVEL_BADARG;
+ curp.mmin = MANDOCERR_MAX;
curp.outopts = &conf.output;
options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
- defos = NULL;

use_pager = 1;
tag_files = NULL;
@@ -198,11 +199,11 @@ main(int argc, char *argv[])
warnx("-I %s: Bad argument", optarg);
return (int)MANDOCLEVEL_BADARG;
}
- if (defos) {
+ if (curp.os_s != NULL) {
warnx("-I %s: Duplicate argument", optarg);
return (int)MANDOCLEVEL_BADARG;
}
- defos = mandoc_strdup(optarg + 3);
+ curp.os_s = mandoc_strdup(optarg + 3);
break;
case 'K':
if ( ! koptions(&options, optarg))
@@ -416,7 +417,8 @@ main(int argc, char *argv[])
moptions(&options, auxpaths);

mchars_alloc();
- curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos);
+ curp.mp = mparse_alloc(options, curp.mmin, mmsg,
+ curp.os_e, curp.os_s);

/*
* Conditionally start up the lookaside buffer before parsing.
@@ -494,7 +496,7 @@ out:
mansearch_free(res, sz);
}

- free(defos);
+ free(curp.os_s);

/*
* When using a pager, finish writing both temporary files,
@@ -907,7 +909,7 @@ toptions(struct curparse *curp, char *ar
curp->outtype = OUTT_ASCII;
else if (0 == strcmp(arg, "lint")) {
curp->outtype = OUTT_LINT;
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_BASE;
} else if (0 == strcmp(arg, "tree"))
curp->outtype = OUTT_TREE;
else if (0 == strcmp(arg, "man"))
@@ -936,16 +938,19 @@ static int
woptions(struct curparse *curp, char *arg)
{
char *v, *o;
- const char *toks[8];
+ const char *toks[11];

toks[0] = "stop";
toks[1] = "all";
- toks[2] = "style";
- toks[3] = "warning";
- toks[4] = "error";
- toks[5] = "unsupp";
- toks[6] = "fatal";
- toks[7] = NULL;
+ toks[2] = "base";
+ toks[3] = "style";
+ toks[4] = "warning";
+ toks[5] = "error";
+ toks[6] = "unsupp";
+ toks[7] = "fatal";
+ toks[8] = "openbsd";
+ toks[9] = "netbsd";
+ toks[10] = NULL;

while (*arg) {
o = arg;
@@ -955,19 +960,30 @@ woptions(struct curparse *curp, char *ar
break;
case 1:
case 2:
- curp->wlevel = MANDOCLEVEL_STYLE;
+ curp->mmin = MANDOCERR_BASE;
break;
case 3:
- curp->wlevel = MANDOCLEVEL_WARNING;
+ curp->mmin = MANDOCERR_STYLE;
break;
case 4:
- curp->wlevel = MANDOCLEVEL_ERROR;
+ curp->mmin = MANDOCERR_WARNING;
break;
case 5:
- curp->wlevel = MANDOCLEVEL_UNSUPP;
+ curp->mmin = MANDOCERR_ERROR;
break;
case 6:
- curp->wlevel = MANDOCLEVEL_BADARG;
+ curp->mmin = MANDOCERR_UNSUPP;
+ break;
+ case 7:
+ curp->mmin = MANDOCERR_MAX;
+ break;
+ case 8:
+ curp->mmin = MANDOCERR_BASE;
+ curp->os_e = MANDOC_OS_OPENBSD;
+ break;
+ case 9:
+ curp->mmin = MANDOCERR_BASE;
+ curp->os_e = MANDOC_OS_NETBSD;
break;
default:
warnx("-W %s: Bad argument", o);
@@ -989,9 +1005,10 @@ mmsg(enum mandocerr t, enum mandoclevel
if (line)
fprintf(stderr, "%d:%d:", line, col + 1);

- fprintf(stderr, " %s", mparse_strlevel(lvl));
+ fprintf(stderr, " %s",
+ t < MANDOCERR_STYLE ? "BASE" : mparse_strlevel(lvl));

- if (NULL != (mparse_msg = mparse_strerror(t)))
+ if ((mparse_msg = mparse_strerror(t)) != NULL)
fprintf(stderr, ": %s", mparse_msg);

if (msg)
Index: man_html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man_html.c,v
retrieving revision 1.96
diff -u -p -r1.96 man_html.c
--- man_html.c 8 Jun 2017 12:54:40 -0000 1.96
+++ man_html.c 22 Jun 2017 14:54:56 -0000
@@ -24,6 +24,7 @@
#include <string.h>

#include "mandoc_aux.h"
+#include "mandoc.h"
#include "roff.h"
#include "man.h"
#include "out.h"
Index: man_validate.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man_validate.c,v
retrieving revision 1.101
diff -u -p -r1.101 man_validate.c
--- man_validate.c 17 Jun 2017 22:40:27 -0000 1.101
+++ man_validate.c 22 Jun 2017 14:54:57 -0000
@@ -171,7 +171,9 @@ check_root(CHKARGS)

if (man->meta.os_e &&
(man->meta.rcsids & (1 << man->meta.os_e)) == 0)
- mandoc_msg(MANDOCERR_RCS_MISSING, man->parse, 0, 0, NULL);
+ mandoc_msg(MANDOCERR_RCS_MISSING, man->parse, 0, 0,
+ man->meta.os_e == MANDOC_OS_OPENBSD ?
+ "(OpenBSD)" : "(NetBSD)");
}

static void
@@ -338,12 +340,14 @@ post_TH(CHKARGS)

if (n && (n = n->next))
man->meta.os = mandoc_strdup(n->string);
- else if (man->defos != NULL)
- man->meta.os = mandoc_strdup(man->defos);
- man->meta.os_e = man->meta.os == NULL ? MDOC_OS_OTHER :
- strstr(man->meta.os, "OpenBSD") != NULL ? MDOC_OS_OPENBSD :
- strstr(man->meta.os, "NetBSD") != NULL ? MDOC_OS_NETBSD :
- MDOC_OS_OTHER;
+ else if (man->os_s != NULL)
+ man->meta.os = mandoc_strdup(man->os_s);
+ if (man->meta.os_e == MANDOC_OS_OTHER && man->meta.os != NULL) {
+ if (strstr(man->meta.os, "OpenBSD") != NULL)
+ man->meta.os_e = MANDOC_OS_OPENBSD;
+ else if (strstr(man->meta.os, "NetBSD") != NULL)
+ man->meta.os_e = MANDOC_OS_NETBSD;
+ }

/* TITLE MSEC DATE OS ->VOL<- */
/* If missing, use the default VOL name for MSEC. */
Index: mandoc.1
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
retrieving revision 1.125
diff -u -p -r1.125 mandoc.1
--- mandoc.1 17 Jun 2017 23:06:43 -0000 1.125
+++ mandoc.1 22 Jun 2017 14:54:57 -0000
@@ -75,11 +75,6 @@ and for the
.Xr man 7
.Ic \&TH
macro.
-This can also be used to perform style checks according to the
-conventions of one operating system while running on a different
-operating system; see
-.Sx Style messages
-for details.
.It Fl K Ar encoding
Specify the input encoding.
The supported
@@ -151,14 +146,33 @@ to be reported on the standard error out
The
.Ar level
can be
+.Cm base ,
.Cm style ,
.Cm warning ,
.Cm error ,
or
-.Cm unsupp ;
+.Cm unsupp .
+The
+.Cm base
+level automatically derives the operating system from the contents of the
+.Ic \&Os
+macro, from the
+.Fl Ios
+command line option, or from the
+.Xr uname 3
+return value.
+The levels
+.Cm openbsd
+and
+.Cm netbsd
+are variants of
+.Cm base
+that bypass autodetection and request validation of base system
+conventions for a particular operating system.
+The level
.Cm all
is an alias for
-.Cm style .
+.Cm base .
By default,
.Nm
is silent.
@@ -224,7 +238,7 @@ See
.It Fl T Cm lint
Parse only: produce no output.
Implies
-.Fl W Cm style .
+.Fl W Cm all .
.It Fl T Cm locale
Encode output using the current locale.
This is the default.
@@ -596,19 +610,23 @@ option:
.Pp
.Bl -tag -width Ds -compact
.It 0
-No style suggestions, warnings or errors occurred, or those that
-did were ignored because they were lower than the requested
+No base system convention violations, style suggestions, warnings,
+or errors occurred, or those that did were ignored because they
+were lower than the requested
.Ar level .
.It 1
-At least one style suggestion occurred, but no warning or error, and
+At least one base system convention violation or style suggestion
+occurred, but no warning or error, and
+.Fl W Cm base
+or
.Fl W Cm style
was specified.
.It 2
At least one warning occurred, but no error, and
.Fl W Cm warning
-or
-.Fl W Cm style
-was specified.
+or a lower
+.Ar level
+was requested.
.It 3
At least one parsing error occurred,
but no unsupported feature was encountered, and
@@ -636,7 +654,7 @@ to exit at once, possibly in the middle
Note that selecting
.Fl T Cm lint
output mode implies
-.Fl W Cm style .
+.Fl W Cm all .
.Sh EXAMPLES
To page manuals to the terminal:
.Pp
@@ -669,12 +687,19 @@ parser:
Messages displayed by
.Nm
follow this format:
-.Pp
-.D1 Nm Ns : Ar file : Ns Ar line : Ns Ar column : level : message : macro args
+.Bd -ragged -offset indent
+.Nm Ns :
+.Ar file : Ns Ar line : Ns Ar column : level : message : macro args
+.Pq Ar os
+.Ed
.Pp
Line and column numbers start at 1.
Both are omitted for messages referring to an input file as a whole.
Macro names and arguments are omitted where meaningless.
+The
+.Ar os
+operating system specifier is omitted for messages that are relevant
+for all operating systems.
Fatal messages about invalid command line arguments
or operating system errors, for example when memory is exhausted,
may also omit the
@@ -732,9 +757,15 @@ so it may occasionally issue bogus sugge
Please use your good judgement to decide whether any particular
.Cm style
suggestion really justifies a change to the input file.
+.It Cm base
+A convertion used in the base system of a specific operating system
+is not adhered to.
+These are not markup mistakes, and neither the quality of formatting
+nor portability are in danger.
.El
.Pp
Messages of the
+.Cm base ,
.Cm style ,
.Cm warning ,
.Cm error ,
@@ -746,9 +777,15 @@ are hidden unless their level, or a lowe
option or
.Fl T Cm lint
output mode.
-.Ss Style messages
-As indicated below, some style checks are only performed if a
-specific operating system name occurs in the arguments of the
+.Pp
+As indicated below, all
+.Cm base
+and some
+.Cm style
+checks are only performed if a specific operating system name occurs
+in the arguments of the
+.Fl W
+command line option, of the
.Ic \&Os
macro, of the
.Fl Ios
@@ -756,6 +793,7 @@ command line option, or, if neither are
of the
.Xr uname 3
function.
+.Ss Conventions for base system manuals
.Bl -ohang
.It Sy "Mdocdate found"
.Pq mdoc , Nx
@@ -778,6 +816,17 @@ macro does not use CVS
keyword substitution, but using it is conventionally expected in the
.Ox
base system.
+.It Sy "RCS id missing"
+.Pq Ox , Nx
+The manual page lacks the comment line with the RCS identifier
+generated by CVS
+.Ic OpenBSD
+or
+.Ic NetBSD
+keyword substitution as conventionally used in these operating systems.
+.El
+.Ss Style suggestions
+.Bl -ohang
.It Sy "legacy man(7) date format"
.Pq mdoc
The
@@ -791,14 +840,6 @@ Consider using the conventional
date format
.Dq "Month dd, yyyy"
instead.
-.It Sy "RCS id missing"
-.Pq Ox , Nx
-The manual page lacks the comment line with the RCS identifier
-generated by CVS
-.Ic OpenBSD
-or
-.Ic NetBSD
-keyword substitution as conventionally used in these operating systems.
.It Sy "duplicate RCS id"
A single manual page contains two copies of the RCS identifier for
the same operating system.
Index: mandoc.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v
retrieving revision 1.174
diff -u -p -r1.174 mandoc.h
--- mandoc.h 17 Jun 2017 23:06:43 -0000 1.174
+++ mandoc.h 22 Jun 2017 14:54:57 -0000
@@ -44,12 +44,15 @@ enum mandoclevel {
enum mandocerr {
MANDOCERR_OK,

- MANDOCERR_STYLE, /* ===== start of style suggestions ===== */
+ MANDOCERR_BASE, /* ===== start of base system conventions ===== */

MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
- MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_MISSING, /* RCS id missing */
+
+ MANDOCERR_STYLE, /* ===== start of style suggestions ===== */
+
+ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_RCS_REP, /* duplicate RCS id: ... */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
@@ -413,6 +416,12 @@ struct eqn {
#define MPARSE_UTF8 16 /* accept UTF-8 input */
#define MPARSE_LATIN1 32 /* accept ISO-LATIN-1 input */

+enum mandoc_os {
+ MANDOC_OS_OTHER = 0,
+ MANDOC_OS_NETBSD,
+ MANDOC_OS_OPENBSD
+};
+
enum mandoc_esc {
ESCAPE_ERROR = 0, /* bail! unparsable escape */
ESCAPE_IGNORE, /* escape to be ignored */
@@ -448,7 +457,8 @@ const char *mchars_uc2str(int);
int mchars_num2uc(const char *, size_t);
int mchars_spec2cp(const char *, size_t);
const char *mchars_spec2str(const char *, size_t, size_t *);
-struct mparse *mparse_alloc(int, enum mandoclevel, mandocmsg, const char *);
+struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg,
+ enum mandoc_os, const char *);
void mparse_free(struct mparse *);
void mparse_keep(struct mparse *);
int mparse_open(struct mparse *, const char *);
Index: mandocdb.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandocdb.c,v
retrieving revision 1.199
diff -u -p -r1.199 mandocdb.c
--- mandocdb.c 17 May 2017 22:26:52 -0000 1.199
+++ mandocdb.c 22 Jun 2017 14:54:57 -0000
@@ -394,7 +394,8 @@ mandocdb(int argc, char *argv[])

exitcode = (int)MANDOCLEVEL_OK;
mchars_alloc();
- mp = mparse_alloc(mparse_options, MANDOCLEVEL_BADARG, NULL, NULL);
+ mp = mparse_alloc(mparse_options, MANDOCLEVEL_BADARG, NULL,
+ MANDOC_OS_OTHER, NULL);
mandoc_ohash_init(&mpages, 6, offsetof(struct mpage, inodev));
mandoc_ohash_init(&mlinks, 6, offsetof(struct mlink, file));

Index: mdoc_html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_html.c,v
retrieving revision 1.165
diff -u -p -r1.165 mdoc_html.c
--- mdoc_html.c 19 Jun 2017 12:53:50 -0000 1.165
+++ mdoc_html.c 22 Jun 2017 14:54:57 -0000
@@ -25,6 +25,7 @@
#include <unistd.h>

#include "mandoc_aux.h"
+#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "out.h"
Index: mdoc_validate.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_validate.c,v
retrieving revision 1.254
diff -u -p -r1.254 mdoc_validate.c
--- mdoc_validate.c 17 Jun 2017 22:40:27 -0000 1.254
+++ mdoc_validate.c 22 Jun 2017 14:54:57 -0000
@@ -1694,7 +1694,7 @@ post_bl(POST_ARGS)
nchild = nnext;
}

- if (mdoc->meta.os_e != MDOC_OS_NETBSD)
+ if (mdoc->meta.os_e != MANDOC_OS_NETBSD)
return;

prev_Er = NULL;
@@ -1713,11 +1713,12 @@ post_bl(POST_ARGS)
if (order > 0)
mandoc_vmsg(MANDOCERR_ER_ORDER,
mdoc->parse, nnext->line, nnext->pos,
- "Er %s %s", prev_Er, nnext->string);
+ "Er %s %s (NetBSD)",
+ prev_Er, nnext->string);
else if (order == 0)
mandoc_vmsg(MANDOCERR_ER_REP,
mdoc->parse, nnext->line, nnext->pos,
- "Er %s", prev_Er);
+ "Er %s (NetBSD)", prev_Er);
}
prev_Er = nnext->string;
}
@@ -1793,8 +1794,9 @@ post_root(POST_ARGS)
mdoc->meta.os = mandoc_strdup("");
} else if (mdoc->meta.os_e &&
(mdoc->meta.rcsids & (1 << mdoc->meta.os_e)) == 0)
- mandoc_msg(MANDOCERR_RCS_MISSING,
- mdoc->parse, 0, 0, NULL);
+ mandoc_msg(MANDOCERR_RCS_MISSING, mdoc->parse, 0, 0,
+ mdoc->meta.os_e == MANDOC_OS_OPENBSD ?
+ "(OpenBSD)" : "(NetBSD)");

/* Check that we begin with a proper `Sh'. */

@@ -2533,8 +2535,8 @@ post_os(POST_ARGS)
if (mdoc->meta.os)
goto out;

- if (mdoc->defos) {
- mdoc->meta.os = mandoc_strdup(mdoc->defos);
+ if (mdoc->os_s != NULL) {
+ mdoc->meta.os = mandoc_strdup(mdoc->os_s);
goto out;
}

@@ -2553,9 +2555,13 @@ post_os(POST_ARGS)
mdoc->meta.os = mandoc_strdup(defbuf);
#endif /*!OSNAME*/

-out: mdoc->meta.os_e = strstr(mdoc->meta.os, "OpenBSD") != NULL ?
- MDOC_OS_OPENBSD : strstr(mdoc->meta.os, "NetBSD") != NULL ?
- MDOC_OS_NETBSD : MDOC_OS_OTHER;
+out:
+ if (mdoc->meta.os_e == MANDOC_OS_OTHER) {
+ if (strstr(mdoc->meta.os, "OpenBSD") != NULL)
+ mdoc->meta.os_e = MANDOC_OS_OPENBSD;
+ else if (strstr(mdoc->meta.os, "NetBSD") != NULL)
+ mdoc->meta.os_e = MANDOC_OS_NETBSD;
+ }

/*
* This is the earliest point where we can check
@@ -2569,15 +2575,15 @@ out: mdoc->meta.os_e = strstr(mdoc->meta
if ((n = n->child) == NULL)
return;
if (strncmp(n->string, "$" "Mdocdate", 9)) {
- if (mdoc->meta.os_e == MDOC_OS_OPENBSD)
+ if (mdoc->meta.os_e == MANDOC_OS_OPENBSD)
mandoc_vmsg(MANDOCERR_MDOCDATE_MISSING,
mdoc->parse, n->line, n->pos,
- "Dd %s", n->string);
+ "Dd %s (OpenBSD)", n->string);
} else {
- if (mdoc->meta.os_e == MDOC_OS_NETBSD)
+ if (mdoc->meta.os_e == MANDOC_OS_NETBSD)
mandoc_vmsg(MANDOCERR_MDOCDATE,
mdoc->parse, n->line, n->pos,
- "Dd %s", n->string);
+ "Dd %s (NetBSD)", n->string);
}
}

Index: read.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/read.c,v
retrieving revision 1.150
diff -u -p -r1.150 read.c
--- read.c 17 Jun 2017 23:06:43 -0000 1.150
+++ read.c 22 Jun 2017 14:54:57 -0000
@@ -49,10 +49,10 @@ struct mparse {
const char *file; /* filename of current input file */
struct buf *primary; /* buffer currently being parsed */
struct buf *secondary; /* preprocessed copy of input */
- const char *defos; /* default operating system */
+ const char *os_s; /* default operating system */
mandocmsg mmsg; /* warning/error message handler */
enum mandoclevel file_status; /* status of current parse */
- enum mandoclevel wlevel; /* ignore messages below this */
+ enum mandocerr mmin; /* ignore messages below this */
int options; /* parser options */
int gzip; /* current input file is gzipped */
int filenc; /* encoding of the current file */
@@ -82,12 +82,15 @@ static const enum mandocerr mandoclimits
static const char * const mandocerrs[MANDOCERR_MAX] = {
"ok",

- "generic style suggestion",
+ "base system convention",

"Mdocdate found",
"Mdocdate missing",
- "legacy man(7) date format",
"RCS id missing",
+
+ "generic style suggestion",
+
+ "legacy man(7) date format",
"duplicate RCS id",
"useless macro",
"consider using OS macro",
@@ -738,20 +741,20 @@ mparse_open(struct mparse *curp, const c
}

struct mparse *
-mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg,
- const char *defos)
+mparse_alloc(int options, enum mandocerr mmin, mandocmsg mmsg,
+ enum mandoc_os os_e, const char *os_s)
{
struct mparse *curp;

curp = mandoc_calloc(1, sizeof(struct mparse));

curp->options = options;
- curp->wlevel = wlevel;
+ curp->mmin = mmin;
curp->mmsg = mmsg;
- curp->defos = defos;
+ curp->os_s = os_s;

curp->roff = roff_alloc(curp, options);
- curp->man = roff_man_alloc( curp->roff, curp, curp->defos,
+ curp->man = roff_man_alloc(curp->roff, curp, curp->os_s,
curp->options & MPARSE_QUICK ? 1 : 0);
if (curp->options & MPARSE_MDOC) {
curp->man->macroset = MACROSET_MDOC;
@@ -763,6 +766,7 @@ mparse_alloc(int options, enum mandoclev
curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
}
curp->man->first->tok = TOKEN_NONE;
+ curp->man->meta.os_e = os_e;
return curp;
}

@@ -838,12 +842,12 @@ mandoc_msg(enum mandocerr er, struct mpa
{
enum mandoclevel level;

+ if (er < m->mmin && er != MANDOCERR_FILE)
+ return;
+
level = MANDOCLEVEL_UNSUPP;
while (er < mandoclimits[level])
level--;
-
- if (level < m->wlevel && er != MANDOCERR_FILE)
- return;

if (m->mmsg)
(*m->mmsg)(er, level, m->file, ln, col, msg);
Index: roff.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/roff.c,v
retrieving revision 1.187
diff -u -p -r1.187 roff.c
--- roff.c 18 Jun 2017 17:35:40 -0000 1.187
+++ roff.c 22 Jun 2017 14:54:58 -0000
@@ -817,14 +817,14 @@ roff_man_free(struct roff_man *man)

struct roff_man *
roff_man_alloc(struct roff *roff, struct mparse *parse,
- const char *defos, int quick)
+ const char *os_s, int quick)
{
struct roff_man *man;

man = mandoc_calloc(1, sizeof(*man));
man->parse = parse;
man->roff = roff;
- man->defos = defos;
+ man->os_s = os_s;
man->quick = quick;
roff_man_alloc1(man);
roff->man = man;
@@ -1136,7 +1136,7 @@ roff_res(struct roff *r, struct buf *buf
size_t maxl; /* expected length of the escape name */
size_t naml; /* actual length of the escape name */
enum mandoc_esc esc; /* type of the escape sequence */
- enum mdoc_os os_e; /* kind of RCS id seen */
+ enum mandoc_os os_e; /* kind of RCS id seen */
int inaml; /* length returned from mandoc_escape() */
int expand_count; /* to avoid infinite loops */
int npos; /* position in numeric expression */
@@ -1159,10 +1159,10 @@ roff_res(struct roff *r, struct buf *buf
/* Comment found, look for RCS id. */

if ((cp = strstr(stesc, "$" "OpenBSD")) != NULL) {
- os_e = MDOC_OS_OPENBSD;
+ os_e = MANDOC_OS_OPENBSD;
cp += 8;
} else if ((cp = strstr(stesc, "$" "NetBSD")) != NULL) {
- os_e = MDOC_OS_NETBSD;
+ os_e = MANDOC_OS_NETBSD;
cp += 7;
}
if (cp != NULL &&
Index: roff.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/roff.h,v
retrieving revision 1.37
diff -u -p -r1.37 roff.h
--- roff.h 17 Jun 2017 22:40:27 -0000 1.37
+++ roff.h 22 Jun 2017 14:54:58 -0000
@@ -26,12 +26,6 @@ enum roff_macroset {
MACROSET_MAN
};

-enum mdoc_os {
- MDOC_OS_OTHER = 0,
- MDOC_OS_NETBSD,
- MDOC_OS_OPENBSD
-};
-
enum roff_sec {
SEC_NONE = 0,
SEC_NAME,
@@ -534,8 +528,8 @@ struct roff_meta {
char *name; /* Leading manual name. */
char *date; /* Normalized date. */
int hasbody; /* Document is not empty. */
- int rcsids; /* Bits indexed by enum mdoc_os. */
- enum mdoc_os os_e; /* Operating system. */
+ int rcsids; /* Bits indexed by enum mandoc_os. */
+ enum mandoc_os os_e; /* Operating system. */
};

struct roff_man {
@@ -544,7 +538,7 @@ struct roff_man {
struct roff *roff; /* Roff parser state data. */
struct ohash *mdocmac; /* Mdoc macro lookup table. */
struct ohash *manmac; /* Man macro lookup table. */
- const char *defos; /* Default operating system. */
+ const char *os_s; /* Default operating system. */
struct roff_node *first; /* The first node parsed. */
struct roff_node *last; /* The last node parsed. */
struct roff_node *last_es; /* The most recent Es node. */
Index: roff_html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/roff_html.c,v
retrieving revision 1.10
diff -u -p -r1.10 roff_html.c
--- roff_html.c 14 Jun 2017 22:50:37 -0000 1.10
+++ roff_html.c 22 Jun 2017 14:54:58 -0000
@@ -20,6 +20,7 @@
#include <assert.h>
#include <stddef.h>

+#include "mandoc.h"
#include "roff.h"
#include "out.h"
#include "html.h"
Index: roff_term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/roff_term.c,v
retrieving revision 1.13
diff -u -p -r1.13 roff_term.c
--- roff_term.c 14 Jun 2017 22:50:37 -0000 1.13
+++ roff_term.c 22 Jun 2017 14:54:58 -0000
@@ -19,6 +19,7 @@
#include <assert.h>
#include <stddef.h>

+#include "mandoc.h"
#include "roff.h"
#include "out.h"
#include "term.h"
Index: st.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/st.c,v
retrieving revision 1.10
diff -u -p -r1.10 st.c
--- st.c 6 Oct 2015 18:30:44 -0000 1.10
+++ st.c 22 Jun 2017 14:54:58 -0000
@@ -18,6 +18,7 @@

#include <string.h>

+#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "libmdoc.h"
Loading...