source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@
@ 2017-05-31 15:31 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-05-31 15:31 UTC (permalink / raw)
  To: source

Log Message:
-----------
STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@

Modified Files:
--------------
    mdocml:
        mandoc.1
        mandoc.h
        mdoc_validate.c
        read.c

Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -Lread.c -Lread.c -u -p -r1.166 -r1.167
--- read.c
+++ read.c
@@ -89,6 +89,7 @@ static	const char * const	mandocerrs[MAN
 	"generic style suggestion",
 
 	"useless macro",
+	"consider using OS macro",
 
 	"generic warning",
 
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.217
retrieving revision 1.218
diff -Lmandoc.h -Lmandoc.h -u -p -r1.217 -r1.218
--- mandoc.h
+++ mandoc.h
@@ -47,6 +47,7 @@ enum	mandocerr {
 	MANDOCERR_STYLE, /* ===== start of style suggestions ===== */
 
 	MANDOCERR_MACRO_USELESS, /* useless macro: macro */
+	MANDOCERR_BX, /* consider using OS macro: macro */
 
 	MANDOCERR_WARNING, /* ===== start of warnings ===== */
 
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v
retrieving revision 1.328
retrieving revision 1.329
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.328 -r1.329
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -53,6 +53,7 @@ typedef	void	(*v_post)(POST_ARGS);
 
 static	int	 build_list(struct roff_man *, int);
 static	void	 check_text(struct roff_man *, int, int, char *);
+static	void	 check_bsd(struct roff_man *, int, int, char *);
 static	void	 check_argv(struct roff_man *,
 			struct roff_node *, struct mdoc_argv *);
 static	void	 check_args(struct roff_man *, struct roff_node *);
@@ -302,6 +303,10 @@ mdoc_node_validate(struct roff_man *mdoc
 		if (n->sec != SEC_SYNOPSIS ||
 		    (n->parent->tok != MDOC_Cd && n->parent->tok != MDOC_Fd))
 			check_text(mdoc, n->line, n->pos, n->string);
+		if (n->parent->tok == MDOC_Sh ||
+		    n->parent->tok == MDOC_Ss ||
+		    n->parent->tok == MDOC_It)
+			check_bsd(mdoc, n->line, n->pos, n->string);
 		break;
 	case ROFFT_EQN:
 	case ROFFT_TBL:
@@ -384,6 +389,25 @@ check_text(struct roff_man *mdoc, int ln
 }
 
 static void
+check_bsd(struct roff_man *mdoc, int ln, int pos, char *p)
+{
+	const char	*cp;
+
+	if ((cp = strstr(p, "OpenBSD")) != NULL)
+		mandoc_msg(MANDOCERR_BX, mdoc->parse,
+		    ln, pos + (cp - p), "Ox");
+	if ((cp = strstr(p, "NetBSD")) != NULL)
+		mandoc_msg(MANDOCERR_BX, mdoc->parse,
+		    ln, pos + (cp - p), "Nx");
+	if ((cp = strstr(p, "FreeBSD")) != NULL)
+		mandoc_msg(MANDOCERR_BX, mdoc->parse,
+		    ln, pos + (cp - p), "Fx");
+	if ((cp = strstr(p, "DragonFly")) != NULL)
+		mandoc_msg(MANDOCERR_BX, mdoc->parse,
+		    ln, pos + (cp - p), "Dx");
+}
+
+static void
 post_bl_norm(POST_ARGS)
 {
 	struct roff_node *n;
@@ -2276,11 +2300,19 @@ static void
 post_bx(POST_ARGS)
 {
 	struct roff_node	*n, *nch;
+	const char		*macro;
 
 	n = mdoc->last;
 	nch = n->child;
 
 	if (nch != NULL) {
+		macro = !strcmp(nch->string, "Open") ? "Ox" :
+		    !strcmp(nch->string, "Net") ? "Nx" :
+		    !strcmp(nch->string, "Free") ? "Fx" :
+		    !strcmp(nch->string, "DragonFly") ? "Dx" : NULL;
+		if (macro != NULL)
+			mandoc_msg(MANDOCERR_BX, mdoc->parse,
+			    n->line, n->pos, macro);
 		mdoc->last = nch;
 		nch = nch->next;
 		mdoc->next = ROFF_NEXT_SIBLING;
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v
retrieving revision 1.190
retrieving revision 1.191
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.190 -r1.191
--- mandoc.1
+++ mandoc.1
@@ -753,6 +753,16 @@ or
 .Ic \&Ud
 macro was found.
 Simply delete it: it serves no useful purpose.
+.It Sy "consider using OS macro"
+.Pq mdoc
+A string was found in plain text or in a
+.Ic \&Bx
+macro that could be represented using
+.Ic \&Ox ,
+.Ic \&Nx ,
+.Ic \&Fx ,
+or
+.Ic \&Dx .
 .El
 .Ss Warnings related to the document prologue
 .Bl -ohang
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

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

only message in thread, other threads:[~2017-05-31 15:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 15:31 mdocml: STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@ 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).