version 1.324, 2017/05/05 02:06:19 |
version 1.332, 2017/06/08 00:23:30 |
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 *); |
Line 105 static void post_sh_authors(POST_ARGS); |
|
Line 106 static void post_sh_authors(POST_ARGS); |
|
static void post_sm(POST_ARGS); |
static void post_sm(POST_ARGS); |
static void post_st(POST_ARGS); |
static void post_st(POST_ARGS); |
static void post_std(POST_ARGS); |
static void post_std(POST_ARGS); |
|
static void post_useless(POST_ARGS); |
static void post_xr(POST_ARGS); |
static void post_xr(POST_ARGS); |
static void post_xx(POST_ARGS); |
static void post_xx(POST_ARGS); |
|
|
Line 201 static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] |
|
Line 203 static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] |
|
post_sm, /* Sm */ |
post_sm, /* Sm */ |
post_hyph, /* Sx */ |
post_hyph, /* Sx */ |
NULL, /* Sy */ |
NULL, /* Sy */ |
NULL, /* Tn */ |
post_useless, /* Tn */ |
post_xx, /* Ux */ |
post_xx, /* Ux */ |
NULL, /* Xc */ |
NULL, /* Xc */ |
NULL, /* Xo */ |
NULL, /* Xo */ |
Line 227 static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] |
|
Line 229 static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] |
|
post_en, /* En */ |
post_en, /* En */ |
post_xx, /* Dx */ |
post_xx, /* Dx */ |
NULL, /* %Q */ |
NULL, /* %Q */ |
post_par, /* sp */ |
|
NULL, /* %U */ |
NULL, /* %U */ |
NULL, /* Ta */ |
NULL, /* Ta */ |
NULL, /* ll */ |
|
}; |
}; |
static const v_post *const mdoc_valids = __mdoc_valids - MDOC_Dd; |
static const v_post *const mdoc_valids = __mdoc_valids - MDOC_Dd; |
|
|
Line 303 mdoc_node_validate(struct roff_man *mdoc) |
|
Line 303 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 || |
|
n->parent->tok == MDOC_Ss || |
|
n->parent->tok == MDOC_It) |
|
check_bsd(mdoc, n->line, n->pos, n->string); |
break; |
break; |
case ROFFT_EQN: |
case ROFFT_EQN: |
case ROFFT_TBL: |
case ROFFT_TBL: |
Line 329 mdoc_node_validate(struct roff_man *mdoc) |
|
Line 333 mdoc_node_validate(struct roff_man *mdoc) |
|
if (n->tok < ROFF_MAX) { |
if (n->tok < ROFF_MAX) { |
switch(n->tok) { |
switch(n->tok) { |
case ROFF_br: |
case ROFF_br: |
|
case ROFF_sp: |
post_par(mdoc); |
post_par(mdoc); |
break; |
break; |
default: |
default: |
Line 384 check_text(struct roff_man *mdoc, int ln, int pos, cha |
|
Line 389 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) |
|
{ |
|
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) |
post_bl_norm(POST_ARGS) |
{ |
{ |
struct roff_node *n; |
struct roff_node *n; |
Line 672 post_eoln(POST_ARGS) |
|
Line 696 post_eoln(POST_ARGS) |
|
{ |
{ |
struct roff_node *n; |
struct roff_node *n; |
|
|
|
post_useless(mdoc); |
n = mdoc->last; |
n = mdoc->last; |
if (n->child != NULL) |
if (n->child != NULL) |
mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, n->line, |
mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, n->line, |
Line 769 post_lb(POST_ARGS) |
|
Line 794 post_lb(POST_ARGS) |
|
return; |
return; |
} |
} |
|
|
|
mandoc_vmsg(MANDOCERR_LB_BAD, mdoc->parse, n->child->line, |
|
n->child->pos, "Lb %s", n->child->string); |
|
|
roff_word_alloc(mdoc, n->line, n->pos, "library"); |
roff_word_alloc(mdoc, n->line, n->pos, "library"); |
mdoc->last->flags = NODE_NOSRC; |
mdoc->last->flags = NODE_NOSRC; |
roff_word_alloc(mdoc, n->line, n->pos, "\\(Lq"); |
roff_word_alloc(mdoc, n->line, n->pos, "\\(Lq"); |
Line 867 post_obsolete(POST_ARGS) |
|
Line 895 post_obsolete(POST_ARGS) |
|
n->line, n->pos, roff_name[n->tok]); |
n->line, n->pos, roff_name[n->tok]); |
} |
} |
|
|
|
static void |
|
post_useless(POST_ARGS) |
|
{ |
|
struct roff_node *n; |
|
|
|
n = mdoc->last; |
|
mandoc_msg(MANDOCERR_MACRO_USELESS, mdoc->parse, |
|
n->line, n->pos, roff_name[n->tok]); |
|
} |
|
|
/* |
/* |
* Block macros. |
* Block macros. |
*/ |
*/ |
|
|
post_nd(POST_ARGS) |
post_nd(POST_ARGS) |
{ |
{ |
struct roff_node *n; |
struct roff_node *n; |
|
size_t sz; |
|
|
n = mdoc->last; |
n = mdoc->last; |
|
|
Line 1054 post_nd(POST_ARGS) |
|
Line 1093 post_nd(POST_ARGS) |
|
if (n->child == NULL) |
if (n->child == NULL) |
mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse, |
mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse, |
n->line, n->pos, "Nd"); |
n->line, n->pos, "Nd"); |
|
else if (n->last->type == ROFFT_TEXT && |
|
(sz = strlen(n->last->string)) != 0 && |
|
n->last->string[sz - 1] == '.') |
|
mandoc_msg(MANDOCERR_ND_DOT, mdoc->parse, |
|
n->last->line, n->last->pos + sz - 1, NULL); |
|
|
post_hyph(mdoc); |
post_hyph(mdoc); |
} |
} |
Line 1438 post_bl(POST_ARGS) |
|
Line 1482 post_bl(POST_ARGS) |
|
struct roff_node *nparent, *nprev; /* of the Bl block */ |
struct roff_node *nparent, *nprev; /* of the Bl block */ |
struct roff_node *nblock, *nbody; /* of the Bl */ |
struct roff_node *nblock, *nbody; /* of the Bl */ |
struct roff_node *nchild, *nnext; /* of the Bl body */ |
struct roff_node *nchild, *nnext; /* of the Bl body */ |
|
const char *prev_Er; |
|
int order; |
|
|
nbody = mdoc->last; |
nbody = mdoc->last; |
switch (nbody->type) { |
switch (nbody->type) { |
Line 1538 post_bl(POST_ARGS) |
|
Line 1584 post_bl(POST_ARGS) |
|
|
|
nchild = nnext; |
nchild = nnext; |
} |
} |
|
|
|
if (mdoc->meta.os_e != MDOC_OS_NETBSD) |
|
return; |
|
|
|
prev_Er = NULL; |
|
for (nchild = nbody->child; nchild != NULL; nchild = nchild->next) { |
|
if (nchild->tok != MDOC_It) |
|
continue; |
|
if ((nnext = nchild->head->child) == NULL) |
|
continue; |
|
if (nnext->type == ROFFT_BLOCK) |
|
nnext = nnext->body->child; |
|
if (nnext == NULL || nnext->tok != MDOC_Er) |
|
continue; |
|
nnext = nnext->child; |
|
if (prev_Er != NULL) { |
|
order = strcmp(prev_Er, nnext->string); |
|
if (order > 0) |
|
mandoc_vmsg(MANDOCERR_ER_ORDER, |
|
mdoc->parse, nnext->line, nnext->pos, |
|
"Er %s %s", prev_Er, nnext->string); |
|
else if (order == 0) |
|
mandoc_vmsg(MANDOCERR_ER_REP, |
|
mdoc->parse, nnext->line, nnext->pos, |
|
"Er %s", prev_Er); |
|
} |
|
prev_Er = nnext->string; |
|
} |
} |
} |
|
|
static void |
static void |
Line 1880 post_sh_see_also(POST_ARGS) |
|
Line 1954 post_sh_see_also(POST_ARGS) |
|
if (isalpha((const unsigned char)*name)) |
if (isalpha((const unsigned char)*name)) |
return; |
return; |
lastpunct = n->string; |
lastpunct = n->string; |
if (n->next == NULL) |
if (n->next == NULL || n->next->tok == MDOC_Rs) |
mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse, |
mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse, |
n->line, n->pos, "%s after %s(%s)", |
n->line, n->pos, "%s after %s(%s)", |
lastpunct, lastname, lastsec); |
lastpunct, lastname, lastsec); |
Line 2097 post_par(POST_ARGS) |
|
Line 2171 post_par(POST_ARGS) |
|
struct roff_node *np; |
struct roff_node *np; |
|
|
np = mdoc->last; |
np = mdoc->last; |
if (np->tok != ROFF_br && np->tok != MDOC_sp) |
if (np->tok != ROFF_br && np->tok != ROFF_sp) |
post_prevpar(mdoc); |
post_prevpar(mdoc); |
|
|
if (np->tok == MDOC_sp) { |
if (np->tok == ROFF_sp) { |
if (np->child != NULL && np->child->next != NULL) |
if (np->child != NULL && np->child->next != NULL) |
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
np->child->next->line, np->child->next->pos, |
np->child->next->line, np->child->next->pos, |
Line 2116 post_par(POST_ARGS) |
|
Line 2190 post_par(POST_ARGS) |
|
return; |
return; |
} else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp && |
} else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp && |
(mdoc->last->tok != ROFF_br || |
(mdoc->last->tok != ROFF_br || |
(np->tok != MDOC_sp && np->tok != ROFF_br))) |
(np->tok != ROFF_sp && np->tok != ROFF_br))) |
return; |
return; |
|
|
mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, |
mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, |
|
|
post_bx(POST_ARGS) |
post_bx(POST_ARGS) |
{ |
{ |
struct roff_node *n, *nch; |
struct roff_node *n, *nch; |
|
const char *macro; |
|
|
n = mdoc->last; |
n = mdoc->last; |
nch = n->child; |
nch = n->child; |
|
|
if (nch != NULL) { |
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; |
mdoc->last = nch; |
nch = nch->next; |
nch = nch->next; |
mdoc->next = ROFF_NEXT_SIBLING; |
mdoc->next = ROFF_NEXT_SIBLING; |
Line 2336 post_os(POST_ARGS) |
|
Line 2418 post_os(POST_ARGS) |
|
mdoc->meta.os = NULL; |
mdoc->meta.os = NULL; |
deroff(&mdoc->meta.os, n); |
deroff(&mdoc->meta.os, n); |
if (mdoc->meta.os) |
if (mdoc->meta.os) |
return; |
goto out; |
|
|
if (mdoc->defos) { |
if (mdoc->defos) { |
mdoc->meta.os = mandoc_strdup(mdoc->defos); |
mdoc->meta.os = mandoc_strdup(mdoc->defos); |
return; |
goto out; |
} |
} |
|
|
#ifdef OSNAME |
#ifdef OSNAME |
Line 2357 post_os(POST_ARGS) |
|
Line 2439 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 ? |
|
MDOC_OS_OPENBSD : strstr(mdoc->meta.os, "NetBSD") != NULL ? |
|
MDOC_OS_NETBSD : MDOC_OS_OTHER; |
} |
} |
|
|
enum roff_sec |
enum roff_sec |