version 1.269, 2015/02/04 19:20:12 |
version 1.272, 2015/02/06 01:07:22 |
Line 70 static void rewrite_macro2len(char **); |
|
Line 70 static void rewrite_macro2len(char **); |
|
static void bwarn_ge1(POST_ARGS); |
static void bwarn_ge1(POST_ARGS); |
static void ewarn_eq1(POST_ARGS); |
static void ewarn_eq1(POST_ARGS); |
static void ewarn_ge1(POST_ARGS); |
static void ewarn_ge1(POST_ARGS); |
static void hwarn_eq0(POST_ARGS); |
|
|
|
static void post_an(POST_ARGS); |
static void post_an(POST_ARGS); |
static void post_at(POST_ARGS); |
static void post_at(POST_ARGS); |
Line 157 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 156 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, post_fn }, /* Fn */ |
{ NULL, post_fn }, /* Fn */ |
{ NULL, NULL }, /* Ft */ |
{ NULL, NULL }, /* Ft */ |
{ NULL, NULL }, /* Ic */ |
{ NULL, NULL }, /* Ic */ |
{ NULL, ewarn_eq1 }, /* In */ |
{ NULL, NULL }, /* In */ |
{ NULL, post_defaults }, /* Li */ |
{ NULL, post_defaults }, /* Li */ |
{ NULL, post_nd }, /* Nd */ |
{ NULL, post_nd }, /* Nd */ |
{ NULL, post_nm }, /* Nm */ |
{ NULL, post_nm }, /* Nm */ |
Line 168 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 167 static const struct valids mdoc_valids[MDOC_MAX] = { |
|
{ NULL, post_st }, /* St */ |
{ NULL, post_st }, /* St */ |
{ NULL, NULL }, /* Va */ |
{ NULL, NULL }, /* Va */ |
{ NULL, post_vt }, /* Vt */ |
{ NULL, post_vt }, /* Vt */ |
{ NULL, ewarn_ge1 }, /* Xr */ |
{ NULL, NULL }, /* Xr */ |
{ NULL, ewarn_ge1 }, /* %A */ |
{ NULL, ewarn_ge1 }, /* %A */ |
{ NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */ |
{ NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */ |
{ NULL, ewarn_ge1 }, /* %D */ |
{ NULL, ewarn_ge1 }, /* %D */ |
Line 421 ewarn_ge1(POST_ARGS) |
|
Line 420 ewarn_ge1(POST_ARGS) |
|
} |
} |
|
|
static void |
static void |
hwarn_eq0(POST_ARGS) |
|
{ |
|
check_count(mdoc, MDOC_HEAD, CHECK_EQ, 0); |
|
} |
|
|
|
static void |
|
check_args(struct mdoc *mdoc, struct mdoc_node *n) |
check_args(struct mdoc *mdoc, struct mdoc_node *n) |
{ |
{ |
int i; |
int i; |
|
|
post_literal(POST_ARGS) |
post_literal(POST_ARGS) |
{ |
{ |
|
|
if (mdoc->last->tok == MDOC_Bd) |
|
hwarn_eq0(mdoc); |
|
bwarn_ge1(mdoc); |
bwarn_ge1(mdoc); |
|
|
/* |
/* |
Line 1177 post_an(POST_ARGS) |
|
Line 1168 post_an(POST_ARGS) |
|
struct mdoc_node *np, *nch; |
struct mdoc_node *np, *nch; |
|
|
np = mdoc->last; |
np = mdoc->last; |
if (AUTH__NONE == np->norm->An.auth) { |
nch = np->child; |
if (0 == np->child) |
if (np->norm->An.auth == AUTH__NONE) { |
check_count(mdoc, MDOC_ELEM, CHECK_GT, 0); |
if (nch == NULL) |
} else if ((nch = np->child) != NULL) |
mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, |
|
np->line, np->pos, "An"); |
|
} else if (nch != NULL) |
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
nch->line, nch->pos, "An ... %s", nch->string); |
nch->line, nch->pos, "An ... %s", nch->string); |
} |
} |
Line 1415 post_bl_block_tag(POST_ARGS) |
|
Line 1408 post_bl_block_tag(POST_ARGS) |
|
static void |
static void |
post_bl_head(POST_ARGS) |
post_bl_head(POST_ARGS) |
{ |
{ |
struct mdoc_node *np, *nn, *nnp; |
struct mdoc_node *nbl, *nh, *nch, *nnext; |
struct mdoc_argv *argv; |
struct mdoc_argv *argv; |
int i, j; |
int i, j; |
|
|
if (LIST_column != mdoc->last->norm->Bl.type) { |
nh = mdoc->last; |
/* FIXME: this should be ERROR class... */ |
|
hwarn_eq0(mdoc); |
if (nh->norm->Bl.type != LIST_column) { |
|
if ((nch = nh->child) == NULL) |
|
return; |
|
mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, |
|
nch->line, nch->pos, "Bl ... %s", nch->string); |
|
while (nch != NULL) { |
|
mdoc_node_delete(mdoc, nch); |
|
nch = nh->child; |
|
} |
return; |
return; |
} |
} |
|
|
Line 1431 post_bl_head(POST_ARGS) |
|
Line 1432 post_bl_head(POST_ARGS) |
|
* lists where they're argument values following -column. |
* lists where they're argument values following -column. |
*/ |
*/ |
|
|
if (mdoc->last->child == NULL) |
if (nh->child == NULL) |
return; |
return; |
|
|
np = mdoc->last->parent; |
nbl = nh->parent; |
assert(np->args); |
for (j = 0; j < (int)nbl->args->argc; j++) |
|
if (nbl->args->argv[j].arg == MDOC_Column) |
for (j = 0; j < (int)np->args->argc; j++) |
|
if (MDOC_Column == np->args->argv[j].arg) |
|
break; |
break; |
|
|
assert(j < (int)np->args->argc); |
assert(j < (int)nbl->args->argc); |
|
|
/* |
/* |
* Accommodate for new-style groff column syntax. Shuffle the |
* Accommodate for new-style groff column syntax. Shuffle the |
Line 1449 post_bl_head(POST_ARGS) |
|
Line 1448 post_bl_head(POST_ARGS) |
|
* column field. Then, delete the head children. |
* column field. Then, delete the head children. |
*/ |
*/ |
|
|
argv = np->args->argv + j; |
argv = nbl->args->argv + j; |
i = argv->sz; |
i = argv->sz; |
argv->sz += mdoc->last->nchild; |
argv->sz += nh->nchild; |
argv->value = mandoc_reallocarray(argv->value, |
argv->value = mandoc_reallocarray(argv->value, |
argv->sz, sizeof(char *)); |
argv->sz, sizeof(char *)); |
|
|
mdoc->last->norm->Bl.ncols = argv->sz; |
nh->norm->Bl.ncols = argv->sz; |
mdoc->last->norm->Bl.cols = (void *)argv->value; |
nh->norm->Bl.cols = (void *)argv->value; |
|
|
for (nn = mdoc->last->child; nn; i++) { |
for (nch = nh->child; nch != NULL; nch = nnext) { |
argv->value[i] = nn->string; |
argv->value[i++] = nch->string; |
nn->string = NULL; |
nch->string = NULL; |
nnp = nn; |
nnext = nch->next; |
nn = nn->next; |
mdoc_node_delete(NULL, nch); |
mdoc_node_delete(NULL, nnp); |
|
} |
} |
|
nh->nchild = 0; |
mdoc->last->nchild = 0; |
nh->child = NULL; |
mdoc->last->child = NULL; |
|
} |
} |
|
|
static void |
static void |
Line 1553 post_bl(POST_ARGS) |
|
Line 1550 post_bl(POST_ARGS) |
|
static void |
static void |
post_bk(POST_ARGS) |
post_bk(POST_ARGS) |
{ |
{ |
|
struct mdoc_node *n; |
|
|
hwarn_eq0(mdoc); |
n = mdoc->last; |
bwarn_ge1(mdoc); |
|
|
if (n->type == MDOC_BLOCK && n->body->child == NULL) { |
|
mandoc_msg(MANDOCERR_MACRO_EMPTY, |
|
mdoc->parse, n->line, n->pos, "Bk"); |
|
mdoc_node_delete(mdoc, n); |
|
} |
} |
} |
|
|
static void |
static void |
Line 1637 post_st(POST_ARGS) |
|
Line 1640 post_st(POST_ARGS) |
|
n = mdoc->last; |
n = mdoc->last; |
nch = n->child; |
nch = n->child; |
|
|
if (NULL == nch) { |
|
mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, |
|
n->line, n->pos, mdoc_macronames[n->tok]); |
|
mdoc_node_delete(mdoc, n); |
|
return; |
|
} |
|
|
|
assert(MDOC_TEXT == nch->type); |
assert(MDOC_TEXT == nch->type); |
|
|
if (NULL == (p = mdoc_a2st(nch->string))) { |
if (NULL == (p = mdoc_a2st(nch->string))) { |
Line 2073 post_ignpar(POST_ARGS) |
|
Line 2069 post_ignpar(POST_ARGS) |
|
{ |
{ |
struct mdoc_node *np; |
struct mdoc_node *np; |
|
|
check_count(mdoc, MDOC_HEAD, CHECK_GT, 0); |
|
post_hyph(mdoc); |
post_hyph(mdoc); |
|
|
if (MDOC_BODY != mdoc->last->type) |
if (MDOC_BODY != mdoc->last->type) |