source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Split -Wstyle into -Wstyle and the even lower -Wbase, and add
@ 2017-06-24 14:39 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-06-24 14:39 UTC (permalink / raw)
  To: source

Log Message:
-----------
Split -Wstyle into -Wstyle and the even lower -Wbase, and add
-Wopenbsd and -Wnetbsd to check conventions for the base system of
a specific operating system.  Mark operating system specific messages
with "(OpenBSD)" at the end.

Please use just "-Tlint" to check base system manuals (defaulting 
to -Wall, which is now -Wbase), but prefer "-Tlint -Wstyle" for the
manuals of portable software projects you maintain that are not
part of OpenBSD base, to avoid bogus recommendations about base 
system conventions that do not apply.

Issue originally reported by semarie@, solution using 
an idea from tedu@, discussed with jmc@ and jca@.

Modified Files:
--------------
    mandoc:
        att.c
        cgi.c
        demandoc.c
        lib.c
        main.c
        man_html.c
        man_validate.c
        mandoc.1
        mandoc.3
        mandoc.h
        mandoc_headers.3
        mandocd.c
        mandocdb.c
        mdoc_html.c
        mdoc_validate.c
        read.c
        roff.c
        roff.h
        roff_html.c
        roff_term.c
        st.c

Revision Data
-------------
Index: demandoc.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/demandoc.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -Ldemandoc.c -Ldemandoc.c -u -p -r1.28 -r1.29
--- demandoc.c
+++ demandoc.c
@@ -25,10 +25,10 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "mandoc.h"
 #include "roff.h"
 #include "man.h"
 #include "mdoc.h"
-#include "mandoc.h"
 
 static	void	 pline(int, int *, int *, int);
 static	void	 pman(const struct roff_node *, int *, int *, int);
@@ -78,7 +78,8 @@ main(int argc, char *argv[])
 	argv += optind;
 
 	mchars_alloc();
-	mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_BADARG, NULL, NULL);
+	mp = mparse_alloc(MPARSE_SO, MANDOCERR_MAX, NULL,
+	    MANDOC_OS_OTHER, NULL);
 	assert(mp);
 
 	if (argc < 1)
Index: lib.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/lib.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -Llib.c -Llib.c -u -p -r1.13 -r1.14
--- lib.c
+++ lib.c
@@ -20,6 +20,7 @@
 
 #include <string.h>
 
+#include "mandoc.h"
 #include "roff.h"
 #include "mdoc.h"
 #include "libmdoc.h"
Index: roff.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -Lroff.h -Lroff.h -u -p -r1.55 -r1.56
--- roff.h
+++ roff.h
@@ -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: mandoc.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.h,v
retrieving revision 1.232
retrieving revision 1.233
diff -Lmandoc.h -Lmandoc.h -u -p -r1.232 -r1.233
--- mandoc.h
+++ mandoc.h
@@ -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: roff_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_html.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lroff_html.c -Lroff_html.c -u -p -r1.10 -r1.11
--- roff_html.c
+++ roff_html.c
@@ -20,6 +20,7 @@
 #include <assert.h>
 #include <stddef.h>
 
+#include "mandoc.h"
 #include "roff.h"
 #include "out.h"
 #include "html.h"
Index: mandoc.3
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.3,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lmandoc.3 -Lmandoc.3 -u -p -r1.39 -r1.40
--- mandoc.3
+++ mandoc.3
@@ -47,9 +47,10 @@
 .Ft struct mparse *
 .Fo mparse_alloc
 .Fa "int options"
-.Fa "enum mandoclevel wlevel"
+.Fa "enum mandocerr mmin"
 .Fa "mandocmsg mmsg"
-.Fa "char *defos"
+.Fa "enum mandoc_os oe_e"
+.Fa "char *os_s"
 .Fc
 .Ft void
 .Fo (*mandocmsg)
@@ -304,12 +305,15 @@ This is for example useful in
 .Xr makewhatis 8
 .Fl Q
 to quickly build minimal databases.
-.It Ar wlevel
+.It Ar mmin
 Can be set to
-.Dv MANDOCLEVEL_BADARG ,
-.Dv MANDOCLEVEL_ERROR ,
+.Dv MANDOCERR_BASE ,
+.Dv MANDOCERR_STYLE ,
+.Dv MANDOCERR_WARNING ,
+.Dv MANDOCERR_ERROR ,
+.Dv MANDOCERR_UNSUPP ,
 or
-.Dv MANDOCLEVEL_WARNING .
+.Dv MANDOCERR_MAX .
 Messages below the selected level will be suppressed.
 .It Ar mmsg
 A callback function to handle errors and warnings.
@@ -319,10 +323,19 @@ for an example.
 If printing of error messages is not desired,
 .Dv NULL
 may be passed.
-.It Ar defos
+.It Ar os_e
+Operating system to check base system conventions for.
+If
+.Dv MANDOC_OS_OTHER ,
+the system is automatically detected from
+.Ic \&Os ,
+.Fl Ios ,
+or
+.Xr uname 3 .
+.It Ar os_s
 A default string for the
 .Xr mdoc 7
-.Sq \&Os
+.Ic \&Os
 macro, overriding the
 .Dv OSNAME
 preprocessor definition and the results of
@@ -650,10 +663,10 @@ TEXT end
 .Ed
 .Pp
 Here, the formatting of the
-.Sq \&Ao
+.Ic \&Ao
 block extends from TEXT ao to TEXT ac,
 while the formatting of the
