summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-12 00:54:10 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-12 00:54:10 +0000
commit8275a8e52fbf7fc40a4ad55c8d4ad9efe8f67058 (patch)
treec81a99061a1263dce03ec39c840a76a6e40782dd
parent01e7064c09b621aa81c81b4ce8108312e8e2d7b1 (diff)
downloadmandoc-8275a8e52fbf7fc40a4ad55c8d4ad9efe8f67058.tar.gz
warn about commas in function arguments; inspired by mdoclint(1)
-rw-r--r--mandoc.17
-rw-r--r--mandoc.h1
-rw-r--r--mdoc_validate.c27
-rw-r--r--read.c1
4 files changed, 34 insertions, 2 deletions
diff --git a/mandoc.1 b/mandoc.1
index ebb7df57..04902e35 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1118,6 +1118,13 @@ macro has an invalid argument.
It is used verbatim, with
.Qq "AT&T UNIX "
prefixed to it.
+.It Sy "comma in function argument"
+.Pq mdoc
+An argument of an
+.Ic \&Fa
+or
+.Ic \&Fn
+macro contains a comma; it should probably be split into two arguments.
.It Sy "invalid content in Rs block"
.Pq mdoc
An
diff --git a/mandoc.h b/mandoc.h
index 24a2510a..4f7a193d 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -113,6 +113,7 @@ enum mandocerr {
MANDOCERR_BL_REP, /* skipping duplicate list type: Bl -type */
MANDOCERR_BL_SKIPW, /* skipping -width argument: Bl -type */
MANDOCERR_AT_BAD, /* unknown AT&T UNIX version: At version */
+ MANDOCERR_FA_COMMA, /* comma in function argument: arg */
MANDOCERR_RS_BAD, /* invalid content in Rs block: macro */
MANDOCERR_SM_BAD, /* invalid Boolean argument: macro arg */
MANDOCERR_FT_BAD, /* unknown font, skipping request: ft font */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 23649490..15ee201b 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -100,6 +100,7 @@ static int post_en(POST_ARGS);
static int post_es(POST_ARGS);
static int post_eoln(POST_ARGS);
static int post_ex(POST_ARGS);
+static int post_fa(POST_ARGS);
static int post_fo(POST_ARGS);
static int post_hyph(POST_ARGS);
static int post_hyphtext(POST_ARGS);
@@ -157,10 +158,10 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Er */
{ NULL, NULL }, /* Ev */
{ pre_std, post_ex }, /* Ex */
- { NULL, NULL }, /* Fa */
+ { NULL, post_fa }, /* Fa */
{ NULL, ewarn_ge1 }, /* Fd */
{ NULL, NULL }, /* Fl */
- { NULL, NULL }, /* Fn */
+ { NULL, post_fa }, /* Fn */
{ NULL, NULL }, /* Ft */
{ NULL, NULL }, /* Ic */
{ NULL, ewarn_eq1 }, /* In */
@@ -1008,6 +1009,28 @@ post_fo(POST_ARGS)
}
static int
+post_fa(POST_ARGS)
+{
+ const struct mdoc_node *n;
+ const char *cp;
+
+ for (n = mdoc->last->child; n != NULL; n = n->next) {
+ for (cp = n->string; *cp != '\0'; cp++) {
+ /* Ignore callbacks and alterations. */
+ if (*cp == '(' || *cp == '{')
+ break;
+ if (*cp != ',')
+ continue;
+ mandoc_msg(MANDOCERR_FA_COMMA, mdoc->parse,
+ n->line, n->pos + (cp - n->string),
+ n->string);
+ break;
+ }
+ }
+ return(1);
+}
+
+static int
post_vt(POST_ARGS)
{
const struct mdoc_node *n;
diff --git a/read.c b/read.c
index b19059ed..346bee13 100644
--- a/read.c
+++ b/read.c
@@ -158,6 +158,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"skipping duplicate list type",
"skipping -width argument",
"unknown AT&T UNIX version",
+ "comma in function argument",
"invalid content in Rs block",
"invalid Boolean argument",
"unknown font, skipping request",