source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@
Date: Wed, 31 May 2017 10:31:30 -0500 (EST)	[thread overview]
Message-ID: <6268281310541485421.enqueue@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2017-05-31 15:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=6268281310541485421.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).