version 1.275, 2015/02/06 07:13:14 |
version 1.281, 2015/02/17 20:37:17 |
Line 298 mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n) |
|
Line 298 mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n) |
|
|
|
switch (n->type) { |
switch (n->type) { |
case MDOC_TEXT: |
case MDOC_TEXT: |
check_text(mdoc, n->line, n->pos, n->string); |
if (n->sec != SEC_SYNOPSIS || n->parent->tok != MDOC_Fd) |
|
check_text(mdoc, n->line, n->pos, n->string); |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MDOC_TBL: |
case MDOC_TBL: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
Line 325 mdoc_valid_post(struct mdoc *mdoc) |
|
Line 326 mdoc_valid_post(struct mdoc *mdoc) |
|
n = mdoc->last; |
n = mdoc->last; |
if (n->flags & MDOC_VALID) |
if (n->flags & MDOC_VALID) |
return; |
return; |
n->flags |= MDOC_VALID; |
n->flags |= MDOC_VALID | MDOC_ENDED; |
|
|
switch (n->type) { |
switch (n->type) { |
case MDOC_TEXT: |
case MDOC_TEXT: |
Line 416 pre_display(PRE_ARGS) |
|
Line 417 pre_display(PRE_ARGS) |
|
static void |
static void |
pre_bl(PRE_ARGS) |
pre_bl(PRE_ARGS) |
{ |
{ |
struct mdoc_node *np; |
|
struct mdoc_argv *argv, *wa; |
struct mdoc_argv *argv, *wa; |
int i; |
int i; |
enum mdocargt mdoclt; |
enum mdocargt mdoclt; |
enum mdoc_list lt; |
enum mdoc_list lt; |
|
|
if (MDOC_BLOCK != n->type) { |
if (n->type != MDOC_BLOCK) |
if (ENDBODY_NOT != n->end) { |
|
assert(n->pending); |
|
np = n->pending->parent; |
|
} else |
|
np = n->parent; |
|
|
|
assert(np); |
|
assert(MDOC_BLOCK == np->type); |
|
assert(MDOC_Bl == np->tok); |
|
return; |
return; |
} |
|
|
|
/* |
/* |
* First figure out which kind of list to use: bind ourselves to |
* First figure out which kind of list to use: bind ourselves to |
Line 609 pre_bl(PRE_ARGS) |
|
Line 599 pre_bl(PRE_ARGS) |
|
static void |
static void |
pre_bd(PRE_ARGS) |
pre_bd(PRE_ARGS) |
{ |
{ |
struct mdoc_node *np; |
|
struct mdoc_argv *argv; |
struct mdoc_argv *argv; |
int i; |
int i; |
enum mdoc_disp dt; |
enum mdoc_disp dt; |
|
|
pre_literal(mdoc, n); |
pre_literal(mdoc, n); |
|
|
if (MDOC_BLOCK != n->type) { |
if (n->type != MDOC_BLOCK) |
if (ENDBODY_NOT != n->end) { |
|
assert(n->pending); |
|
np = n->pending->parent; |
|
} else |
|
np = n->parent; |
|
|
|
assert(np); |
|
assert(MDOC_BLOCK == np->type); |
|
assert(MDOC_Bd == np->tok); |
|
return; |
return; |
} |
|
|
|
for (i = 0; n->args && i < (int)n->args->argc; i++) { |
for (i = 0; n->args && i < (int)n->args->argc; i++) { |
argv = n->args->argv + i; |
argv = n->args->argv + i; |
Line 797 post_bf(POST_ARGS) |
|
Line 776 post_bf(POST_ARGS) |
|
* element, which contains the goods. |
* element, which contains the goods. |
*/ |
*/ |
|
|
if (MDOC_HEAD != mdoc->last->type) { |
np = mdoc->last; |
if (ENDBODY_NOT != mdoc->last->end) { |
if (MDOC_HEAD != np->type) |
assert(mdoc->last->pending); |
|
np = mdoc->last->pending->parent->head; |
|
} else if (MDOC_BLOCK != mdoc->last->type) { |
|
np = mdoc->last->parent->head; |
|
} else |
|
np = mdoc->last->head; |
|
|
|
assert(np); |
|
assert(MDOC_HEAD == np->type); |
|
assert(MDOC_Bf == np->tok); |
|
return; |
return; |
} |
|
|
|
np = mdoc->last; |
|
assert(MDOC_BLOCK == np->parent->type); |
assert(MDOC_BLOCK == np->parent->type); |
assert(MDOC_Bf == np->parent->tok); |
assert(MDOC_Bf == np->parent->tok); |
|
|
Line 872 post_lb(POST_ARGS) |
|
Line 839 post_lb(POST_ARGS) |
|
|
|
if (NULL == (stdlibname = mdoc_a2lib(n->string))) |
if (NULL == (stdlibname = mdoc_a2lib(n->string))) |
mandoc_asprintf(&libname, |
mandoc_asprintf(&libname, |
"library \\(lq%s\\(rq", n->string); |
"library \\(Lq%s\\(Rq", n->string); |
else |
else |
libname = mandoc_strdup(stdlibname); |
libname = mandoc_strdup(stdlibname); |
|
|
Line 1221 post_it(POST_ARGS) |
|
Line 1188 post_it(POST_ARGS) |
|
i++; |
i++; |
|
|
if (i < cols || i > cols + 1) |
if (i < cols || i > cols + 1) |
mandoc_vmsg(MANDOCERR_ARGCOUNT, |
mandoc_vmsg(MANDOCERR_BL_COL, |
mdoc->parse, nit->line, nit->pos, |
mdoc->parse, nit->line, nit->pos, |
"columns == %d (have %d)", cols, i); |
"%d columns, %d cells", cols, i); |
break; |
break; |
default: |
default: |
abort(); |
abort(); |
|
|
post_sh_see_also(POST_ARGS) |
post_sh_see_also(POST_ARGS) |
{ |
{ |
const struct mdoc_node *n; |
const struct mdoc_node *n; |
const char *name, *sec; |
const char *name, *sec; |
const char *lastname, *lastsec, *lastpunct; |
const char *lastname, *lastsec, *lastpunct; |
int cmp; |
int cmp; |
|
|
Line 2189 post_dt(POST_ARGS) |
|
Line 2156 post_dt(POST_ARGS) |
|
mdoc->meta.vol = NULL; |
mdoc->meta.vol = NULL; |
mdoc->meta.arch = NULL; |
mdoc->meta.arch = NULL; |
|
|
/* First check that all characters are uppercase. */ |
/* Mandatory first argument: title. */ |
|
|
if (NULL != (nn = n->child)) |
nn = n->child; |
for (p = nn->string; *p; p++) { |
if (nn == NULL || *nn->string == '\0') { |
if (toupper((unsigned char)*p) == *p) |
|
continue; |
|
mandoc_vmsg(MANDOCERR_TITLE_CASE, |
|
mdoc->parse, nn->line, |
|
nn->pos + (p - nn->string), |
|
"Dt %s", nn->string); |
|
break; |
|
} |
|
|
|
/* No argument: msec and arch remain NULL. */ |
|
|
|
if (NULL == (nn = n->child)) { |
|
mandoc_msg(MANDOCERR_DT_NOTITLE, |
mandoc_msg(MANDOCERR_DT_NOTITLE, |
mdoc->parse, n->line, n->pos, "Dt"); |
mdoc->parse, n->line, n->pos, "Dt"); |
mdoc->meta.title = mandoc_strdup("UNTITLED"); |
mdoc->meta.title = mandoc_strdup("UNTITLED"); |
mdoc->meta.vol = mandoc_strdup("LOCAL"); |
} else { |
goto out; |
mdoc->meta.title = mandoc_strdup(nn->string); |
|
|
|
/* Check that all characters are uppercase. */ |
|
|
|
for (p = nn->string; *p != '\0'; p++) |
|
if (islower((unsigned char)*p)) { |
|
mandoc_vmsg(MANDOCERR_TITLE_CASE, |
|
mdoc->parse, nn->line, |
|
nn->pos + (p - nn->string), |
|
"Dt %s", nn->string); |
|
break; |
|
} |
} |
} |
|
|
/* One argument: msec and arch remain NULL. */ |
/* Mandatory second argument: section. */ |
|
|
mdoc->meta.title = mandoc_strdup( |
if (nn != NULL) |
'\0' == nn->string[0] ? "UNTITLED" : nn->string); |
nn = nn->next; |
|
|
if (NULL == (nn = nn->next)) { |
if (nn == NULL) { |
mandoc_vmsg(MANDOCERR_MSEC_MISSING, |
mandoc_vmsg(MANDOCERR_MSEC_MISSING, |
mdoc->parse, n->line, n->pos, |
mdoc->parse, n->line, n->pos, |
"Dt %s", mdoc->meta.title); |
"Dt %s", mdoc->meta.title); |
mdoc->meta.vol = mandoc_strdup("LOCAL"); |
mdoc->meta.vol = mandoc_strdup("LOCAL"); |
goto out; |
goto out; /* msec and arch remain NULL. */ |
} |
} |
|
|
/* Handles: `.Dt TITLE SEC' |
mdoc->meta.msec = mandoc_strdup(nn->string); |
* title = TITLE, |
|
* volume = SEC is msec ? format(msec) : SEC, |
|
* msec = SEC is msec ? atoi(msec) : 0, |
|
* arch = NULL |
|
*/ |
|
|
|
|
/* Infer volume title from section number. */ |
|
|
cp = mandoc_a2msec(nn->string); |
cp = mandoc_a2msec(nn->string); |
if (cp) { |
if (cp == NULL) { |
mdoc->meta.vol = mandoc_strdup(cp); |
|
mdoc->meta.msec = mandoc_strdup(nn->string); |
|
} else { |
|
mandoc_vmsg(MANDOCERR_MSEC_BAD, mdoc->parse, |
mandoc_vmsg(MANDOCERR_MSEC_BAD, mdoc->parse, |
nn->line, nn->pos, "Dt ... %s", nn->string); |
nn->line, nn->pos, "Dt ... %s", nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
mdoc->meta.msec = mandoc_strdup(nn->string); |
} else |
} |
mdoc->meta.vol = mandoc_strdup(cp); |
|
|
/* Handle an optional architecture */ |
/* Optional third argument: architecture. */ |
|
|
if ((nn = nn->next) != NULL) { |
if ((nn = nn->next) == NULL) |
for (p = nn->string; *p; p++) |
goto out; |
*p = tolower((unsigned char)*p); |
|
mdoc->meta.arch = mandoc_strdup(nn->string); |
|
} |
|
|
|
/* Ignore any subsequent parameters... */ |
for (p = nn->string; *p != '\0'; p++) |
/* FIXME: warn about subsequent parameters. */ |
*p = tolower((unsigned char)*p); |
|
mdoc->meta.arch = mandoc_strdup(nn->string); |
|
|
|
/* Ignore fourth and later arguments. */ |
|
|
|
if ((nn = nn->next) != NULL) |
|
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
|
nn->line, nn->pos, "Dt ... %s", nn->string); |
|
|
out: |
out: |
mdoc_node_delete(mdoc, n); |
mdoc_node_delete(mdoc, n); |
} |
} |