version 1.334, 2017/06/10 16:54:16 |
version 1.341, 2017/06/24 15:59:50 |
Line 53 typedef void (*v_post)(POST_ARGS); |
|
Line 53 typedef void (*v_post)(POST_ARGS); |
|
|
|
static int build_list(struct roff_man *, int); |
static int build_list(struct roff_man *, int); |
static void check_text(struct roff_man *, int, int, char *); |
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 *, |
static void check_argv(struct roff_man *, |
struct roff_node *, struct mdoc_argv *); |
struct roff_node *, struct mdoc_argv *); |
static void check_args(struct roff_man *, struct roff_node *); |
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 int child_an(const struct roff_node *); |
static size_t macro2len(enum roff_tok); |
static size_t macro2len(enum roff_tok); |
static void rewrite_macro2len(struct roff_man *, char **); |
static void rewrite_macro2len(struct roff_man *, char **); |
Line 184 static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] |
|
Line 184 static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] |
|
NULL, /* Eo */ |
NULL, /* Eo */ |
post_xx, /* Fx */ |
post_xx, /* Fx */ |
post_delim, /* Ms */ |
post_delim, /* Ms */ |
post_delim, /* No */ |
NULL, /* No */ |
post_ns, /* Ns */ |
post_ns, /* Ns */ |
post_xx, /* Nx */ |
post_xx, /* Nx */ |
post_xx, /* Ox */ |
post_xx, /* Ox */ |
Line 304 mdoc_node_validate(struct roff_man *mdoc) |
|
Line 304 mdoc_node_validate(struct roff_man *mdoc) |
|
if (n->sec != SEC_SYNOPSIS || |
if (n->sec != SEC_SYNOPSIS || |
(n->parent->tok != MDOC_Cd && n->parent->tok != MDOC_Fd)) |
(n->parent->tok != MDOC_Cd && n->parent->tok != MDOC_Fd)) |
check_text(mdoc, n->line, n->pos, n->string); |
check_text(mdoc, n->line, n->pos, n->string); |
if (n->parent->tok == MDOC_Sh || |
if (n->parent->tok == MDOC_It || |
n->parent->tok == MDOC_Ss || |
(n->parent->type == ROFFT_BODY && |
n->parent->tok == MDOC_It) |
(n->parent->tok == MDOC_Sh || |
check_bsd(mdoc, n->line, n->pos, n->string); |
n->parent->tok == MDOC_Ss))) |
|
check_toptext(mdoc, n->line, n->pos, n->string); |
break; |
break; |
case ROFFT_EQN: |
case ROFFT_EQN: |
case ROFFT_TBL: |
case ROFFT_TBL: |
Line 390 check_text(struct roff_man *mdoc, int ln, int pos, cha |
|
Line 391 check_text(struct roff_man *mdoc, int ln, int pos, cha |
|
} |
} |
|
|
static void |
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) |
if ((cp = strstr(p, "OpenBSD")) != NULL) |
mandoc_msg(MANDOCERR_BX, mdoc->parse, |
mandoc_msg(MANDOCERR_BX, mdoc->parse, |
ln, pos + (cp - p), "Ox"); |
ln, pos + (cp - p), "Ox"); |
Line 406 check_bsd(struct roff_man *mdoc, int ln, int pos, char |
|
Line 410 check_bsd(struct roff_man *mdoc, int ln, int pos, char |
|
if ((cp = strstr(p, "DragonFly")) != NULL) |
if ((cp = strstr(p, "DragonFly")) != NULL) |
mandoc_msg(MANDOCERR_BX, mdoc->parse, |
mandoc_msg(MANDOCERR_BX, mdoc->parse, |
ln, pos + (cp - p), "Dx"); |
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 |
static void |
Line 481 post_delim(POST_ARGS) |
|
Line 498 post_delim(POST_ARGS) |
|
|
|
/* At least three alphabetic words with a sentence ending. */ |
/* At least three alphabetic words with a sentence ending. */ |
if (strchr("!.:?", *lc) != NULL && (tok == MDOC_Em || |
if (strchr("!.:?", *lc) != NULL && (tok == MDOC_Em || |
tok == MDOC_Li || tok == MDOC_No || tok == MDOC_Po || |
tok == MDOC_Li || tok == MDOC_Po || tok == MDOC_Pq || |
tok == MDOC_Pq || tok == MDOC_Sy)) { |
tok == MDOC_Sy)) { |
nw = 0; |
nw = 0; |
for (cp = lc - 1; cp >= nch->string; cp--) { |
for (cp = lc - 1; cp >= nch->string; cp--) { |
if (*cp == ' ') { |
if (*cp == ' ') { |
Line 1692 post_bl(POST_ARGS) |
|
Line 1709 post_bl(POST_ARGS) |
|
nchild = nnext; |
nchild = nnext; |
} |
} |
|
|
if (mdoc->meta.os_e != MDOC_OS_NETBSD) |
if (mdoc->meta.os_e != MANDOC_OS_NETBSD) |
return; |
return; |
|
|
prev_Er = NULL; |
prev_Er = NULL; |
Line 1711 post_bl(POST_ARGS) |
|
Line 1728 post_bl(POST_ARGS) |
|
if (order > 0) |
if (order > 0) |
mandoc_vmsg(MANDOCERR_ER_ORDER, |
mandoc_vmsg(MANDOCERR_ER_ORDER, |
mdoc->parse, nnext->line, nnext->pos, |
mdoc->parse, nnext->line, nnext->pos, |
"Er %s %s", prev_Er, nnext->string); |
"Er %s %s (NetBSD)", |
|
prev_Er, nnext->string); |
else if (order == 0) |
else if (order == 0) |
mandoc_vmsg(MANDOCERR_ER_REP, |
mandoc_vmsg(MANDOCERR_ER_REP, |
mdoc->parse, nnext->line, nnext->pos, |
mdoc->parse, nnext->line, nnext->pos, |
"Er %s", prev_Er); |
"Er %s (NetBSD)", prev_Er); |
} |
} |
prev_Er = nnext->string; |
prev_Er = nnext->string; |
} |
} |
Line 1773 post_root(POST_ARGS) |
|
Line 1791 post_root(POST_ARGS) |
|
/* Add missing prologue data. */ |
/* Add missing prologue data. */ |
|
|
if (mdoc->meta.date == NULL) |
if (mdoc->meta.date == NULL) |
mdoc->meta.date = mdoc->quick ? |
mdoc->meta.date = mdoc->quick ? mandoc_strdup("") : |
mandoc_strdup("") : |
mandoc_normdate(mdoc, NULL, 0, 0); |
mandoc_normdate(mdoc->parse, NULL, 0, 0); |
|
|
|
if (mdoc->meta.title == NULL) { |
if (mdoc->meta.title == NULL) { |
mandoc_msg(MANDOCERR_DT_NOTITLE, |
mandoc_msg(MANDOCERR_DT_NOTITLE, |
Line 1790 post_root(POST_ARGS) |
|
Line 1807 post_root(POST_ARGS) |
|
mandoc_msg(MANDOCERR_OS_MISSING, |
mandoc_msg(MANDOCERR_OS_MISSING, |
mdoc->parse, 0, 0, NULL); |
mdoc->parse, 0, 0, NULL); |
mdoc->meta.os = mandoc_strdup(""); |
mdoc->meta.os = mandoc_strdup(""); |
} |
} else if (mdoc->meta.os_e && |
|
(mdoc->meta.rcsids & (1 << mdoc->meta.os_e)) == 0) |
|
mandoc_msg(MANDOCERR_RCS_MISSING, mdoc->parse, 0, 0, |
|
mdoc->meta.os_e == MANDOC_OS_OPENBSD ? |
|
"(OpenBSD)" : "(NetBSD)"); |
|
|
/* Check that we begin with a proper `Sh'. */ |
/* Check that we begin with a proper `Sh'. */ |
|
|
Line 2331 post_dd(POST_ARGS) |
|
Line 2352 post_dd(POST_ARGS) |
|
|
|
if (n->child == NULL || n->child->string[0] == '\0') { |
if (n->child == NULL || n->child->string[0] == '\0') { |
mdoc->meta.date = mdoc->quick ? mandoc_strdup("") : |
mdoc->meta.date = mdoc->quick ? mandoc_strdup("") : |
mandoc_normdate(mdoc->parse, NULL, n->line, n->pos); |
mandoc_normdate(mdoc, NULL, n->line, n->pos); |
return; |
return; |
} |
} |
|
|
Line 2340 post_dd(POST_ARGS) |
|
Line 2361 post_dd(POST_ARGS) |
|
if (mdoc->quick) |
if (mdoc->quick) |
mdoc->meta.date = datestr; |
mdoc->meta.date = datestr; |
else { |
else { |
mdoc->meta.date = mandoc_normdate(mdoc->parse, |
mdoc->meta.date = mandoc_normdate(mdoc, |
datestr, n->line, n->pos); |
datestr, n->line, n->pos); |
free(datestr); |
free(datestr); |
} |
} |
Line 2529 post_os(POST_ARGS) |
|
Line 2550 post_os(POST_ARGS) |
|
if (mdoc->meta.os) |
if (mdoc->meta.os) |
goto out; |
goto out; |
|
|
if (mdoc->defos) { |
if (mdoc->os_s != NULL) { |
mdoc->meta.os = mandoc_strdup(mdoc->defos); |
mdoc->meta.os = mandoc_strdup(mdoc->os_s); |
goto out; |
goto out; |
} |
} |
|
|
Line 2549 post_os(POST_ARGS) |
|
Line 2570 post_os(POST_ARGS) |
|
mdoc->meta.os = mandoc_strdup(defbuf); |
mdoc->meta.os = mandoc_strdup(defbuf); |
#endif /*!OSNAME*/ |
#endif /*!OSNAME*/ |
|
|
out: mdoc->meta.os_e = strstr(mdoc->meta.os, "OpenBSD") != NULL ? |
out: |
MDOC_OS_OPENBSD : strstr(mdoc->meta.os, "NetBSD") != NULL ? |
if (mdoc->meta.os_e == MANDOC_OS_OTHER) { |
MDOC_OS_NETBSD : MDOC_OS_OTHER; |
if (strstr(mdoc->meta.os, "OpenBSD") != NULL) |
|
mdoc->meta.os_e = MANDOC_OS_OPENBSD; |
|
else if (strstr(mdoc->meta.os, "NetBSD") != NULL) |
|
mdoc->meta.os_e = MANDOC_OS_NETBSD; |
|
} |
|
|
|
/* |
|
* This is the earliest point where we can check |
|
* Mdocdate conventions because we don't know |
|
* the operating system earlier. |
|
*/ |
|
|
|
if (n->child != NULL) |
|
mandoc_vmsg(MANDOCERR_OS_ARG, mdoc->parse, |
|
n->child->line, n->child->pos, |
|
"Os %s (%s)", n->child->string, |
|
mdoc->meta.os_e == MANDOC_OS_OPENBSD ? |
|
"OpenBSD" : "NetBSD"); |
|
|
|
while (n->tok != MDOC_Dd) |
|
if ((n = n->prev) == NULL) |
|
return; |
|
if ((n = n->child) == NULL) |
|
return; |
|
if (strncmp(n->string, "$" "Mdocdate", 9)) { |
|
if (mdoc->meta.os_e == MANDOC_OS_OPENBSD) |
|
mandoc_vmsg(MANDOCERR_MDOCDATE_MISSING, |
|
mdoc->parse, n->line, n->pos, |
|
"Dd %s (OpenBSD)", n->string); |
|
} else { |
|
if (mdoc->meta.os_e == MANDOC_OS_NETBSD) |
|
mandoc_vmsg(MANDOCERR_MDOCDATE, |
|
mdoc->parse, n->line, n->pos, |
|
"Dd %s (NetBSD)", n->string); |
|
} |
} |
} |
|
|
enum roff_sec |
enum roff_sec |