-.Sq \&Bo
+.Ic \&Bo
 block extends from TEXT bo to TEXT bc.
 It renders as follows in
 .Fl T Ns Cm ascii
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandocdb.c,v
retrieving revision 1.250
retrieving revision 1.251
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.250 -r1.251
--- mandocdb.c
+++ mandocdb.c
@@ -420,7 +420,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: mandoc.1
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.1,v
retrieving revision 1.201
retrieving revision 1.202
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.201 -r1.202
--- mandoc.1
+++ mandoc.1
@@ -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: roff_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_term.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lroff_term.c -Lroff_term.c -u -p -r1.13 -r1.14
--- roff_term.c
+++ roff_term.c
@@ -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: /home/cvs/mandoc/mandoc/st.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lst.c -Lst.c -u -p -r1.13 -r1.14
--- st.c
+++ st.c
@@ -20,6 +20,7 @@
 
 #include <string.h>
 
+#include "mandoc.h"
 #include "roff.h"
 #include "mdoc.h"
 #include "libmdoc.h"
Index: man_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_html.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -Lman_html.c -Lman_html.c -u -p -r1.143 -r1.144
--- man_html.c
+++ man_html.c
@@ -26,6 +26,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: /home/cvs/mandoc/mandoc/man_validate.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -Lman_validate.c -Lman_validate.c -u -p -r1.130 -r1.131
--- man_validate.c
+++ man_validate.c
@@ -173,7 +173,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
@@ -340,12 +342,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_headers.3
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_headers.3,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lmandoc_headers.3 -Lmandoc_headers.3 -u -p -r1.13 -r1.14
--- mandoc_headers.3
+++ mandoc_headers.3
@@ -87,6 +87,7 @@ Provides
 .Vt enum mandoc_esc ,
 .Vt enum mandocerr ,
 .Vt enum mandoclevel ,
+.Vt enum mandoc_os ,
 .Vt enum tbl_cellt ,
 .Vt enum tbl_datt ,
 .Vt enum tbl_spant ,
@@ -126,7 +127,11 @@ as an opaque type for function prototype
 Requires
 .Qq Pa mandoc_ohash.h
 for
-.Vt struct ohash .
+.Vt struct ohash
+and
+.Qq Pa mandoc.h
+for
+.Vt enum mandoc_os .
 .Pp
 Provides
 .Vt enum mdoc_endbody ,
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.339
retrieving revision 1.340
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.339 -r1.340
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1709,7 +1709,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;
@@ -1728,11 +1728,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;
 	}
@@ -1808,8 +1809,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'. */
 
@@ -2548,8 +2550,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;
 	}
 
@@ -2568,9 +2570,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
@@ -2584,15 +2590,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: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.315
retrieving revision 1.316
diff -Lroff.c -Lroff.c -u -p -r1.315 -r1.316
--- roff.c
+++ roff.c
@@ -819,14 +819,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;
@@ -1138,7 +1138,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 */
@@ -1161,10 +1161,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: read.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/read.c,v
retrieving revision 1.178
retrieving revision 1.179
diff -Lread.c -Lread.c -u -p -r1.178 -r1.179
--- read.c
+++ read.c
@@ -53,10 +53,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 */
@@ -86,12 +86,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",
@@ -755,20 +758,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;
@@ -780,6 +783,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;
 }
 
@@ -855,12 +859,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: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.292
retrieving revision 1.293
diff -Lmain.c -Lmain.c -u -p -r1.292 -r1.293
--- main.c
+++ main.c
@@ -74,11 +74,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 */
 };
 
 
@@ -119,7 +121,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;
@@ -183,10 +185,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;
@@ -222,11 +223,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))
@@ -446,7 +447,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.
@@ -524,7 +526,7 @@ out:
 		mansearch_free(res, sz);
 	}
 
-	free(defos);
+	free(curp.os_s);
 
 	/*
 	 * When using a pager, finish writing both temporary files,
@@ -937,7 +939,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"))
@@ -966,16 +968,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;
@@ -985,19 +990,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);
@@ -1019,9 +1035,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: mandocd.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandocd.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lmandocd.c -Lmandocd.c -u -p -r1.5 -r1.6
--- mandocd.c
+++ mandocd.c
@@ -171,7 +171,7 @@ main(int argc, char *argv[])
 
 	mchars_alloc();
 	parser = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1,
-	    MANDOCLEVEL_BADARG, NULL, defos);
+	    MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, defos);
 
 	memset(&options, 0, sizeof(options));
 	switch (outtype) {
Index: cgi.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/cgi.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -Lcgi.c -Lcgi.c -u -p -r1.155 -r1.156
--- cgi.c
+++ cgi.c
@@ -832,7 +832,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: att.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/att.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -Latt.c -Latt.c -u -p -r1.15 -r1.16
--- att.c
+++ att.c
@@ -19,6 +19,7 @@
 #include <sys/types.h>
 #include <string.h>
 
+#include "mandoc.h"
 #include "roff.h"
 #include "mdoc.h"
 #include "libmdoc.h"
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_html.c,v
retrieving revision 1.290
retrieving revision 1.291
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.290 -r1.291
--- mdoc_html.c
+++ mdoc_html.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 
 #include "mandoc_aux.h"
+#include "mandoc.h"
 #include "roff.h"
 #include "mdoc.h"
 #include "out.h"
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-24 14:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-24 14:39 mandoc: Split -Wstyle into -Wstyle and the even lower -Wbase, and add schwarze

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