version 1.247, 2014/09/07 23:25:01 |
version 1.252, 2014/10/13 14:01:21 |
Line 100 static int post_en(POST_ARGS); |
|
Line 100 static int post_en(POST_ARGS); |
|
static int post_es(POST_ARGS); |
static int post_es(POST_ARGS); |
static int post_eoln(POST_ARGS); |
static int post_eoln(POST_ARGS); |
static int post_ex(POST_ARGS); |
static int post_ex(POST_ARGS); |
|
static int post_fa(POST_ARGS); |
|
static int post_fn(POST_ARGS); |
|
static int post_fname(POST_ARGS); |
static int post_fo(POST_ARGS); |
static int post_fo(POST_ARGS); |
static int post_hyph(POST_ARGS); |
static int post_hyph(POST_ARGS); |
static int post_hyphtext(POST_ARGS); |
static int post_hyphtext(POST_ARGS); |
Line 117 static int post_rs(POST_ARGS); |
|
Line 120 static int post_rs(POST_ARGS); |
|
static int post_sh(POST_ARGS); |
static int post_sh(POST_ARGS); |
static int post_sh_head(POST_ARGS); |
static int post_sh_head(POST_ARGS); |
static int post_sh_name(POST_ARGS); |
static int post_sh_name(POST_ARGS); |
|
static int post_sh_see_also(POST_ARGS); |
static int post_sh_authors(POST_ARGS); |
static int post_sh_authors(POST_ARGS); |
static int post_st(POST_ARGS); |
static int post_st(POST_ARGS); |
static int post_vt(POST_ARGS); |
static int post_vt(POST_ARGS); |
Line 156 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 160 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, NULL }, /* Er */ |
{ NULL, NULL }, /* Er */ |
{ NULL, NULL }, /* Ev */ |
{ NULL, NULL }, /* Ev */ |
{ pre_std, post_ex }, /* Ex */ |
{ pre_std, post_ex }, /* Ex */ |
{ NULL, NULL }, /* Fa */ |
{ NULL, post_fa }, /* Fa */ |
{ NULL, ewarn_ge1 }, /* Fd */ |
{ NULL, ewarn_ge1 }, /* Fd */ |
{ NULL, NULL }, /* Fl */ |
{ NULL, NULL }, /* Fl */ |
{ NULL, NULL }, /* Fn */ |
{ NULL, post_fn }, /* Fn */ |
{ NULL, NULL }, /* Ft */ |
{ NULL, NULL }, /* Ft */ |
{ NULL, NULL }, /* Ic */ |
{ NULL, NULL }, /* Ic */ |
{ NULL, ewarn_eq1 }, /* In */ |
{ NULL, ewarn_eq1 }, /* In */ |
Line 998 post_eoln(POST_ARGS) |
|
Line 1002 post_eoln(POST_ARGS) |
|
} |
} |
|
|
static int |
static int |
|
post_fname(POST_ARGS) |
|
{ |
|
const struct mdoc_node *n; |
|
const char *cp; |
|
size_t pos; |
|
|
|
n = mdoc->last->child; |
|
pos = strcspn(n->string, "()"); |
|
cp = n->string + pos; |
|
if ( ! (cp[0] == '\0' || (cp[0] == '(' && cp[1] == '*'))) |
|
mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse, |
|
n->line, n->pos + pos, n->string); |
|
return(1); |
|
} |
|
|
|
static int |
|
post_fn(POST_ARGS) |
|
{ |
|
|
|
post_fname(mdoc); |
|
post_fa(mdoc); |
|
return(1); |
|
} |
|
|
|
static int |
post_fo(POST_ARGS) |
post_fo(POST_ARGS) |
{ |
{ |
|
|
hwarn_eq1(mdoc); |
hwarn_eq1(mdoc); |
bwarn_ge1(mdoc); |
bwarn_ge1(mdoc); |
|
if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild) |
|
post_fname(mdoc); |
return(1); |
return(1); |
} |
} |
|
|
static int |
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) |
post_vt(POST_ARGS) |
{ |
{ |
const struct mdoc_node *n; |
const struct mdoc_node *n; |
Line 1856 post_sh(POST_ARGS) |
|
Line 1909 post_sh(POST_ARGS) |
|
switch (mdoc->lastsec) { |
switch (mdoc->lastsec) { |
case SEC_NAME: |
case SEC_NAME: |
return(post_sh_name(mdoc)); |
return(post_sh_name(mdoc)); |
|
case SEC_SEE_ALSO: |
|
return(post_sh_see_also(mdoc)); |
case SEC_AUTHORS: |
case SEC_AUTHORS: |
return(post_sh_authors(mdoc)); |
return(post_sh_authors(mdoc)); |
default: |
default: |
Line 1901 post_sh_name(POST_ARGS) |
|
Line 1956 post_sh_name(POST_ARGS) |
|
|
|
mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse, |
mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse, |
n->line, n->pos, mdoc_macronames[n->tok]); |
n->line, n->pos, mdoc_macronames[n->tok]); |
|
return(1); |
|
} |
|
|
|
static int |
|
post_sh_see_also(POST_ARGS) |
|
{ |
|
const struct mdoc_node *n; |
|
const char *name, *sec; |
|
const char *lastname, *lastsec, *lastpunct; |
|
int cmp; |
|
|
|
n = mdoc->last->child; |
|
lastname = lastsec = lastpunct = NULL; |
|
while (n != NULL) { |
|
if (n->tok != MDOC_Xr || n->nchild < 2) |
|
break; |
|
|
|
/* Process one .Xr node. */ |
|
|
|
name = n->child->string; |
|
sec = n->child->next->string; |
|
if (lastsec != NULL) { |
|
if (lastpunct[0] != ',' || lastpunct[1] != '\0') |
|
mandoc_vmsg(MANDOCERR_XR_PUNCT, |
|
mdoc->parse, n->line, n->pos, |
|
"%s before %s(%s)", lastpunct, |
|
name, sec); |
|
cmp = strcmp(lastsec, sec); |
|
if (cmp > 0) |
|
mandoc_vmsg(MANDOCERR_XR_ORDER, |
|
mdoc->parse, n->line, n->pos, |
|
"%s(%s) after %s(%s)", name, |
|
sec, lastname, lastsec); |
|
else if (cmp == 0 && strcmp(lastname, name) > 0) |
|
mandoc_vmsg(MANDOCERR_XR_ORDER, |
|
mdoc->parse, n->line, n->pos, |
|
"%s after %s", name, lastname); |
|
} |
|
lastname = name; |
|
lastsec = sec; |
|
|
|
/* Process the following node. */ |
|
|
|
n = n->next; |
|
if (n == NULL) |
|
break; |
|
if (n->tok == MDOC_Xr) { |
|
lastpunct = "none"; |
|
continue; |
|
} |
|
if (n->type != MDOC_TEXT) |
|
break; |
|
for (name = n->string; *name != '\0'; name++) |
|
if (isalpha((const unsigned char)*name)) |
|
return(1); |
|
lastpunct = n->string; |
|
if (n->next == NULL) |
|
mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse, |
|
n->line, n->pos, "%s after %s(%s)", |
|
lastpunct, lastname, lastsec); |
|
n = n->next; |
|
} |
return(1); |
return(1); |
} |
} |
|
|