summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.19
-rw-r--r--mandoc.h1
-rw-r--r--mdoc_validate.c31
-rw-r--r--read.c1
4 files changed, 35 insertions, 7 deletions
diff --git a/mandoc.1 b/mandoc.1
index a2ca109b..981bce68 100644
--- a/mandoc.1
+++ b/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
diff --git a/mandoc.h b/mandoc.h
index 99f84254..67abe210 100644
--- a/mandoc.h
+++ b/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 ===== */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 51b49697..36c1b6ce 100644
--- a/mdoc_validate.c
+++ b/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, int pos, char *p)
}
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, int pos, char *p)
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
diff --git a/read.c b/read.c
index 609594ae..0db43ef3 100644
--- a/read.c
+++ b/read.c
@@ -94,6 +94,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"duplicate errno",
"description line ends with a full stop",
"no blank before trailing delimiter",
+ "function name without markup",
"generic warning",