diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-09-24 15:01:06 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-09-24 15:01:06 +0000 |
commit | 183e6ae0229d1ddcdf3a1f493eaae4a39d11d97a (patch) | |
tree | fcfba174f3984847528e7def61f307ee45c4ec54 /mdoc_validate.c | |
parent | 6a2359747f92ffc48b612b8fb8a2e7a87a9dff8f (diff) | |
download | mandoc-183e6ae0229d1ddcdf3a1f493eaae4a39d11d97a.tar.gz |
Added EBADCHILD error (bad child of parent context).
`Rs' post-checks that all children are proper bibliographic elements.
`Rs' correctly re-orders its children as per groff's output (including %C).
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index 558dd931..abc32752 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -89,6 +89,7 @@ static int post_it(POST_ARGS); static int post_lb(POST_ARGS); static int post_nm(POST_ARGS); static int post_root(POST_ARGS); +static int post_rs(POST_ARGS); static int post_sh(POST_ARGS); static int post_sh_body(POST_ARGS); static int post_sh_head(POST_ARGS); @@ -125,6 +126,7 @@ static v_post posts_nd[] = { berr_ge1, NULL }; static v_post posts_nm[] = { post_nm, NULL }; static v_post posts_notext[] = { eerr_eq0, NULL }; static v_post posts_pf[] = { eerr_eq1, NULL }; +static v_post posts_rs[] = { bwarn_ge1, herr_eq0, post_rs, NULL }; static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL }; static v_post posts_sp[] = { post_sp, NULL }; static v_post posts_ss[] = { herr_ge1, NULL }; @@ -236,7 +238,7 @@ const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Qo */ { NULL, posts_wline }, /* Qq */ { NULL, NULL }, /* Re */ - { NULL, posts_wline }, /* Rs */ + { NULL, posts_rs }, /* Rs */ { NULL, NULL }, /* Sc */ { NULL, NULL }, /* So */ { NULL, posts_wline }, /* Sq */ @@ -1077,9 +1079,7 @@ post_bl(POST_ARGS) if (MDOC_BLOCK == n->type) if (MDOC_It == n->tok) continue; - return(mdoc_verr(mdoc, n->line, n->pos, - "bad child of parent %s", - mdoc_macronames[mdoc->last->tok])); + return(mdoc_nerr(mdoc, n, EBADCHILD)); } return(1); @@ -1168,6 +1168,50 @@ post_st(POST_ARGS) static int +post_rs(POST_ARGS) +{ + struct mdoc_node *nn; + + if (MDOC_BODY != mdoc->last->type) + return(1); + + for (nn = mdoc->last->child; nn; nn = nn->next) + switch (nn->tok) { + case(MDOC__Q): + /* FALLTHROUGH */ + case(MDOC__C): + /* FALLTHROUGH */ + case(MDOC__A): + /* FALLTHROUGH */ + case(MDOC__B): + /* FALLTHROUGH */ + case(MDOC__D): + /* FALLTHROUGH */ + case(MDOC__I): + /* FALLTHROUGH */ + case(MDOC__J): + /* FALLTHROUGH */ + case(MDOC__N): + /* FALLTHROUGH */ + case(MDOC__O): + /* FALLTHROUGH */ + case(MDOC__P): + /* FALLTHROUGH */ + case(MDOC__R): + /* FALLTHROUGH */ + case(MDOC__T): + /* FALLTHROUGH */ + case(MDOC__V): + break; + default: + return(mdoc_nerr(mdoc, nn, EBADCHILD)); + } + + return(1); +} + + +static int post_sh(POST_ARGS) { |