version 1.87, 2010/05/30 22:56:02 |
version 1.90, 2010/05/31 23:40:25 |
Line 268 const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 268 const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, posts_notext }, /* br */ |
{ NULL, posts_notext }, /* br */ |
{ NULL, posts_sp }, /* sp */ |
{ NULL, posts_sp }, /* sp */ |
{ NULL, posts_text1 }, /* %U */ |
{ NULL, posts_text1 }, /* %U */ |
|
{ NULL, NULL }, /* Ta */ |
}; |
}; |
|
|
|
|
Line 928 post_an(POST_ARGS) |
|
Line 929 post_an(POST_ARGS) |
|
static int |
static int |
post_it(POST_ARGS) |
post_it(POST_ARGS) |
{ |
{ |
/* FIXME: use mdoc_list! */ |
int i, cols, rc; |
int type, i, cols; |
enum mdoc_list lt; |
struct mdoc_node *n, *c; |
struct mdoc_node *n, *c; |
|
enum mandocerr er; |
|
|
if (MDOC_BLOCK != mdoc->last->type) |
if (MDOC_BLOCK != mdoc->last->type) |
return(1); |
return(1); |
|
|
n = mdoc->last->parent->parent; |
n = mdoc->last->parent->parent; |
if (NULL == n->args) { |
lt = n->data.list; |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE); |
|
return(0); |
|
} |
|
|
|
/* Some types require block-head, some not. */ |
if (LIST__NONE == lt) { |
|
|
/* LINTED */ |
|
for (cols = type = -1, i = 0; -1 == type && |
|
i < (int)n->args->argc; i++) |
|
switch (n->args->argv[i].arg) { |
|
case (MDOC_Tag): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Diag): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Hang): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Ohang): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Inset): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Bullet): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Dash): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Enum): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Hyphen): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Item): |
|
type = n->args->argv[i].arg; |
|
break; |
|
case (MDOC_Column): |
|
type = n->args->argv[i].arg; |
|
cols = (int)n->args->argv[i].sz; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
if (-1 == type) { |
|
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE); |
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE); |
return(0); |
return(0); |
} |
} |
|
|
switch (type) { |
switch (lt) { |
case (MDOC_Tag): |
case (LIST_tag): |
if (NULL == mdoc->last->head->child) |
if (mdoc->last->head->child) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS)) |
break; |
return(0); |
/* FIXME: give this a dummy value. */ |
|
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS)) |
|
return(0); |
break; |
break; |
case (MDOC_Hang): |
case (LIST_hang): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Ohang): |
case (LIST_ohang): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Inset): |
case (LIST_inset): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Diag): |
case (LIST_diag): |
if (NULL == mdoc->last->head->child) |
if (NULL == mdoc->last->head->child) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS)) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS)) |
return(0); |
return(0); |
Line 1001 post_it(POST_ARGS) |
|
Line 967 post_it(POST_ARGS) |
|
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) |
return(0); |
return(0); |
break; |
break; |
case (MDOC_Bullet): |
case (LIST_bullet): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Enum): |
case (LIST_enum): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (LIST_hyphen): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Item): |
case (LIST_item): |
if (mdoc->last->head->child) |
if (mdoc->last->head->child) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST)) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST)) |
return(0); |
return(0); |
Line 1017 post_it(POST_ARGS) |
|
Line 983 post_it(POST_ARGS) |
|
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) |
return(0); |
return(0); |
break; |
break; |
case (MDOC_Column): |
case (LIST_column): |
|
cols = -1; |
|
for (i = 0; i < (int)n->args->argc; i++) |
|
if (MDOC_Column == n->args->argv[i].arg) { |
|
cols = (int)n->args->argv[i].sz; |
|
break; |
|
} |
|
|
|
assert(-1 != cols); |
assert(NULL == mdoc->last->head->child); |
assert(NULL == mdoc->last->head->child); |
|
|
if (NULL == mdoc->last->body->child) |
if (NULL == mdoc->last->body->child) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) |
if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY)) |
return(0); |
return(0); |
|
|
/* Count up the number of columns. */ |
for (i = 0, c = mdoc->last->child; c; c = c->next) |
c = mdoc->last->child; |
|
for (i = 0; c; c = c->next) |
|
if (MDOC_BODY == c->type) |
if (MDOC_BODY == c->type) |
i++; |
i++; |
|
|
if (i < cols) { |
if (i < cols) |
if ( ! mdoc_vmsg(mdoc, MANDOCERR_ARGCOUNT, |
er = MANDOCERR_ARGCOUNT; |
mdoc->last->line, |
else if (i == cols || i == cols + 1) |
mdoc->last->pos, |
|
"columns == %d (have %d)", |
|
cols, i)) |
|
return(0); |
|
break; |
break; |
} else if (i == cols || i == cols + 1) |
else |
break; |
er = MANDOCERR_SYNTARGCOUNT; |
|
|
mdoc_vmsg(mdoc, MANDOCERR_SYNTARGCOUNT, |
rc = mdoc_vmsg(mdoc, er, |
mdoc->last->line, mdoc->last->pos, |
mdoc->last->line, mdoc->last->pos, |
"columns == %d (have %d)", cols, i); |
"columns == %d (have %d)", cols, i); |
return(0); |
return(rc); |
default: |
default: |
break; |
break; |
} |
} |
Line 1055 post_it(POST_ARGS) |
|
Line 1024 post_it(POST_ARGS) |
|
static int |
static int |
post_bl_head(POST_ARGS) |
post_bl_head(POST_ARGS) |
{ |
{ |
int i; |
int i; |
const struct mdoc_node *n; |
struct mdoc_node *n; |
const struct mdoc_argv *a; |
|
|
|
|
assert(mdoc->last->parent); |
n = mdoc->last->parent; |
n = mdoc->last->parent; |
assert(n->args); |
|
|
|
for (i = 0; i < (int)n->args->argc; i++) { |
if (LIST_column == n->data.list) { |
a = &n->args->argv[i]; |
for (i = 0; i < (int)n->args->argc; i++) |
if (a->arg == MDOC_Column) { |
if (MDOC_Column == n->args->argv[i].arg) |
if (a->sz && mdoc->last->nchild) |
break; |
return(mdoc_nmsg(mdoc, n, MANDOCERR_COLUMNS)); |
assert(i < (int)n->args->argc); |
return(1); |
|
|
if (n->args->argv[i].sz && mdoc->last->nchild) { |
|
mdoc_nmsg(mdoc, n, MANDOCERR_COLUMNS); |
|
return(0); |
} |
} |
|
return(1); |
} |
} |
|
|
if (0 == (i = mdoc->last->nchild)) |
if (0 == (i = mdoc->last->nchild)) |