source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: style message about missing .Fn markup; inspired by mdoclint
@ 2017-06-11 17:17 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-06-11 17:17 UTC (permalink / raw)
  To: source

Log Message:
-----------
style message about missing .Fn markup; inspired by mdoclint

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.174
retrieving revision 1.175
diff -Lread.c -Lread.c -u -p -r1.174 -r1.175
--- read.c
+++ read.c
@@ -94,6 +94,7 @@ static	const char * const	mandocerrs[MAN
 	"duplicate errno",
 	"description line ends with a full stop",
 	"no blank before trailing delimiter",
+	"function name without markup",
 
 	"generic warning",
 
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v
retrieving revision 1.197
retrieving revision 1.198
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.197 -r1.198
--- mandoc.1
+++ mandoc.1
@@ -799,10 +799,19 @@ Do not use punctuation at the end of an
 .Ic \&Nd
 block.
 .It Sy "no blank before trailing delimiter"
+.Pq mdoc
 The last argument of a macro that supports trailing delimiter
 arguments is longer than one byte and ends with a trailing delimiter.
 Consider inserting a blank such that the delimiter becomes a separate
 argument, thus moving it out of the scope of the macro.
+.It Sy "function name without markup"
+.Pq mdoc
+A word followed by an empty pair of parentheses occurs on a text line.
+Consider using an
+.Ic \&Fn
+or
+.Ic \&Xr
+macro.
 .El
 .Ss Warnings related to the document prologue
 .Bl -ohang
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.227
retrieving revision 1.228
diff -Lmandoc.h -Lmandoc.h -u -p -r1.227 -r1.228
--- mandoc.h
+++ mandoc.h
@@ -52,6 +52,7 @@ enum	mandocerr {
 	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() */
 
 	MANDOCERR_WARNING, /* ===== start of warnings ===== */
 
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v
retrieving revision 1.335
retrieving revision 1.336
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.335 -r1.336
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -53,10 +53,10 @@ 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 *);
+static	void	 check_toptext(struct roff_man *, int, int, const char *);
 static	int	 child_an(const struct roff_node *);
 static	size_t		macro2len(enum roff_tok);
 static	void	 rewrite_macro2len(struct roff_man *, char **);
@@ -304,10 +304,11 @@ 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);
+		if (n->parent->tok == MDOC_It ||
+		    (n->parent->type == ROFFT_BODY &&
+		     (n->parent->tok == MDOC_Sh ||
+		      n->parent->tok == MDOC_Ss)))
+			check_toptext(mdoc, n->line, n->pos, n->string);
 		break;
 	case ROFFT_EQN:
 	case ROFFT_TBL:
@@ -390,9 +391,12 @@ check_text(struct roff_man *mdoc, int ln
 }
 
 static void
-check_bsd(struct roff_man *mdoc, int ln, int pos, char *p)
+check_toptext(struct roff_man *mdoc, int ln, int pos, const char *p)
 {
-	const char	*cp;
+	const char	*cp, *cpr;
+
+	if (*p == '\0')
+		return;
 
 	if ((cp = strstr(p, "OpenBSD")) != NULL)
 		mandoc_msg(MANDOCERR_BX, mdoc->parse,
@@ -406,6 +410,19 @@ check_bsd(struct roff_man *mdoc, int ln,
 	if ((cp = strstr(p, "DragonFly")) != NULL)
 		mandoc_msg(MANDOCERR_BX, mdoc->parse,
 		    ln, pos + (cp - p), "Dx");
+
+	cp = p;
+	while ((cp = strstr(cp + 1, "()")) != NULL) {
+		for (cpr = cp - 1; cpr >= p; cpr--)
+			if (*cpr != '_' && !isalnum((unsigned char)*cpr))
+				break;
+		if ((cpr < p || *cpr == ' ') && cpr + 1 < cp) {
+			cpr++;
+			mandoc_vmsg(MANDOCERR_FUNC, mdoc->parse,
+			    ln, pos + (cpr - p),
+			    "%.*s()", (int)(cp - cpr), cpr);
+		}
+	}
 }
 
 static void
--
 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-06-11 17:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-11 17:17 mdocml: style message about missing .Fn markup; inspired by mdoclint 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).