version 1.215, 2014/06/20 17:24:00 |
version 1.217, 2014/07/01 22:37:15 |
Line 935 pre_dt(PRE_ARGS) |
|
Line 935 pre_dt(PRE_ARGS) |
|
{ |
{ |
|
|
if (NULL == mdoc->meta.date || mdoc->meta.os) |
if (NULL == mdoc->meta.date || mdoc->meta.os) |
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_ORDER); |
mandoc_msg(MANDOCERR_PROLOG_ORDER, mdoc->parse, |
|
n->line, n->pos, "Dt"); |
|
|
if (mdoc->meta.title) |
if (mdoc->meta.title) |
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_REP); |
mandoc_msg(MANDOCERR_PROLOG_REP, mdoc->parse, |
|
n->line, n->pos, "Dt"); |
|
|
return(1); |
return(1); |
} |
} |
Line 948 pre_os(PRE_ARGS) |
|
Line 950 pre_os(PRE_ARGS) |
|
{ |
{ |
|
|
if (NULL == mdoc->meta.title || NULL == mdoc->meta.date) |
if (NULL == mdoc->meta.title || NULL == mdoc->meta.date) |
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_ORDER); |
mandoc_msg(MANDOCERR_PROLOG_ORDER, mdoc->parse, |
|
n->line, n->pos, "Os"); |
|
|
if (mdoc->meta.os) |
if (mdoc->meta.os) |
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_REP); |
mandoc_msg(MANDOCERR_PROLOG_REP, mdoc->parse, |
|
n->line, n->pos, "Os"); |
|
|
return(1); |
return(1); |
} |
} |
Line 961 pre_dd(PRE_ARGS) |
|
Line 965 pre_dd(PRE_ARGS) |
|
{ |
{ |
|
|
if (mdoc->meta.title || mdoc->meta.os) |
if (mdoc->meta.title || mdoc->meta.os) |
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_ORDER); |
mandoc_msg(MANDOCERR_PROLOG_ORDER, mdoc->parse, |
|
n->line, n->pos, "Dd"); |
|
|
if (mdoc->meta.date) |
if (mdoc->meta.date) |
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOG_REP); |
mandoc_msg(MANDOCERR_PROLOG_REP, mdoc->parse, |
|
n->line, n->pos, "Dd"); |
|
|
return(1); |
return(1); |
} |
} |
Line 1645 ebool(struct mdoc *mdoc) |
|
Line 1651 ebool(struct mdoc *mdoc) |
|
static int |
static int |
post_root(POST_ARGS) |
post_root(POST_ARGS) |
{ |
{ |
int erc; |
int ret; |
struct mdoc_node *n; |
struct mdoc_node *n; |
|
|
erc = 0; |
ret = 1; |
|
|
/* Check that we have a finished prologue. */ |
/* Check that we have a finished prologue. */ |
|
|
if ( ! (MDOC_PBODY & mdoc->flags)) { |
if ( ! (MDOC_PBODY & mdoc->flags)) { |
erc++; |
ret = 0; |
mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG); |
mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG); |
} |
} |
|
|
Line 1662 post_root(POST_ARGS) |
|
Line 1668 post_root(POST_ARGS) |
|
|
|
/* Check that we begin with a proper `Sh'. */ |
/* Check that we begin with a proper `Sh'. */ |
|
|
if (NULL == n->child) { |
if (NULL == n->child) |
erc++; |
mdoc_nmsg(mdoc, n, MANDOCERR_DOC_EMPTY); |
mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY); |
else if (MDOC_Sh != n->child->tok) |
} else if (MDOC_BLOCK != n->child->type || |
mandoc_msg(MANDOCERR_SEC_BEFORE, mdoc->parse, |
MDOC_Sh != n->child->tok) { |
n->child->line, n->child->pos, |
erc++; |
mdoc_macronames[n->child->tok]); |
/* Can this be lifted? See rxdebug.1 for example. */ |
|
mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY); |
|
} |
|
|
|
return(erc ? 0 : 1); |
return(ret); |
} |
} |
|
|
static int |
static int |
Line 1893 post_sh_body(POST_ARGS) |
|
Line 1896 post_sh_body(POST_ARGS) |
|
*/ |
*/ |
|
|
if (NULL == (n = mdoc->last->child)) { |
if (NULL == (n = mdoc->last->child)) { |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADNAMESEC); |
mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse, |
|
mdoc->last->line, mdoc->last->pos, "empty"); |
return(1); |
return(1); |
} |
} |
|
|
Line 1902 post_sh_body(POST_ARGS) |
|
Line 1906 post_sh_body(POST_ARGS) |
|
continue; |
continue; |
if (MDOC_TEXT == n->type) |
if (MDOC_TEXT == n->type) |
continue; |
continue; |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADNAMESEC); |
mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse, |
|
n->line, n->pos, mdoc_macronames[n->tok]); |
} |
} |
|
|
assert(n); |
assert(n); |
if (MDOC_BLOCK == n->type && MDOC_Nd == n->tok) |
if (MDOC_BLOCK == n->type && MDOC_Nd == n->tok) |
return(1); |
return(1); |
|
|
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADNAMESEC); |
mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse, |
|
n->line, n->pos, mdoc_macronames[n->tok]); |
return(1); |
return(1); |
} |
} |
|
|
|
|
post_sh_head(POST_ARGS) |
post_sh_head(POST_ARGS) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
|
const char *goodsec; |
char *secname; |
char *secname; |
enum mdoc_sec sec; |
enum mdoc_sec sec; |
|
|
Line 1935 post_sh_head(POST_ARGS) |
|
Line 1942 post_sh_head(POST_ARGS) |
|
/* The NAME should be first. */ |
/* The NAME should be first. */ |
|
|
if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed) |
if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed) |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NAMESECFIRST); |
mandoc_msg(MANDOCERR_NAMESEC_FIRST, mdoc->parse, |
|
mdoc->last->line, mdoc->last->pos, secname); |
|
|
/* The SYNOPSIS gets special attention in other areas. */ |
/* The SYNOPSIS gets special attention in other areas. */ |
|
|
Line 1978 post_sh_head(POST_ARGS) |
|
Line 1986 post_sh_head(POST_ARGS) |
|
*/ |
*/ |
|
|
if (sec == mdoc->lastnamed) |
if (sec == mdoc->lastnamed) |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SECREP); |
mandoc_msg(MANDOCERR_SEC_REP, mdoc->parse, |
|
mdoc->last->line, mdoc->last->pos, secname); |
|
|
if (sec < mdoc->lastnamed) |
if (sec < mdoc->lastnamed) |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SECOOO); |
mandoc_msg(MANDOCERR_SEC_ORDER, mdoc->parse, |
|
mdoc->last->line, mdoc->last->pos, secname); |
|
|
/* Mark the last named section. */ |
/* Mark the last named section. */ |
|
|
Line 1991 post_sh_head(POST_ARGS) |
|
Line 2001 post_sh_head(POST_ARGS) |
|
|
|
assert(mdoc->meta.msec); |
assert(mdoc->meta.msec); |
|
|
|
goodsec = NULL; |
switch (sec) { |
switch (sec) { |
case SEC_ERRORS: |
case SEC_ERRORS: |
if (*mdoc->meta.msec == '4') |
if (*mdoc->meta.msec == '4') |
break; |
break; |
|
goodsec = "2, 3, 4, 9"; |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case SEC_RETURN_VALUES: |
case SEC_RETURN_VALUES: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
Line 2003 post_sh_head(POST_ARGS) |
|
Line 2015 post_sh_head(POST_ARGS) |
|
break; |
break; |
if (*mdoc->meta.msec == '3') |
if (*mdoc->meta.msec == '3') |
break; |
break; |
|
if (NULL == goodsec) |
|
goodsec = "2, 3, 9"; |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case SEC_CONTEXT: |
case SEC_CONTEXT: |
if (*mdoc->meta.msec == '9') |
if (*mdoc->meta.msec == '9') |
break; |
break; |
mandoc_msg(MANDOCERR_SECMSEC, mdoc->parse, |
if (NULL == goodsec) |
mdoc->last->line, mdoc->last->pos, secname); |
goodsec = "9"; |
|
mandoc_vmsg(MANDOCERR_SEC_MSEC, mdoc->parse, |
|
mdoc->last->line, mdoc->last->pos, |
|
"%s for %s only", secname, goodsec); |
break; |
break; |
default: |
default: |
break; |
break; |
Line 2173 post_dt(POST_ARGS) |
|
Line 2190 post_dt(POST_ARGS) |
|
|
|
mdoc->meta.title = mdoc->meta.vol = mdoc->meta.arch = NULL; |
mdoc->meta.title = mdoc->meta.vol = mdoc->meta.arch = NULL; |
|
|
/* First make all characters uppercase. */ |
/* First check that all characters are uppercase. */ |
|
|
if (NULL != (nn = n->child)) |
if (NULL != (nn = n->child)) |
for (p = nn->string; *p; p++) { |
for (p = nn->string; *p; p++) { |
if (toupper((unsigned char)*p) == *p) |
if (toupper((unsigned char)*p) == *p) |
continue; |
continue; |
|
mandoc_msg(MANDOCERR_TITLE_CASE, |
/* |
mdoc->parse, nn->line, |
* FIXME: don't be lazy: have this make all |
nn->pos + (p - nn->string), |
* characters be uppercase and just warn once. |
nn->string); |
*/ |
|
mdoc_nmsg(mdoc, nn, MANDOCERR_TITLE_CASE); |
|
break; |
break; |
} |
} |
|
|
Line 2228 post_dt(POST_ARGS) |
|
Line 2243 post_dt(POST_ARGS) |
|
mdoc->meta.vol = mandoc_strdup(cp); |
mdoc->meta.vol = mandoc_strdup(cp); |
mdoc->meta.msec = mandoc_strdup(nn->string); |
mdoc->meta.msec = mandoc_strdup(nn->string); |
} else { |
} else { |
mdoc_nmsg(mdoc, n, MANDOCERR_MSEC_BAD); |
mandoc_msg(MANDOCERR_MSEC_BAD, mdoc->parse, |
|
nn->line, nn->pos, nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
mdoc->meta.msec = mandoc_strdup(nn->string); |
mdoc->meta.msec = mandoc_strdup(nn->string); |
} |
} |
Line 2250 post_dt(POST_ARGS) |
|
Line 2266 post_dt(POST_ARGS) |
|
} else { |
} else { |
cp = mdoc_a2arch(nn->string); |
cp = mdoc_a2arch(nn->string); |
if (NULL == cp) { |
if (NULL == cp) { |
mdoc_nmsg(mdoc, nn, MANDOCERR_ARCH_BAD); |
mandoc_msg(MANDOCERR_ARCH_BAD, mdoc->parse, |
|
nn->line, nn->pos, nn->string); |
free(mdoc->meta.vol); |
free(mdoc->meta.vol); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
} else |
} else |