diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-05-31 15:31:00 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-05-31 15:31:00 +0000 |
commit | 97d9e8867b464b881cf5d4f88296991990492d49 (patch) | |
tree | 8cdae68a9a911fdb7764094619a2a3425e5c06c1 /mdoc_validate.c | |
parent | c7f610a9114ad98bda15eb653ca89a1db958ddd7 (diff) | |
download | mandoc-97d9e8867b464b881cf5d4f88296991990492d49.tar.gz |
STYLE message about missing use of Ox/Nx/Fx/Dx; OK jmc@ wiz@
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index a4b01c97..1a9dce2b 100644 --- a/mdoc_validate.c +++ b/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, int pos, char *p) } 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; |