diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-06 03:38:45 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-06 03:38:45 +0000 |
commit | f1b8e7051e92af5f6c90c234ea75598ee7976318 (patch) | |
tree | e89f39da84ae391f6274db2c8a96f024fdf27709 /mdoc_validate.c | |
parent | 5c488f049fc8ba35c593e62595b53c5e7baf56f8 (diff) | |
download | mandoc-f1b8e7051e92af5f6c90c234ea75598ee7976318.tar.gz |
better handle .Fo and .Fd without argument
better handle .Fo with more than one argument
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index cf7358bf..b554a9bb 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -67,7 +67,6 @@ static enum mdoc_sec a2sec(const char *); static size_t macro2len(enum mdoct); static void rewrite_macro2len(char **); -static void bwarn_ge1(POST_ARGS); static void ewarn_eq1(POST_ARGS); static void ewarn_ge1(POST_ARGS); @@ -151,7 +150,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Ev */ { pre_std, post_ex }, /* Ex */ { NULL, post_fa }, /* Fa */ - { NULL, ewarn_ge1 }, /* Fd */ + { NULL, NULL }, /* Fd */ { NULL, NULL }, /* Fl */ { NULL, post_fn }, /* Fn */ { NULL, NULL }, /* Ft */ @@ -402,12 +401,6 @@ check_count(struct mdoc *mdoc, enum mdoc_type type, } static void -bwarn_ge1(POST_ARGS) -{ - check_count(mdoc, MDOC_BODY, CHECK_GT, 0); -} - -static void ewarn_eq1(POST_ARGS) { check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); @@ -980,11 +973,27 @@ post_fn(POST_ARGS) static void post_fo(POST_ARGS) { + const struct mdoc_node *n; + + n = mdoc->last; + + if (n->type != MDOC_HEAD) + return; + + if (n->child == NULL) { + mandoc_msg(MANDOCERR_FO_NOHEAD, mdoc->parse, + n->line, n->pos, "Fo"); + return; + } + if (n->child != n->last) { + mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, + n->child->next->line, n->child->next->pos, + "Fo ... %s", n->child->next->string); + while (n->child != n->last) + mdoc_node_delete(mdoc, n->last); + } - check_count(mdoc, MDOC_HEAD, CHECK_EQ, 1); - bwarn_ge1(mdoc); - if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild) - post_fname(mdoc); + post_fname(mdoc); } static void |