-enum check_lvl {
- CHECK_WARN,
- CHECK_ERROR,
-};
-
-typedef int (*v_pre)(PRE_ARGS);
-typedef int (*v_post)(POST_ARGS);
-
-struct valids {
- v_pre *pre;
- v_post *post;
-};
-
-static int check_count(struct mdoc *, enum mdoc_type,
- enum check_lvl, enum check_ineq, int);
-static int check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);
-static void check_text(struct mdoc *, int, int, char *);
-static void check_argv(struct mdoc *,
- struct mdoc_node *, struct mdoc_argv *);
-static void check_args(struct mdoc *, struct mdoc_node *);
-static enum mdoc_sec a2sec(const char *);
-static size_t macro2len(enum mdoct);
-
-static int ebool(POST_ARGS);
-static int berr_ge1(POST_ARGS);
-static int bwarn_ge1(POST_ARGS);
-static int ewarn_eq0(POST_ARGS);
-static int ewarn_eq1(POST_ARGS);
-static int ewarn_ge1(POST_ARGS);
-static int ewarn_le1(POST_ARGS);
-static int hwarn_eq0(POST_ARGS);
-static int hwarn_eq1(POST_ARGS);
-static int hwarn_ge1(POST_ARGS);
-static int hwarn_le1(POST_ARGS);
-
-static int post_an(POST_ARGS);
-static int post_at(POST_ARGS);
-static int post_bf(POST_ARGS);
-static int post_bl(POST_ARGS);
-static int post_bl_block(POST_ARGS);
-static int post_bl_block_width(POST_ARGS);
-static int post_bl_block_tag(POST_ARGS);
-static int post_bl_head(POST_ARGS);
-static int post_bx(POST_ARGS);
-static int post_defaults(POST_ARGS);
-static int post_dd(POST_ARGS);
-static int post_dt(POST_ARGS);
-static int post_en(POST_ARGS);
-static int post_es(POST_ARGS);
-static int post_eoln(POST_ARGS);
-static int post_hyph(POST_ARGS);
-static int post_ignpar(POST_ARGS);
-static int post_it(POST_ARGS);
-static int post_lb(POST_ARGS);
-static int post_literal(POST_ARGS);
-static int post_nm(POST_ARGS);
-static int post_ns(POST_ARGS);
-static int post_os(POST_ARGS);
-static int post_par(POST_ARGS);
-static int post_prol(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);
-static int post_st(POST_ARGS);
-static int post_std(POST_ARGS);
-static int post_vt(POST_ARGS);
-static int pre_an(PRE_ARGS);
-static int pre_bd(PRE_ARGS);
-static int pre_bl(PRE_ARGS);
-static int pre_dd(PRE_ARGS);
-static int pre_display(PRE_ARGS);
-static int pre_dt(PRE_ARGS);
-static int pre_it(PRE_ARGS);
-static int pre_literal(PRE_ARGS);
-static int pre_obsolete(PRE_ARGS);
-static int pre_os(PRE_ARGS);
-static int pre_par(PRE_ARGS);
-static int pre_sh(PRE_ARGS);
-static int pre_ss(PRE_ARGS);
-static int pre_std(PRE_ARGS);
-
-static v_post posts_an[] = { post_an, NULL };
-static v_post posts_at[] = { post_at, post_defaults, NULL };
-static v_post posts_bd[] = { post_literal, hwarn_eq0, bwarn_ge1, NULL };
-static v_post posts_bf[] = { hwarn_le1, post_bf, NULL };
-static v_post posts_bk[] = { hwarn_eq0, bwarn_ge1, NULL };
-static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
-static v_post posts_bx[] = { post_bx, NULL };
-static v_post posts_bool[] = { ebool, NULL };
-static v_post posts_eoln[] = { post_eoln, NULL };
-static v_post posts_defaults[] = { post_defaults, NULL };
-static v_post posts_d1[] = { bwarn_ge1, post_hyph, NULL };
-static v_post posts_dd[] = { post_dd, post_prol, NULL };
-static v_post posts_dl[] = { post_literal, bwarn_ge1, NULL };
-static v_post posts_dt[] = { post_dt, post_prol, NULL };
-static v_post posts_en[] = { post_en, NULL };
-static v_post posts_es[] = { post_es, NULL };
-static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
-static v_post posts_hyph[] = { post_hyph, NULL };
-static v_post posts_hyphtext[] = { ewarn_ge1, post_hyph, NULL };
-static v_post posts_it[] = { post_it, NULL };
-static v_post posts_lb[] = { post_lb, NULL };
-static v_post posts_nd[] = { berr_ge1, post_hyph, NULL };
-static v_post posts_nm[] = { post_nm, NULL };
-static v_post posts_notext[] = { ewarn_eq0, NULL };
-static v_post posts_ns[] = { post_ns, NULL };
-static v_post posts_os[] = { post_os, post_prol, NULL };
-static v_post posts_pp[] = { post_par, ewarn_eq0, NULL };
-static v_post posts_rs[] = { post_rs, NULL };
-static v_post posts_sh[] = { post_ignpar,hwarn_ge1,post_sh,post_hyph,NULL };
-static v_post posts_sp[] = { post_par, ewarn_le1, NULL };
-static v_post posts_ss[] = { post_ignpar, hwarn_ge1, post_hyph, NULL };
-static v_post posts_st[] = { post_st, NULL };
-static v_post posts_std[] = { post_std, NULL };
-static v_post posts_text[] = { ewarn_ge1, NULL };
-static v_post posts_text1[] = { ewarn_eq1, NULL };
-static v_post posts_vt[] = { post_vt, NULL };
-static v_pre pres_an[] = { pre_an, NULL };
-static v_pre pres_bd[] = { pre_display, pre_bd, pre_literal, pre_par, NULL };
-static v_pre pres_bl[] = { pre_bl, pre_par, NULL };
-static v_pre pres_d1[] = { pre_display, NULL };
-static v_pre pres_dl[] = { pre_literal, pre_display, NULL };
-static v_pre pres_dd[] = { pre_dd, NULL };
-static v_pre pres_dt[] = { pre_dt, NULL };
-static v_pre pres_it[] = { pre_it, pre_par, NULL };
-static v_pre pres_obsolete[] = { pre_obsolete, NULL };
-static v_pre pres_os[] = { pre_os, NULL };
-static v_pre pres_pp[] = { pre_par, NULL };
-static v_pre pres_sh[] = { pre_sh, NULL };
-static v_pre pres_ss[] = { pre_ss, NULL };
-static v_pre pres_std[] = { pre_std, NULL };
-
-static const struct valids mdoc_valids[MDOC_MAX] = {
- { NULL, NULL }, /* Ap */
- { pres_dd, posts_dd }, /* Dd */
- { pres_dt, posts_dt }, /* Dt */
- { pres_os, posts_os }, /* Os */
- { pres_sh, posts_sh }, /* Sh */
- { pres_ss, posts_ss }, /* Ss */
- { pres_pp, posts_pp }, /* Pp */
- { pres_d1, posts_d1 }, /* D1 */
- { pres_dl, posts_dl }, /* Dl */
- { pres_bd, posts_bd }, /* Bd */
- { NULL, NULL }, /* Ed */
- { pres_bl, posts_bl }, /* Bl */
- { NULL, NULL }, /* El */
- { pres_it, posts_it }, /* It */
- { NULL, NULL }, /* Ad */
- { pres_an, posts_an }, /* An */
- { NULL, posts_defaults }, /* Ar */
- { NULL, NULL }, /* Cd */
- { NULL, NULL }, /* Cm */
- { NULL, NULL }, /* Dv */
- { NULL, NULL }, /* Er */
- { NULL, NULL }, /* Ev */
- { pres_std, posts_std }, /* Ex */
- { NULL, NULL }, /* Fa */
- { NULL, posts_text }, /* Fd */
- { NULL, NULL }, /* Fl */
- { NULL, NULL }, /* Fn */
- { NULL, NULL }, /* Ft */
- { NULL, NULL }, /* Ic */
- { NULL, posts_text1 }, /* In */
- { NULL, posts_defaults }, /* Li */
- { NULL, posts_nd }, /* Nd */
- { NULL, posts_nm }, /* Nm */
- { NULL, NULL }, /* Op */
- { pres_obsolete, NULL }, /* Ot */
- { NULL, posts_defaults }, /* Pa */
- { pres_std, posts_std }, /* Rv */
- { NULL, posts_st }, /* St */
- { NULL, NULL }, /* Va */
- { NULL, posts_vt }, /* Vt */
- { NULL, posts_text }, /* Xr */
- { NULL, posts_text }, /* %A */
- { NULL, posts_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */
- { NULL, posts_text }, /* %D */
- { NULL, posts_text }, /* %I */
- { NULL, posts_text }, /* %J */
- { NULL, posts_hyphtext }, /* %N */
- { NULL, posts_hyphtext }, /* %O */
- { NULL, posts_text }, /* %P */
- { NULL, posts_hyphtext }, /* %R */
- { NULL, posts_hyphtext }, /* %T */ /* FIXME: can be used outside Rs/Re. */
- { NULL, posts_text }, /* %V */
- { NULL, NULL }, /* Ac */
- { NULL, NULL }, /* Ao */
- { NULL, NULL }, /* Aq */
- { NULL, posts_at }, /* At */
- { NULL, NULL }, /* Bc */
- { NULL, posts_bf }, /* Bf */
- { NULL, NULL }, /* Bo */
- { NULL, NULL }, /* Bq */
- { NULL, NULL }, /* Bsx */
- { NULL, posts_bx }, /* Bx */
- { NULL, posts_bool }, /* Db */
- { NULL, NULL }, /* Dc */
- { NULL, NULL }, /* Do */
- { NULL, NULL }, /* Dq */
- { NULL, NULL }, /* Ec */
- { NULL, NULL }, /* Ef */
- { NULL, NULL }, /* Em */
- { NULL, NULL }, /* Eo */
- { NULL, NULL }, /* Fx */
- { NULL, NULL }, /* Ms */
- { NULL, posts_notext }, /* No */
- { NULL, posts_ns }, /* Ns */
- { NULL, NULL }, /* Nx */
- { NULL, NULL }, /* Ox */
- { NULL, NULL }, /* Pc */
- { NULL, posts_text1 }, /* Pf */
- { NULL, NULL }, /* Po */
- { NULL, NULL }, /* Pq */
- { NULL, NULL }, /* Qc */
- { NULL, NULL }, /* Ql */
- { NULL, NULL }, /* Qo */
- { NULL, NULL }, /* Qq */
- { NULL, NULL }, /* Re */
- { NULL, posts_rs }, /* Rs */
- { NULL, NULL }, /* Sc */
- { NULL, NULL }, /* So */
- { NULL, NULL }, /* Sq */
- { NULL, posts_bool }, /* Sm */
- { NULL, posts_hyph }, /* Sx */
- { NULL, NULL }, /* Sy */
- { NULL, NULL }, /* Tn */
- { NULL, NULL }, /* Ux */
- { NULL, NULL }, /* Xc */
- { NULL, NULL }, /* Xo */
- { NULL, posts_fo }, /* Fo */
- { NULL, NULL }, /* Fc */
- { NULL, NULL }, /* Oo */
- { NULL, NULL }, /* Oc */
- { NULL, posts_bk }, /* Bk */
- { NULL, NULL }, /* Ek */
- { NULL, posts_eoln }, /* Bt */
- { NULL, NULL }, /* Hf */
- { pres_obsolete, NULL }, /* Fr */
- { NULL, posts_eoln }, /* Ud */
- { NULL, posts_lb }, /* Lb */
- { pres_pp, posts_pp }, /* Lp */
- { NULL, NULL }, /* Lk */
- { NULL, posts_defaults }, /* Mt */
- { NULL, NULL }, /* Brq */
- { NULL, NULL }, /* Bro */
- { NULL, NULL }, /* Brc */
- { NULL, posts_text }, /* %C */
- { pres_obsolete, posts_es }, /* Es */
- { pres_obsolete, posts_en }, /* En */
- { NULL, NULL }, /* Dx */
- { NULL, posts_text }, /* %Q */
- { NULL, posts_pp }, /* br */
- { NULL, posts_sp }, /* sp */
- { NULL, posts_text1 }, /* %U */
- { NULL, NULL }, /* Ta */
- { NULL, NULL }, /* ll */